Reactive Programming
Florent Pillet
DMCA Meetup - Sophia Antipolis, Feb 21st 2018
Reactive
programming
Programming with streams
of asynchronous data
“It's just a callback”
Krunoslav Zaher, author of RxSwift
5 stages to the Zen of Rx
! Learning curve
" Mind bending
# Frustration
$ Enlightenment
% Code clarity & predictability
Asynchronous data
• Network request
• Current location
• Loading data from a database
• Getting images from a cache
• etc…
Asynchronous data
• User interaction
• Notification
• Network up / down
• State changes
• etc…
Observable sequences
Some work you start
Observable sequences
Infinite sequence you subscribe to (i.e. notifications)
Observable sequences
Some work that fails
Observable sequences
Sources most often start work when you subscribe
Observable sequences
Sources most often start work when you subscribe
Observable sequences
Sources most often start work when you subscribe
Observable sequences
Sources most often start work when you subscribe
Cancellation
Disposables let you cancel a subscription at any time
Cancellation
Disposables let you cancel a subscription at any time
Cancellation
Disposables let you cancel a subscription at any time
Operators
Transform
Operators
Transform
Operators
Compose
Easy timers
Easy timers
Easy timers
Decoupling producer and consumer
Decoupling producer and consumer
Decoupling producer and consumer
Decoupling producer and consumer
Decoupling producer and consumer
Expressive pipelines
Expressive pipelines
Expressive pipelines
Expressive pipelines
Expressive pipelines
Expressive pipelines
Expressive pipelines
Mock sources of data for tests
Replace state with observables
Inspired by Shai Mishali - @freak4pc
Replace state with observables
Inspired by Shai Mishali - @freak4pc
Replace state with observables
Inspired by Shai Mishali - @freak4pc
Replace state with observables
Inspired by Shai Mishali - @freak4pc
Replace state with observables
Inspired by Shai Mishali - @freak4pc
Replace state with observables
Inspired by Shai Mishali - @freak4pc
Manage threading
Manage threading
Manage threading
Manage threading
Rx powah !
Rx Take away
• Powerful abstraction
• Steep learning curve
• Starting with Futures & Promises can help
• Use sparingly at first
• Teams should progress in lockstep
Rx Take away
Many frameworks, same concepts, similar operators:
• RxSwift, ReactiveSwift
• RxJava, RxKotlin
• RxJS
• ... and many more at reactivex.io
Thank you
Reactive Programming
with RxSwift
https://raywenderlich.com
Florent Pillet
@fpillet

DMCA#21: reactive-programming