SlideShare a Scribd company logo
Strange Async Code or:
How I Learned to Stop
Worrying and Love
ReactiveX
MATT WILL - @MATTWILL09 -HTTP://DPLBLOG.COM/MATT
DON’T PANIC LABS
SOFTWARE ENGINEER / CODE WRANGLER
Strange Async Code - ReaxtiveX
What is ReactiveX
The Observer pattern done right
What is the observer pattern?
https://en.wikipedia.org/wiki/Observer_pattern
"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"
https://msdn.microsoft.com/en-us/library/ee817669.aspx
I had never heard of this paper which was published around the time I started writing code
professionally, but it essentially boils it down to the event and delegate model used in .Net
This means that we have all been using an observer pattern for a long time, just that no one really
called it that.
What makes ReactiveX so great?
ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern,
and functional programming
It makes it very easy to set up new event sources.
You can easily chain operations to transform and filter the result sets
Tapping into an observable to listen for events is easy to do.
Sounds great, but can I use it?
Java: RxJava
JavaScript: RxJS
C#: Rx.NET
C#(Unity): UniRx
Scala: RxScala
Clojure: RxClojure
C++: RxCpp
Lua: RxLua
Ruby: Rx.rb
Python: RxPY
Go: RxGo
Groovy: RxGroovy
JRuby: RxJRuby
Kotlin: RxKotlin
Swift: RxSwift
PHP: RxPHP
Elixir: reaxive
Dart: RxDart
It makes life simpler
It is simpler because the code consuming the observable doesn't care how the observable is
implemented. The consumer only knows that it interacts with the observable in an async
manner.
We don't have to code a bunch of callback functions that get nested deeply within each other.
Each language has it's own implementation of ReactiveX that conforms to the language but the
concepts are the same across all languages.
Terminology
Observable - a source for data that is
subscribed to
Observer - one who subscribes to be notified
when changes occur on an observer
Subscriber - A specialized type of observer that
has an unsubscribe method so it can tell the
observable it doesn't care about events any
more
Single - an observable that will only emit one
item
onNext - Method that the observable calls to
notify an observer that the next item is
available
onCompleted - Method that the observable
calls to indicate that there will be no more
items available on the stream
onError - Method that the observable calls to
indicate that an error has occurred while
processing the stream.
Hot observable - an observable that is always
producing a stream of items, even if no
observers exist. Observers will connect mid-
stream and get values from that point
Cold observable - an observable that will not
begin producing items on a stream until an
observer connects.
Creating
Create
Empty
From
Interval
Just
Range
Start
Timer
ToObservable
Transforming
Buffer
FlatMap
GroupBy
Map
Scan
Window
Filtering
Debounce
Distinct/DistinctUntilChanged
ElementAt
Filter
First
IgnoreElements
Last
Sample
Skip
SkipLast
Take
TakeLast
Utilities
SubscribeOn - tells the observable which scheduler it should run on
ObserveOn - tells the observer which scheduler is should run on
Timeout
Conditionals
All
Contains
SkipUntil/SkipWhile
TakeUntil/TakeWhile
Connectables
Connect
Publish
Replay
Demos
What are some other ways people are
using ReactiveX
Making mobile apps more
Pulling data from a live database (e.g. Firebase) and feeding that data to screens
The Angular team is working on the ability to hook up ReativeX into the validation pipeline so you
can do async validation
Resources
Learn more:
◦ http://reactivex.io
◦ http://rxmarbles.com
◦ http://introtorx.com
Code
◦ https://github.com/mattwill09/NebraskaCode17
Slides
◦ https://www.slideshare.net/MatthewWill5/strange-async-code-reaxtivex
Or
◦ https://goo.gl/p03ak9

More Related Content

PDF
Introduction to AS3Signals
PDF
Sperasoft Talks: RxJava Functional Reactive Programming on Android
PDF
Scaling Prometheus to measure millions of things
PDF
An Infectious Disease Surveillance Simulation (IDSS) in the Cloud
PPTX
QTP Presentation
PDF
Count downlatch & implementation
PDF
The pets, the cattle and the germs - Avishai Ish-Shalom - DevOpsDays Tel Aviv...
PDF
Reactive java - Reactive Programming + RxJava
Introduction to AS3Signals
Sperasoft Talks: RxJava Functional Reactive Programming on Android
Scaling Prometheus to measure millions of things
An Infectious Disease Surveillance Simulation (IDSS) in the Cloud
QTP Presentation
Count downlatch & implementation
The pets, the cattle and the germs - Avishai Ish-Shalom - DevOpsDays Tel Aviv...
Reactive java - Reactive Programming + RxJava

Similar to Strange Async Code - ReaxtiveX (20)

PDF
Streams, Streams Everywhere! An Introduction to Rx
PDF
Reactive x
PDF
My Gentle Introduction to RxJS
PDF
RxJava - introduction & design
PPTX
Rx presentation
PPTX
Microservices Part 4: Functional Reactive Programming
PPTX
Reactive Programming in Java 8 with Rx-Java
PPTX
Rx- Reactive Extensions for .NET
PPTX
Reactive Programming and RxJS
PDF
Intro to Rx Java
PPTX
PPTX
Mini training - Reactive Extensions (Rx)
PPTX
Rx – reactive extensions
PPTX
Introduction to RxJS
PDF
rx-java-presentation
PDF
Introduction to reactive programming
PDF
A Quick Intro to ReactiveX
PPTX
Intro to Functional Programming with RxJava
PPTX
PPTX
Introduction to RxJava on Android
Streams, Streams Everywhere! An Introduction to Rx
Reactive x
My Gentle Introduction to RxJS
RxJava - introduction & design
Rx presentation
Microservices Part 4: Functional Reactive Programming
Reactive Programming in Java 8 with Rx-Java
Rx- Reactive Extensions for .NET
Reactive Programming and RxJS
Intro to Rx Java
Mini training - Reactive Extensions (Rx)
Rx – reactive extensions
Introduction to RxJS
rx-java-presentation
Introduction to reactive programming
A Quick Intro to ReactiveX
Intro to Functional Programming with RxJava
Introduction to RxJava on Android
Ad

Recently uploaded (20)

PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
composite construction of structures.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
UNIT 4 Total Quality Management .pptx
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
Construction Project Organization Group 2.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPT
Project quality management in manufacturing
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PPT on Performance Review to get promotions
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPT
Mechanical Engineering MATERIALS Selection
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Internet of Things (IOT) - A guide to understanding
composite construction of structures.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
UNIT 4 Total Quality Management .pptx
OOP with Java - Java Introduction (Basics)
Construction Project Organization Group 2.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Project quality management in manufacturing
Operating System & Kernel Study Guide-1 - converted.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
CH1 Production IntroductoryConcepts.pptx
bas. eng. economics group 4 presentation 1.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT on Performance Review to get promotions
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Mechanical Engineering MATERIALS Selection
Ad

Strange Async Code - ReaxtiveX

  • 1. Strange Async Code or: How I Learned to Stop Worrying and Love ReactiveX MATT WILL - @MATTWILL09 -HTTP://DPLBLOG.COM/MATT DON’T PANIC LABS SOFTWARE ENGINEER / CODE WRANGLER
  • 3. What is ReactiveX The Observer pattern done right What is the observer pattern? https://en.wikipedia.org/wiki/Observer_pattern "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" https://msdn.microsoft.com/en-us/library/ee817669.aspx I had never heard of this paper which was published around the time I started writing code professionally, but it essentially boils it down to the event and delegate model used in .Net This means that we have all been using an observer pattern for a long time, just that no one really called it that.
  • 4. What makes ReactiveX so great? ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming It makes it very easy to set up new event sources. You can easily chain operations to transform and filter the result sets Tapping into an observable to listen for events is easy to do.
  • 5. Sounds great, but can I use it? Java: RxJava JavaScript: RxJS C#: Rx.NET C#(Unity): UniRx Scala: RxScala Clojure: RxClojure C++: RxCpp Lua: RxLua Ruby: Rx.rb Python: RxPY Go: RxGo Groovy: RxGroovy JRuby: RxJRuby Kotlin: RxKotlin Swift: RxSwift PHP: RxPHP Elixir: reaxive Dart: RxDart
  • 6. It makes life simpler It is simpler because the code consuming the observable doesn't care how the observable is implemented. The consumer only knows that it interacts with the observable in an async manner. We don't have to code a bunch of callback functions that get nested deeply within each other. Each language has it's own implementation of ReactiveX that conforms to the language but the concepts are the same across all languages.
  • 7. Terminology Observable - a source for data that is subscribed to Observer - one who subscribes to be notified when changes occur on an observer Subscriber - A specialized type of observer that has an unsubscribe method so it can tell the observable it doesn't care about events any more Single - an observable that will only emit one item onNext - Method that the observable calls to notify an observer that the next item is available onCompleted - Method that the observable calls to indicate that there will be no more items available on the stream onError - Method that the observable calls to indicate that an error has occurred while processing the stream. Hot observable - an observable that is always producing a stream of items, even if no observers exist. Observers will connect mid- stream and get values from that point Cold observable - an observable that will not begin producing items on a stream until an observer connects.
  • 11. Utilities SubscribeOn - tells the observable which scheduler it should run on ObserveOn - tells the observer which scheduler is should run on Timeout
  • 14. Demos
  • 15. What are some other ways people are using ReactiveX Making mobile apps more Pulling data from a live database (e.g. Firebase) and feeding that data to screens The Angular team is working on the ability to hook up ReativeX into the validation pipeline so you can do async validation
  • 16. Resources Learn more: ◦ http://reactivex.io ◦ http://rxmarbles.com ◦ http://introtorx.com Code ◦ https://github.com/mattwill09/NebraskaCode17 Slides ◦ https://www.slideshare.net/MatthewWill5/strange-async-code-reaxtivex Or ◦ https://goo.gl/p03ak9