Reactive programming with cycle.js

luca mezzalira
luca mezzaliraSolutions Architect | Google Developer Expert | London JS community manager at Massive Interactive
Reactive
programming with
Cycle.js
HELLO!
I am Luca Mezzalira
Solutions Architect @ Massive Interactive
Google Developer Expert on Web Technologies
Community Manager of London JavaScript User Group
AGENDA
▸ Reactive programming
▸ Model - View - Intent
▸ Cycle.js
1.
REACTIVE
PROGRAMMING
PROGRAMMING PARADIGMS
FUNCTIONAL
It 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.
IMPERATIVE
It 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.
REACTIVE
It 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.
Imperative vs Reactive
REACTIVE PROGRAMMING IS
PROGRAMMING WITH
ASYNCHRONOUS DATA STREAMS
IS REACTIVE
PROGRAMMING
REALLY SO
INTERESTING?
OBSERVER PATTERN
The 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.
ITERATOR PATTERN
In object-oriented programming, the iterator pattern is a design
pattern in which an iterator is used to traverse a container and
access the container's elements. The iterator pattern decouples
algorithms from containers
RxJS
“BACK-PRESSURE? WHAT?!
Main obstacle when you approach for the first time
Reactive Programming is the vocabulary.
My first suggestion is to familiarise with the domain, a lot
of concepts become way easier if you understand what
they mean before you start to work with them.
streams, hot observables, cold observables, marbles
diagram, back-pressure, operators...
STREAMS
A 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
COLD OBSERVABLES
Cold observables start running upon
subscription: the observable sequence only starts
pushing values to the observers when subscribe
is called.
Values are also not shared among subscribers.
HOT OBSERVABLES
When an observer subscribes to a hot observable
sequence, it will get all values in the stream
that are emitted after it subscribes.
The hot observable sequence is shared among
all subscribers, and each subscriber is pushed
the next value in the sequence.
OPERATORS
▸ Creating Observables
▸ Transforming Observables
▸ Filtering Observables
▸ Combining Observables
▸ Error Handling Operators
▸ Mathematical Operators
▸ Conditional Operators
▸ Connectable Observables
Operators
reactivex.io/documentation/operators.html
MARBLES DIAGRAM
rxmarbles.com
2.
MODEL VIEW
INTENT
Architectures Timeline
90s
MVP
80s
MVC
2005
MVVM
2013
FLUX
2009
DCI
2015
MVI
VIEW INTENT
MODEL
RENDERER
futurice.com/blog/reactive-mvc-and-the-virtual-dom
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
VIEW
Input: 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
INTENT
Input: raw user input events from the View.
Output: model-friendly user intention events.
INTENT
MODEL
Input: user interaction events from the Intent.
Output: data events.
MODEL
MVI PROs
▸ Better separation of concern
▸ Monodirectional flow
▸ Dependency Injection
▸ Applications become easier
to test (in particular views)
▸ All the states live inside the
Model and the View is state-
agnostic
3.
Cycle.js
Cycle.js
Cycle’s core abstraction is your
application as a pure function main()
where inputs are read effects (sources)
from the external world and outputs
(sinks) are write effects to affect the
external world.
These side effects in the external world
are managed by drivers: plugins that
handle DOM effects, HTTP effects, etc.
CORE CONCEPTS
▸ Objects
▸ Functions
▸ Drivers
▸ Helpers
DRIVERS
Drivers are functions that listen to
Observable sinks (their input), perform
imperative side effects, and may return
Observable sources (their output).
http://cycle.js.org/drivers.html
Cycle.js DOMDriver
Cycle.js in action
thenewstack.io/developers-need-know-mvi-model-view-intent
Why not using
Reactive Programming
in any project then?
THANKS EVERYONE
Q&A
@lucamezzalira
www.lucamezzalira.com
www.londonjs.uk
mezzalab@gmail.com
1 of 33

Recommended

Next generation of frontend architectures by
Next generation of frontend architecturesNext generation of frontend architectures
Next generation of frontend architecturesluca mezzalira
9.1K views44 slides
Evolution of front end architectures by
Evolution of front end architecturesEvolution of front end architectures
Evolution of front end architecturesluca mezzalira
1.1K views20 slides
Mvi an architecture for reactive programming by
Mvi an architecture for reactive programmingMvi an architecture for reactive programming
Mvi an architecture for reactive programmingluca mezzalira
663 views25 slides
Cycle.js a reactive framework by
Cycle.js  a reactive frameworkCycle.js  a reactive framework
Cycle.js a reactive frameworkluca mezzalira
256 views18 slides
Dependency Inversion in large-scale TypeScript applications with InversifyJS by
Dependency Inversion in large-scale TypeScript applications with InversifyJSDependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJSRemo Jansen
4.3K views34 slides
Cyclejs introduction by
Cyclejs introductionCyclejs introduction
Cyclejs introductionArye Lukashevski
1.4K views73 slides

More Related Content

Similar to Reactive programming with cycle.js

From User Action to Framework Reaction by
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reactionjbandi
160 views45 slides
Sdlc by
SdlcSdlc
SdlcBilal Aslam
118 views9 slides
Sdlc by
SdlcSdlc
SdlcBilal Aslam
160 views9 slides
From User Action to Framework Reaction by
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework ReactionJonas Bandi
41 views45 slides
379008-rc217-functionalprogramming by
379008-rc217-functionalprogramming379008-rc217-functionalprogramming
379008-rc217-functionalprogrammingLuis Atencio
217 views7 slides
Functional programming in TypeScript by
Functional programming in TypeScriptFunctional programming in TypeScript
Functional programming in TypeScriptbinDebug WorkSpace
1.7K views30 slides

Similar to Reactive programming with cycle.js(20)

From User Action to Framework Reaction by jbandi
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
jbandi160 views
From User Action to Framework Reaction by Jonas Bandi
From User Action to Framework ReactionFrom User Action to Framework Reaction
From User Action to Framework Reaction
Jonas Bandi41 views
379008-rc217-functionalprogramming by Luis Atencio
379008-rc217-functionalprogramming379008-rc217-functionalprogramming
379008-rc217-functionalprogramming
Luis Atencio217 views
Advantages Of Throw Away Prototyping by Jennifer Lopez
Advantages Of Throw Away PrototypingAdvantages Of Throw Away Prototyping
Advantages Of Throw Away Prototyping
Jennifer Lopez2 views
PATTERNS06 - The .NET Event Model by Michael Heron
PATTERNS06 - The .NET Event ModelPATTERNS06 - The .NET Event Model
PATTERNS06 - The .NET Event Model
Michael Heron523 views
Lecture 1 uml with java implementation by the_wumberlog
Lecture 1 uml with java implementationLecture 1 uml with java implementation
Lecture 1 uml with java implementation
the_wumberlog6K views
Unit 1 by donny101
Unit  1Unit  1
Unit 1
donny101221 views
Application Of A Macbook Pro And Os X by Kris Cundiff
Application Of A Macbook Pro And Os XApplication Of A Macbook Pro And Os X
Application Of A Macbook Pro And Os X
Kris Cundiff2 views
Pattern oriented architecture for web based architecture by shuchi tripathi
Pattern oriented architecture for web based architecturePattern oriented architecture for web based architecture
Pattern oriented architecture for web based architecture
shuchi tripathi1.1K views
The Bespoke Software Product Factory (2007) by Peter Antman
The Bespoke Software Product Factory (2007)The Bespoke Software Product Factory (2007)
The Bespoke Software Product Factory (2007)
Peter Antman1K views

More from luca mezzalira

Kaizen - the key of continuos improvement by
Kaizen - the key of continuos improvementKaizen - the key of continuos improvement
Kaizen - the key of continuos improvementluca mezzalira
2.7K views29 slides
Having fun with Adobe AIR 2013 by
Having fun with Adobe AIR 2013Having fun with Adobe AIR 2013
Having fun with Adobe AIR 2013luca mezzalira
1.6K views72 slides
Flash Platform su dispositivi mobili by
Flash Platform su dispositivi mobiliFlash Platform su dispositivi mobili
Flash Platform su dispositivi mobililuca mezzalira
610 views31 slides
Flash Platform Ovierview by
Flash Platform OvierviewFlash Platform Ovierview
Flash Platform Ovierviewluca mezzalira
489 views10 slides
Using design pattern for mobile by
Using design pattern for mobileUsing design pattern for mobile
Using design pattern for mobileluca mezzalira
1.7K views17 slides
Sviluppo di contenuti Flash Platform su iOS e Android by
Sviluppo di contenuti Flash Platform su iOS e AndroidSviluppo di contenuti Flash Platform su iOS e Android
Sviluppo di contenuti Flash Platform su iOS e Androidluca mezzalira
384 views31 slides

More from luca mezzalira(10)

Kaizen - the key of continuos improvement by luca mezzalira
Kaizen - the key of continuos improvementKaizen - the key of continuos improvement
Kaizen - the key of continuos improvement
luca mezzalira2.7K views
Having fun with Adobe AIR 2013 by luca mezzalira
Having fun with Adobe AIR 2013Having fun with Adobe AIR 2013
Having fun with Adobe AIR 2013
luca mezzalira1.6K views
Flash Platform su dispositivi mobili by luca mezzalira
Flash Platform su dispositivi mobiliFlash Platform su dispositivi mobili
Flash Platform su dispositivi mobili
luca mezzalira610 views
Using design pattern for mobile by luca mezzalira
Using design pattern for mobileUsing design pattern for mobile
Using design pattern for mobile
luca mezzalira1.7K views
Sviluppo di contenuti Flash Platform su iOS e Android by luca mezzalira
Sviluppo di contenuti Flash Platform su iOS e AndroidSviluppo di contenuti Flash Platform su iOS e Android
Sviluppo di contenuti Flash Platform su iOS e Android
luca mezzalira384 views
Actionscript 3 Design Pattern by luca mezzalira
Actionscript 3 Design PatternActionscript 3 Design Pattern
Actionscript 3 Design Pattern
luca mezzalira7.8K views
Android Development with Flash Platform by luca mezzalira
Android Development with Flash PlatformAndroid Development with Flash Platform
Android Development with Flash Platform
luca mezzalira279 views

Recently uploaded

Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveNetwork Automation Forum
46 views35 slides
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
50 views23 slides
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsShapeBlue
111 views13 slides
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Moses Kemibaro
29 views38 slides
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...ShapeBlue
46 views29 slides
Scaling Knowledge Graph Architectures with AI by
Scaling Knowledge Graph Architectures with AIScaling Knowledge Graph Architectures with AI
Scaling Knowledge Graph Architectures with AIEnterprise Knowledge
53 views15 slides

Recently uploaded(20)

Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue by ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue50 views
Why and How CloudStack at weSystems - Stephan Bienek - weSystems by ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue111 views
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De... by Moses Kemibaro
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Don’t Make A Human Do A Robot’s Job! : 6 Reasons Why AI Will Save Us & Not De...
Moses Kemibaro29 views
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... by ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue46 views
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT by ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue91 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman40 views
HTTP headers that make your website go faster - devs.gent November 2023 by Thijs Feryn
HTTP headers that make your website go faster - devs.gent November 2023HTTP headers that make your website go faster - devs.gent November 2023
HTTP headers that make your website go faster - devs.gent November 2023
Thijs Feryn28 views
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue by ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue85 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson133 views
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software344 views
Business Analyst Series 2023 - Week 4 Session 7 by DianaGray10
Business Analyst Series 2023 -  Week 4 Session 7Business Analyst Series 2023 -  Week 4 Session 7
Business Analyst Series 2023 - Week 4 Session 7
DianaGray1080 views
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... by ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue77 views
State of the Union - Rohit Yadav - Apache CloudStack by ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue145 views
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc77 views

Reactive programming with cycle.js