SlideShare a Scribd company logo
Reactive Programming in the Browser
Feat. Scala.js and Rx
Overview
● How can we develop purely functional frontend
applications?
● What does Reactive Programming mean?
● What are the pros and cons to the reactive approach?
● Live Coding session!
How do we develop user interfaces
with pure functional programming?
This is pure!
val program = for {
button <- createElement("button")
span <- createElement("span")
_ <- button.addEventListener("click", clickListener)
} yield ()
def clickListener(e: Event) = for {
span <- querySelector("span")
content <- span.textContent
_ <- span.setTextContent(content + "Text")
} yield ()
Let’s try again...
def app(update: State => State, view: State => Html) = for {
oldState <- getCurrentState()
updated <- saveState(update(oldState))
_ <- view(updated).render()
} yield ()
def update(oldState: State) = oldState + "Text"
def view(state: State) = div(
button(click := app(update, view)),
span(state)
)
val program = app(update, view)
We can go even further
sealed trait Action
case class AppendText(text: String) extends Action
def reducer(action: Action, old: State) = action match {
case AppendText(text) => old + text
}
def app(action: Action) = for {
oldState <- getCurrentState()
updated <- saveState(reducer(action, oldState))
_ <- view(updated).render()
} yield ()
● State Monad?
● Mutable References?
● Free Monads?
● Streams?
But how do we query
or update the current
state?
Reactive Programming
How is that useful?
How is that useful?
OutWatch
A small library for easing frontend development
with reactive streams:
● Updating DOM efficiently without sacrificing
abstraction => Virtual DOM
● Handling subscriptions automatically
● Polyglot (Scala & PureScript)
Let’s check out some code!
Conclusions
● Reactive Programming is Functional Programming + Time
● We can use this to model different Architectures (e.g. Elm
Architecture)
● Applications can be modeled by using only pure functions
● Functional Programming patterns still apply
● We can work at an extra level of abstraction but maintain
flexibility
Thank you for listening!
You can find out more at http://outwatch.github.io. Or check out my twitter
@LukaJacobowitz and my Blog http://lukajcb.github.io/blog

More Related Content

PDF
Accessible Ajax on Rails
PPTX
Getting functional with elixir
PDF
Angular js 2.0, ng poznań 20.11
PDF
The Flexible Layout Kit (how we got rid of web views). UA Mobile 2016.
PDF
Neoito — React 101
PDF
AngularJs in Las Palmas de GC
PPTX
React native tour
KEY
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
Accessible Ajax on Rails
Getting functional with elixir
Angular js 2.0, ng poznań 20.11
The Flexible Layout Kit (how we got rid of web views). UA Mobile 2016.
Neoito — React 101
AngularJs in Las Palmas de GC
React native tour
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...

Similar to Reactive Programming in the Browser feat. Scala.js and Rx (20)

PDF
Reactive programming and RxJS
PPTX
Functional reactive programming
PDF
Moving towards Reactive Programming
PPTX
Reactive programming
PPTX
Functional Reactive Endpoints using Spring 5
PDF
I have a stream - Insights in Reactive Programming - Jan Carsten Lohmuller - ...
PDF
Reactive systems
PPTX
What’s expected in Spring 5
PDF
Reactive programming with cycle.js
PPTX
Functional Reactive Programming with RxJS
PDF
Reactive meetup 0 copy
PPTX
Reactive programming intro
PPTX
Solve it Differently with Reactive Programming
PDF
Functional Reactive Programming in Clojurescript
PDF
From User Action to Framework Reaction
PDF
Reactive Applications in Java
PPTX
Reactive programming every day
PDF
Reactive Programming
PDF
An introduction to Reactive applications, Reactive Streams, and options for t...
PDF
[DevDay 2019] Reactive Programming with JavaScript - By Pham Nguyen Duc, Web ...
Reactive programming and RxJS
Functional reactive programming
Moving towards Reactive Programming
Reactive programming
Functional Reactive Endpoints using Spring 5
I have a stream - Insights in Reactive Programming - Jan Carsten Lohmuller - ...
Reactive systems
What’s expected in Spring 5
Reactive programming with cycle.js
Functional Reactive Programming with RxJS
Reactive meetup 0 copy
Reactive programming intro
Solve it Differently with Reactive Programming
Functional Reactive Programming in Clojurescript
From User Action to Framework Reaction
Reactive Applications in Java
Reactive programming every day
Reactive Programming
An introduction to Reactive applications, Reactive Streams, and options for t...
[DevDay 2019] Reactive Programming with JavaScript - By Pham Nguyen Duc, Web ...
Ad

More from Luka Jacobowitz (13)

PDF
Monoids, Monoids, Monoids - ScalaLove 2020
PDF
Monoids, monoids, monoids
PDF
Testing in the World of Functional Programming
PDF
Up and Running with the Typelevel Stack
PDF
Principled Error Handling - Scalapeño
PDF
Principled Error Handling with FP
PDF
Oh, All the things you'll traverse
PDF
Advanced Tagless Final - Saying Farewell to Free
PDF
Traversals for all ocasions
PDF
Building a Tagless Final DSL for WebGL
PDF
What Referential Transparency can do for you
PDF
Scala UA 2017
PDF
Reactive Programming in the Browser feat. Scala.js and PureScript
Monoids, Monoids, Monoids - ScalaLove 2020
Monoids, monoids, monoids
Testing in the World of Functional Programming
Up and Running with the Typelevel Stack
Principled Error Handling - Scalapeño
Principled Error Handling with FP
Oh, All the things you'll traverse
Advanced Tagless Final - Saying Farewell to Free
Traversals for all ocasions
Building a Tagless Final DSL for WebGL
What Referential Transparency can do for you
Scala UA 2017
Reactive Programming in the Browser feat. Scala.js and PureScript
Ad

Recently uploaded (20)

PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
top salesforce developer skills in 2025.pdf
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administration Chapter 2
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
ai tools demonstartion for schools and inter college
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Essential Infomation Tech presentation.pptx
PDF
medical staffing services at VALiNTRY
PDF
PTS Company Brochure 2025 (1).pdf.......
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
How to Choose the Right IT Partner for Your Business in Malaysia
top salesforce developer skills in 2025.pdf
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administration Chapter 2
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
ai tools demonstartion for schools and inter college
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
How to Migrate SBCGlobal Email to Yahoo Easily
How Creative Agencies Leverage Project Management Software.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Operating system designcfffgfgggggggvggggggggg
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Essential Infomation Tech presentation.pptx
medical staffing services at VALiNTRY
PTS Company Brochure 2025 (1).pdf.......

Reactive Programming in the Browser feat. Scala.js and Rx

  • 1. Reactive Programming in the Browser Feat. Scala.js and Rx
  • 2. Overview ● How can we develop purely functional frontend applications? ● What does Reactive Programming mean? ● What are the pros and cons to the reactive approach? ● Live Coding session!
  • 3. How do we develop user interfaces with pure functional programming?
  • 4. This is pure! val program = for { button <- createElement("button") span <- createElement("span") _ <- button.addEventListener("click", clickListener) } yield () def clickListener(e: Event) = for { span <- querySelector("span") content <- span.textContent _ <- span.setTextContent(content + "Text") } yield ()
  • 5. Let’s try again... def app(update: State => State, view: State => Html) = for { oldState <- getCurrentState() updated <- saveState(update(oldState)) _ <- view(updated).render() } yield () def update(oldState: State) = oldState + "Text" def view(state: State) = div( button(click := app(update, view)), span(state) ) val program = app(update, view)
  • 6. We can go even further sealed trait Action case class AppendText(text: String) extends Action def reducer(action: Action, old: State) = action match { case AppendText(text) => old + text } def app(action: Action) = for { oldState <- getCurrentState() updated <- saveState(reducer(action, oldState)) _ <- view(updated).render() } yield ()
  • 7. ● State Monad? ● Mutable References? ● Free Monads? ● Streams? But how do we query or update the current state?
  • 9. How is that useful?
  • 10. How is that useful?
  • 11. OutWatch A small library for easing frontend development with reactive streams: ● Updating DOM efficiently without sacrificing abstraction => Virtual DOM ● Handling subscriptions automatically ● Polyglot (Scala & PureScript)
  • 12. Let’s check out some code!
  • 13. Conclusions ● Reactive Programming is Functional Programming + Time ● We can use this to model different Architectures (e.g. Elm Architecture) ● Applications can be modeled by using only pure functions ● Functional Programming patterns still apply ● We can work at an extra level of abstraction but maintain flexibility
  • 14. Thank you for listening! You can find out more at http://outwatch.github.io. Or check out my twitter @LukaJacobowitz and my Blog http://lukajcb.github.io/blog