Top Banner
Next generation of FRONT END architectures
27

Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

Apr 16, 2017

Download

Technology

Codemotion
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

Next generation of FRONT END architectures

Page 2: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

HELLO!

I am Luca MezzaliraSolutions Architect @ DAZN

Google Developer Expert on Web technologies

Community Manager of London JavaScript Community

Page 3: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

AGENDA▸ Front end architectures

overview

▸ Reactive programming

▸ MVI

Page 4: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

1.ARCHITECTURES PAST & PRESENT

Page 5: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

Architectures Timeline

90s

MVP

80s

MVC

2005

MVVM

2013

FLUX

2009

DCI

2015

MVI

Page 6: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

What are we trying to solve with event driven architectures?

Page 7: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

▸ Events▸ Signals▸ Pub/Sub system▸ Actions + Dispatcher▸ ...

OBJECTS COMMUNICATION

Page 8: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

2.REACTIVE PROGRAMMING

Page 9: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

PROGRAMMING PARADIGMSFUNCTIONALIt is a declarative programming paradigm, which means programming is done with expressions. In functional code, the output value of a function depends only on the arguments that are input to the function, so calling a function f twice with the same value for an argument x will produce the same result f(x) each time.

IMPERATIVEIt is a programming paradigm that uses statements that change a program's state. In much the same way that the imperative mood in natural languages expresses commands, an imperative program consists of commands for the computer to perform. Imperative programming focuses on describing how a program operates.

REACTIVEIt is a programming paradigm oriented around data flows and the propagation of change. This means that it should be possible to express static or dynamic data flows with ease in the programming languages used, and that the underlying execution model will automatically propagate changes through the data flow.

Page 10: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

PASSIVE REACTIVE

BA BA

Page 11: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

Reactive Bingo

Page 12: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

STREAMSA stream is a sequence of ongoing events ordered in time. It can emit three different things: a value (of some type), an error, or a "completed" signal.

EVERYTHING CAN BE A STREAM

Page 13: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

OBSERVER PATTERNThe observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems.

Page 14: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

3.MODEL VIEW INTENT

Page 15: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

VIEW MODELPRESENTER

https://en.wikipedia.org/wiki/Model-view-presenter

Page 16: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

VIEW INTENT

MODEL

RENDERER

futurice.com/blog/reactive-mvc-and-the-virtual-dom

Page 17: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

VIEWInput: data events from the Model.

Output: a Virtual DOM rendering of the model, and raw user input events (such as clicks, keyboard typing, accelerometer events, etc).

VIEW

RENDERER

Page 18: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

INTENTInput: raw user input events from the View.

Output: model-friendly user intention events.

INTENT

Page 19: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

MODELInput: user interaction events from the Intent.

Output: data events.

MODEL

Page 20: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

MVI RULES▸ A module shouldn’t control

any other module (controller in MVC)

▸ The only shared part between modules are observables

▸ Intent is a component with only one responsibility: It should interpret what the user is trying to do in terms of model updates, and export these "user intentions" as events

Page 21: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

4.Cycle.js

Page 22: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

Cycle.js

Page 23: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

Cycle in action

Page 24: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

Awesome Cycle.jshttps://github.com/cyclejs-community/awesome-cyclejs

Cycle.jshttp://cycle.js.org/

Unidirectional Data flowhttps://vimeo.com/168652278

Cycle.js fundamentalshttps://egghead.io/courses/cycle-js-fundamentals

Page 25: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

Shall we useReactive Programming

in any project then?

Page 26: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

media.dazn.com

JOIN US :)

Page 27: Next generation of frontend architectures - Luca Mezzalira - Codemotion Milan 2016

THANKS EVERYONE

Q&A@lucamezzalira

www.lucamezzalira.com

www.londonjs.uk

[email protected]