Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rxjs
Search
Danila Marchenkov
September 13, 2017
Education
0
100
Rxjs
Danila Marchenkov
September 13, 2017
Tweet
Share
More Decks by Danila Marchenkov
See All by Danila Marchenkov
angular6
sprit3dan
0
73
angular5
sprit3dan
0
52
angular#4
sprit3dan
0
160
angular#3
sprit3dan
0
44
angular#2
sprit3dan
0
34
Angular#1
sprit3dan
0
52
HTML 5 Canvas
sprit3dan
0
44
Angular #6
sprit3dan
0
68
Angular #5
sprit3dan
0
120
Other Decks in Education
See All in Education
ARアプリを活用した防災まち歩きデータ作成ハンズオン
nro2daisuke
0
190
「実践的探究」を志向する日本の教育研究における近年の展開 /jera2025
kiriem
0
110
Présentation_1ère_Spé_2025.pdf
bernhardsvt
0
400
沖ハック~のみぞうさんとハッキングチャレンジ☆~
nomizone
1
330
今の私を形作る4つの要素と偶然の出会い(セレンディピティ)
mamohacy
2
110
The knowledge panel is your new homepage
bradwetherall
0
190
Web Application Frameworks - Lecture 3 - Web Technologies (1019888BNR)
signer
PRO
0
3k
仏教の源流からの奈良県中南和_奈良まほろば館‗飛鳥・藤原DAO/asuka-fujiwara_Saraswati
tkimura12
0
140
GOVERNOR ADDRESS:2025年9月29日合同公式訪問例会:2720 Japan O.K. ロータリーEクラブ、2025年10月6日卓話:藤田 千克由 氏(国際ロータリー第2720地区 2025-2026年度 ガバナー・大分中央ロータリークラブ・大分トキハタクシー(株)顧問)
2720japanoke
0
600
2026 g0v 零時政府年會啟動提案 / g0v Summit 2026 Kickstart
rschiang
0
350
登壇未経験者のための登壇戦略~LTは設計が9割!!!~
masakiokuda
3
710
2024-2025 CBT top items
cbtlibrary
0
130
Featured
See All Featured
Site-Speed That Sticks
csswizardry
11
900
Java REST API Framework Comparison - PWX 2021
mraible
33
8.9k
Into the Great Unknown - MozCon
thekraken
40
2.1k
It's Worth the Effort
3n
187
28k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
9
590
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
252
21k
A better future with KSS
kneath
239
18k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.7k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.7k
Being A Developer After 40
akosma
91
590k
How STYLIGHT went responsive
nonsquared
100
5.8k
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