SlideShare a Scribd company logo
LET IT FLOW 
Introduction to Functional Reactive Programming 
@ArturSkowronski
About Me 
@ArturSkowronski
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
Functional 
REACTIVE PROGRAMMING
DATAFLOW
PROPAGATION 
OF CHANGE
a = 1 
b = 2 
c = a + b
b = 3 
c = ?
C 
A 
B
Properties 
or 
Signals 
or 
Behaviours
Let it Flow - Introduction to Functional Reactive Programming
Event Streams
Single Event
Events Stream
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
Dirty Checking! 
Change Listeners!
Creator: Juha Paananen
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
Observable 
EventStreams 
Properties
Talk is cheap. Show me the code 
Linus Torvald
Examples
Example 1: ScoreBoard
var score = 0 
$('#plus').click(function(){ 
score = score + 1; 
$('#result').html(score); 
}) 
$('#minus').click(function(){ 
score = score - 1; 
$('#result').html(score); 
})
var plus = $('#plus') 
.asEventStream('click'); 
! 
var minus = $('#minus') 
.asEventStream('click');
Let it Flow - Introduction to Functional Reactive Programming
var score = plus.map(1) 
.merge(minus.map(-1)) 
.scan(0, function(x, y){ 
return x + y })
Map
var score = plus.map(1) 
.merge(minus.map(-1)) 
.scan(0, function(x, y){ 
return x + y })
var 
.merge(minus.map(-1)) 
.
a 
b 
a.merge(b) 
1 3 
2 
1 2 3 
Merge
Let it Flow - Introduction to Functional Reactive Programming
var 
. 
.scan(0, function(x, y){ 
return x + y })
Event Stream 
Property
a 
a.scan('',sum) 
"a" 
"c" "t" 
"" "c" "ca" 
"cat" 
Seed Value 
"" + "c" 
"c" + "a" 
"ca" + "t" 
Scan
score.onValue(function(value){ 
$("#score").html(value); 
}); 
Side Effect
Let it Flow - Introduction to Functional Reactive Programming
var favorite = $('#favorite') 
.asEventStream('click') 
.map(2);
var score = up 
.merge(down) 
.merge(favorite) 
.scan(0, sum)
Let it Flow - Introduction to Functional Reactive Programming
Example 1I: Combining DataStreams
function inputVal(ev) { 
return $(ev.currentTarget).val() } 
var username = 
$('#username').asEventStream('keyup') 
.map(inputVal) 
Username:
var password = 
$('#password').asEventStream('keyup') 
.map(inputVal) 
Username: 
Password:
Let it Flow - Introduction to Functional Reactive Programming
Custom Function 
uValid = username.map(isValid) 
! 
! 
pValid = password.map(isValid)
validForm 
= 
uValid.combine(pValid, function(a, b){ 
return a && b 
})
a 
b 
a.combine 
(b, plus) 
1 3 
2 
3 5 
Combine
Submit 
validForm.onValue(function(value) { 
$("#submit").attr("disabled", !enabled) 
})
Let it Flow - Introduction to Functional Reactive Programming
Example III: Promises
Bacon.fromPromise 
var ajaxCall = Bacon.fromPromise( 
$.ajax({ url : "meetjs/users.json"}) 
) 
var ajaxCall(query){ 
return Bacon.fromPromise( 
$.ajax({ url : "meetjs/?q=" + query})) 
}
Search: 
var search = 
$('#search').asEventStream('keyup') 
.map(inputVal) 
search.map(ajaxCall).onValue(function(value){ 
value.onValue(function(value){ 
doSomethingWithResult(value); 
}); 
});
Let it Flow - Introduction to Functional Reactive Programming
Search: 
search.map(ajaxCall).onValue(function(value){ 
value.onValue(function(value){ 
doSomethingWithResult(value); 
}); 
});
Let it Flow - Introduction to Functional Reactive Programming
flatMap
a 
~1 ~2 
f(1) 
f(2) 
"a" 
a.flatMap(f) "a" "b" 
FlatMap 
"b"
a 
~1 ~2 
f(1) 
f(2) 
a.flatMapLatest 
"a" 
(f) "a" 
"b" 
FlatMapLatest
search.flatMapLatest(ajaxCall) 
.onValue(function(value){ 
doSomethingWithResult(value); 
})
WHERE ?
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
Wrap Up
Filters 
Bus 
Combine 
Templates 
This Presentation
Let it Flow - Introduction to Functional Reactive Programming
Let it Flow - Introduction to Functional Reactive Programming
Thank You! 
Questions? 
@ArturSkowronski arturskowronski.com

More Related Content

PDF
Signal Stacktrace
DOCX
A Shiny Example-- R
PPT
Cpp tutorial
DOCX
Pratik Bakane C++
DOCX
Pratik Bakane C++
DOCX
Pratik Bakane C++
DOCX
Pratik Bakane C++
PPTX
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
Signal Stacktrace
A Shiny Example-- R
Cpp tutorial
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
Pratik Bakane C++
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...

What's hot (18)

DOCX
Pratik Bakane C++
PDF
Basic program in java
PDF
The Effective Developer - Work Smarter, Not Harder
PDF
Seeking the truth from mobile analytics
PDF
Introduction to cron queue
ODP
Scala+swing
PDF
Implement a queue using two stacks.
TXT
Empolyee deatils in java
PDF
PPTX
Phpbase
PDF
Phing - PHP Conference 2015
PDF
Bcsl 033 data and file structures lab s3-3
DOCX
C program to implement linked list using array abstract data type
DOC
Final ds record
PDF
Bcsl 033 data and file structures lab s4-2
PDF
Angular Refactoring in Real World
DOC
Program(Output)
PDF
Webmontag Berlin "coffee script"
Pratik Bakane C++
Basic program in java
The Effective Developer - Work Smarter, Not Harder
Seeking the truth from mobile analytics
Introduction to cron queue
Scala+swing
Implement a queue using two stacks.
Empolyee deatils in java
Phpbase
Phing - PHP Conference 2015
Bcsl 033 data and file structures lab s3-3
C program to implement linked list using array abstract data type
Final ds record
Bcsl 033 data and file structures lab s4-2
Angular Refactoring in Real World
Program(Output)
Webmontag Berlin "coffee script"
Ad

Viewers also liked (20)

PDF
Embracing change - how to introduce Clojure into your company technology stac...
PDF
Teasing talk for Flow-based programming made easy with PyF 2.0
PDF
Functional Reactive Programming by Gerold Meisinger
PDF
NoFlo - Flow-Based Programming for Node.js
PPTX
20160609 nike techtalks reactive applications tools of the trade
PDF
Rethink Frontend Development With Elm
PDF
Need for Async: Hot pursuit for scalable applications
PDF
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
PDF
My adventure with Elm
PDF
Flow Base Programming with Node-RED and Functional Reactive Programming with ...
PPT
S105 performance
PPTX
Pantone colours
ODP
2829 liberty
PPTX
Facebook the social network
PPT
IBM Impact Session 2351 hybrid apps
PPTX
S104 twist and cloud
ODP
SHARE 2014, Pittsburgh CICS scalability
PPTX
Learning art of singing
PDF
Scala.js - yet another what..?
PPTX
S107 5 compelling reasons for using cics in the cloud
Embracing change - how to introduce Clojure into your company technology stac...
Teasing talk for Flow-based programming made easy with PyF 2.0
Functional Reactive Programming by Gerold Meisinger
NoFlo - Flow-Based Programming for Node.js
20160609 nike techtalks reactive applications tools of the trade
Rethink Frontend Development With Elm
Need for Async: Hot pursuit for scalable applications
PSUG #52 Dataflow and simplified reactive programming with Akka-streams
My adventure with Elm
Flow Base Programming with Node-RED and Functional Reactive Programming with ...
S105 performance
Pantone colours
2829 liberty
Facebook the social network
IBM Impact Session 2351 hybrid apps
S104 twist and cloud
SHARE 2014, Pittsburgh CICS scalability
Learning art of singing
Scala.js - yet another what..?
S107 5 compelling reasons for using cics in the cloud
Ad

Similar to Let it Flow - Introduction to Functional Reactive Programming (20)

PPTX
Reactive programming every day
PDF
PDF
Functional Reactive Programming in JavaScript
PPTX
Functional reactive programming
PDF
Rethink Async With RXJS
PDF
Rethink Async with RXJS
PDF
Rethink Async with RXJS
PDF
Add Some Fun to Your Functional Programming With RXJS
PPTX
Functional Reactive Programming with RxJS
PDF
Cascadia.js: Don't Cross the Streams
PDF
Functional Reactive Programming / Compositional Event Systems
PDF
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
PDF
Cycle.js - A functional reactive UI framework
PDF
FRP with Ractive and RxJS
PPTX
Functional Programming in Javascript - IL Tech Talks week
PDF
Functional Programming with JavaScript
PPTX
Luis Atencio on RxJS
PDF
Reactive Programming with JavaScript
PDF
J query fundamentals
PPTX
jQuery Data Manipulate API - A source code dissecting journey
Reactive programming every day
Functional Reactive Programming in JavaScript
Functional reactive programming
Rethink Async With RXJS
Rethink Async with RXJS
Rethink Async with RXJS
Add Some Fun to Your Functional Programming With RXJS
Functional Reactive Programming with RxJS
Cascadia.js: Don't Cross the Streams
Functional Reactive Programming / Compositional Event Systems
Cycle.js - Functional reactive UI framework (Nikos Kalogridis)
Cycle.js - A functional reactive UI framework
FRP with Ractive and RxJS
Functional Programming in Javascript - IL Tech Talks week
Functional Programming with JavaScript
Luis Atencio on RxJS
Reactive Programming with JavaScript
J query fundamentals
jQuery Data Manipulate API - A source code dissecting journey

More from Artur Skowroński (20)

PDF
Build your own NES Emulator... with Kotlin
PDF
Running Java on Arm - Is it worth it in 2025?
PDF
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
PDF
Kopiąc Trufle - Odkrywanie tajemnic najmniej zrozumiałego elementu GraalVM
PDF
The State of the Green IT at the beginning of 2024
PDF
My chcemy grać w Zielone! Czyli stan świata Green Technology końcówką 2023
PDF
GraalVM, CRaC, Leyden and friends
PDF
Od Czarnoksiężnik z krainy Oz do modeli na produkcji
PDF
JVM Iceberg... we need to go deeper
PDF
JVM Iceberg... we need to go deeper
PDF
Panie, kto tu Panu tak ... - czyli porozmawiajmy o Legacy
PDF
Panie, kto tu Panu tak ... - czyli porozmawiajmy o Legacy
PDF
Ciąg dalszy nastąpi - o wielowątkowości, Projekcie Loom i kotlinowych Korutynach
PDF
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
PDF
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’a
PDF
Type Systems on the example of TypeScript
PDF
Google Assistant po polsku - developerski punkt widzenia
PDF
Google Assistant & Alexa - Asystenci głosowi: możliwości, podobieństwa, różnice
PDF
To Be Continued - multithreading with Project Loom and Kotlin's Coroutines
PDF
To be Continued - multithreading with Project Loom and Kotlin's Coroutines
Build your own NES Emulator... with Kotlin
Running Java on Arm - Is it worth it in 2025?
JVM in the Age of AI: Babylon, Valhalla, TornadoVM and friends
Kopiąc Trufle - Odkrywanie tajemnic najmniej zrozumiałego elementu GraalVM
The State of the Green IT at the beginning of 2024
My chcemy grać w Zielone! Czyli stan świata Green Technology końcówką 2023
GraalVM, CRaC, Leyden and friends
Od Czarnoksiężnik z krainy Oz do modeli na produkcji
JVM Iceberg... we need to go deeper
JVM Iceberg... we need to go deeper
Panie, kto tu Panu tak ... - czyli porozmawiajmy o Legacy
Panie, kto tu Panu tak ... - czyli porozmawiajmy o Legacy
Ciąg dalszy nastąpi - o wielowątkowości, Projekcie Loom i kotlinowych Korutynach
Artur Skowroński – Ten Typ tak ma - O systemach typów na przykładzie TypeScri...
Ten Typ tak ma - O systemach typów na przykładzie TypeScript’a
Type Systems on the example of TypeScript
Google Assistant po polsku - developerski punkt widzenia
Google Assistant & Alexa - Asystenci głosowi: możliwości, podobieństwa, różnice
To Be Continued - multithreading with Project Loom and Kotlin's Coroutines
To be Continued - multithreading with Project Loom and Kotlin's Coroutines

Recently uploaded (20)

PPTX
Geodesy 1.pptx...............................................
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
additive manufacturing of ss316l using mig welding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PDF
Structs to JSON How Go Powers REST APIs.pdf
PDF
Well-logging-methods_new................
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
Construction Project Organization Group 2.pptx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
Geodesy 1.pptx...............................................
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Strings in CPP - Strings in C++ are sequences of characters used to store and...
additive manufacturing of ss316l using mig welding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Structs to JSON How Go Powers REST APIs.pdf
Well-logging-methods_new................
Arduino robotics embedded978-1-4302-3184-4.pdf
Construction Project Organization Group 2.pptx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Operating System & Kernel Study Guide-1 - converted.pdf
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
UNIT 4 Total Quality Management .pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
CH1 Production IntroductoryConcepts.pptx

Let it Flow - Introduction to Functional Reactive Programming