Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Dealing with streams using RxJs
Search
Hugo Cordier
June 05, 2015
Programming
2.9k
8
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Dealing with streams using RxJs
Hugo Cordier
June 05, 2015
More Decks by Hugo Cordier
See All by Hugo Cordier
Reactive Programming with RxJava
hugocrd
1
360
Reactive Programming with RxJS
hugocrd
4
820
Recherche Géospatiale dans MongoDB
hugocrd
0
120
Other Decks in Programming
See All in Programming
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
1.7k
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.2k
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
140
Spec-driven Development with AI
simas
PRO
0
2.2k
社内AIエージェント「Askワンバン」における コストチューニングの取り組み
t0yohei
0
110
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
3.1k
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
3
1.7k
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
7.1k
最近”作らせてる” ローカルAIアプリの話
akit37
0
520
Kotlinの15年とServer-Side Kotlin
n_takehata
1
170
AI-Powered Domain-Driven Design
ziobrando
0
350
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
1.1k
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
570
So, you think you're a good person
axbom
PRO
2
2.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
470
Paper Plane (Part 1)
katiecoart
PRO
2
12k
The Cult of Friendly URLs
andyhume
79
7k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
540
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
500
ラッコキーワード サービス紹介資料
rakko
5
5.6M
30 Presentation Tips
portentint
PRO
1
450
How to Talk to Developers About Accessibility
jct
2
600
HDC tutorial
michielstock
2
990
Mind Mapping
helmedeiros
1
420
Transcript
Dealing with Streams using RxJS
Hello! I am Hugo Cordier Developer and CTO at Melusyn
Melusyn helps film makers to manage and organize their productions. You can find me at : @HugoCrd We are hiring! Drop me a line at
[email protected]
♥
1. What’s an event? Javascript is about events
What’s an event? DOM events clicks, moves, focuses, drags events
What’s an event? Async response Ajax, Websocket events
What’s an event? Timeout, interval Time related events
What’s an event? Solution Callbacks & Promises
2. What’s a stream? Give me use-cases!
What’s a stream? A stream is a group of events
What’s a stream? Double clicks How fast can you click?
What’s a stream? Keyboard Konami code is a must have
feature
What’s a stream? Synchronizing async responses Requesting several services
What’s a stream? Solution Reactive Extensions
3. What to do with it?
What to do with it? Transforming events in the Stream
What to do with it? Merging, mixing Several streams
What to do with it? Dealing with time Delaying events,
creating interval, ...
4. The Rx Model Observables and Operators
The Rx Model A stream is an Observable An Observable
push down events through Operators
The Rx Model Operators transform a stream They can be
used to transform, filter and mix events from an Observable
The Rx Model
The Rx Model
The Rx Model myObservable .map(value => value+1) .filter(value => value
> 2) Finally some code!
The Rx Model
The Rx Model myObservable .merge(anotherObservable) .map(value => value+1) .filter(value =>
value > 2)
The Rx Model
The Rx Model myObservable .flatMap(anotherObservable) .map(value => value+1)//Values from anotherObservable
.filter(value => value > 2)
There’s a whole bunch of Operators The Rx Model http://reactivex.io/documentation/operators.html
5. The Rx Model Subscribing and dealing with errors
An Observable needs to be subscribed The Rx Model The
stream will flow once it has been subscribed
The Rx Model myObservable .subscribe( value => console.log(“Event”+value), e =>
console.error(e) )
6. The Rx Model Creating Observables
How to create an Observable? The Rx Model
The Rx Model Rx.Observable .just(1) .from([1,5,0,12,4]) .fromEvent(domElement, event) .fromNodeCallback(nodeFct) .fromPromise(promise)
.interval(2000)
The Rx Model Rx.Observable.create(s => { for (value in values)
{ s.onNext(value) } s.onCompleted() })
7. In real life
In real life Live search Using Google Geocoder and RxJS
http://codepen.io/HugoCrd/pen/vOxQvM
In real life Composing streams Aggregate data from several requests
http://codepen.io/HugoCrd/pen/azGxdW
In real life Realtime statistics Ping a server each x
seconds and diplay results http://codepen.io/HugoCrd/pen/dPeaLY
8. In real life RxJS is just a library. Use
it with whatever you want
In real life with... Node.js Node uses Callbacks. They can
easily be used as a stream var rename = Rx.Observable.fromNodeCallback(fs.rename); rename('file1.txt', 'file2.txt') .map(...) .subscribe(...)
In real life with... Angular.js Angular $watch is a stream
of model changes Angular also has an eventbus system : events on a handler are a stream Rx.Observable.$watch(scope, 'name') .map(...) .subscribe(...)
In real life with... Backbone.js Binding to an object is
listening to it’s changes. This could be used as a stream. Rx.Observable.fromEvent(object, ‘click’) .map(...) .subscribe(...)
In real life with... JS Wokers A worker could post
messages to into stream Rx.DOM.fromWebWorker('worker.js') .map(...) .subscribe(...)
Thanks! Any questions? We are hiring! Drop me a line
at
[email protected]
or @HugoCrd ♥
This template is from SlidesCarnival