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
Rxjs
Search
Danila Marchenkov
September 13, 2017
Education
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rxjs
Danila Marchenkov
September 13, 2017
More Decks by Danila Marchenkov
See All by Danila Marchenkov
angular6
sprit3dan
0
80
angular5
sprit3dan
0
62
angular#4
sprit3dan
0
170
angular#3
sprit3dan
0
54
angular#2
sprit3dan
0
44
Angular#1
sprit3dan
0
73
HTML 5 Canvas
sprit3dan
0
55
Angular #6
sprit3dan
0
79
Angular #5
sprit3dan
0
130
Other Decks in Education
See All in Education
25-26 CBT Library top items
cbtlibrary
0
310
【デザイナー就活講座】 デザイナー就活市場・企業探し・ポートフォリオのポイント
koheihasebe
0
670
Center for Entrepreneurship Education | Science Tokyo (Institute of Science Tokyo)
sciencetokyo
PRO
0
510
「答えを出す」より「わかる」をつくる
kzkmaeda
1
310
チームの鏡になるー自分の癖を知ると、チームのパターンが見えてくる@スクフェス仙台
saorimurooka
0
220
Sekolah Sabat - Triwulan 4 2026 - Pelajaran 1
hiola
0
6.2k
Plano urbano de Madrid desde el Ensanche al s. XXI (2ª parte).
juanmartin2026
1
99k
Comentario del plano urbano de Madrid hasta 1860 (1ª parte )
juanmartin2026
1
99k
Tema 1. El relieve de España: Formación y características
juanmartin2026
0
34k
NDIAS Automotive / IoT CTF 2026 Recap - Keyfob & OSINT
himitu23
0
350
新しいJavaを学んで・使っていこう! / osd26do
gishi_yama
0
260
響け!ユーフォニアムと考える「決め方」/Thinking About Decision-Making with Sound! Euphonium
3l4l5
1
190
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
340
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
270
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
570
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
2
2.9k
Believing is Seeing
oripsolob
1
230
Navigating Team Friction
lara
192
16k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
490
Transcript
ReactiveX Marchenkov Danila, Software Developer
None
RxJS RxJava Rx.NET RxScala RxSwift RxClosure RxCpp RxGo RxGroovy RxJRuby
RxPHP RxPY Rx.rb RxDart RxLua
FRP Asynchronous - Observables Synchronous - Iterators
Observable
DOM-events Async operations Any data flow within app
Api?
• audit • auditTime • filter • last • buffer
• bufferWhen • catch • combine • combineAll • combineLatest • concat • count • debounce • delay • distinct • do • every • exhaust • expand • findIndex • find • forEach • groupBy • isEmpty • lift • map • mapTo • max • merge • mergeAll • min • multicast
const obs = Observable.from([1, 2, 3, 4]); obs.subscribe(it => console.log(‘obs’
+ it)); >obs1 >obs2 >obs3 >obs4
const obs = Observable.from([1, 2, 3, 4]); obs .map(val =>
`obs${val}`) .subscribe(it => console.log(it)); >obs1 >obs2 >obs3 >obs4
let emitter; const obs: Observable<number> = new Observable(e => emitter
= e); [1, 2, 3, 4].forEach(it => emitter.next(it)); obs.subscribe(it => console.log(it));
let emitter; const obs: Observable<number> = new Observable(e => emitter
= e); [1, 2, 3, 4].forEach(it => emitter.next(it)); obs.subscribe(it => console.log(it)); >ERROR TypeError: Cannot read property 'next' of undefined
let emitter; const obs: Observable<number> = new Observable(e => emitter
= e); obs.subscribe(it => console.log(it)); [1, 2, 3, 4].forEach(it => emitter.next(it)); >1 >2 >3 >4
import { Observable } from ‘rxjs/Rx'; export class Service {
private stream: Observable<T> = new Observable(obs => this.emitter = obs) private emitter; public get onSteamEvent() { return this.steam; } private someMethod() { . . . this.emitter.next({someData}); } }
import { Observable } from ‘rxjs/Rx'; export class Service {
private stream: Observable<T> = new Observable(obs => this.emitter = obs).share(); private emitter; public get onSteamEvent() { return this.steam; } private someMethod() { . . . this.emitter.next({someData}); } }
HOT vs COLD Observables
var cold = new Observable((observer) => { var producer =
new Producer(); // have observer listen to producer here }); COLD
HOT var producer = new Producer(); var hot = new
Observable((observer) => { // have observer listen to producer here });
Multicasting
const obs: Observable<number> = new Observable(e => emitter = e);
obs.subscribe(it => console.log(it)); obs.map(it => it + 1).subscribe(it => console.log(it)); [1, 2, 3, 4].forEach(it => emitter.next(it));
const obs: Observable<number> = new Observable(e => emitter = e);
obs.subscribe(it => console.log(it)); obs.map(it => it + 1).subscribe(it => console.log(it)); [1, 2, 3, 4].forEach(it => emitter.next(it)); >2 >3 >4 >5
const obs = new Observable<number>(e => emitter = e).share(); obs.subscribe(it
=> console.log(it)); obs.map(it => it + 1).subscribe(it => console.log(it)); [1, 2, 3, 4].forEach(it => emitter.next(it)); >1 >2 >2 >3 >3 >4 >5
Profit over Promise?
Observable > Promise • Observable is reusable • Observable is
cancellable • A lot of powerful operators • Hot & Cold observables • Merging a lot of observables • Multiple pipeline instead of only .then, .catch • Obs can become Promise :3
Subject
or BehaviourSubject AsyncSubject AnonymousSubject ReplaySubject
Every Subject is an Observable. Every Subject is an Observer.
let subj = new Subject(); subj.next(1); subj.subscribe(it => console.log(it)); subj.next(2);
>2
let lastNOperations = Infinity; let subj = new ReplaySubject(lastNOpearions); subj.next(1);
subj.subscribe(it => console.log(it)); subj.next(2); >1 >2
let subj = new BehaviorSubject(1); subj.subscribe(it => console.log(it)); subj.next(2); >1
>2
Careful
Subject will NOT be disposed after all subscribers disconnected Use
Subjects only in place, where two-way data flow is certainly needed!
Useful operations except map, reduce, filter, find
Distinct
Reduce
Repeat
Partition
Concat
Merge