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
Programação Reativa com RxJS
Search
Jonata Weber
May 27, 2017
Technology
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Programação Reativa com RxJS
Jonata Weber
May 27, 2017
More Decks by Jonata Weber
See All by Jonata Weber
PHPStan - Analisador Estático
jonataa
0
130
PHP Moderno
jonataa
0
120
TemDendê: Desenvolvimento PHP a Moda Baiana
jonataa
0
63
O que esperar de um profissional de TI
jonataa
0
56
A onda agora é função como serviço
jonataa
0
42
Programação Funcional com Acarajé e Dendê
jonataa
0
82
Curso de Programação Funcional com JavaScript
jonataa
0
190
Medindo a Performance de Códigos PHP
jonataa
0
79
5 motivos para você participar de eventos
jonataa
0
160
Other Decks in Technology
See All in Technology
LLMに渡さなかった仕事
nanaism
0
930
映像変換サーバーなしで端末内でHLSを生成してライブ配信
hikarusato
0
130
開発投資の期待値を上げるプロダクトロードマップづくり ~プロダクトエンジニアが越境して事業を伸ばす~
kekekenta
1
220
HRC_Frontend_Conference_Fukuoka_2026.pdf
ts020
0
750
AIに任せた品質は、誰が見立てるのか - AI時代のテストマネジメント
nakanao
3
2.3k
すぐできる衛星通信対応 あとは山奥に行くだけ
tatetate55
0
140
2026_devsumi_ozono.pdf
o3
3
520
AI de Idea
kawaguti
PRO
2
130
俺の仕事は AIに奪われないし、たぶんその BIも要らない
hikaruri
0
520
The Knowledge Spine: A Machine-Executable Ontology for Governed Marketing Activation
vananth22
0
110
What the customer really needed
kawaguti
PRO
3
210
AIエージェントの自己改善をどう設計するか / How to Design Self-Improvement for AI Agents
22mi
25
16k
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1.6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Why Our Code Smells
bkeepers
PRO
340
58k
Claude Code のすすめ
schroneko
67
230k
Code Review Best Practice
trishagee
74
20k
Scaling GitHub
holman
464
140k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
500
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Transcript
Programação Reativa com RxJS Por Jonata Weber
@JonataWeber
None
None
Programação Reativa
Reactive programming is programming with asynchronous data streams.
Async em Web apps • AJAX • User Events (mouse
clicks, mouvemoves, keyups, etc) • Animations • Sockets • Workers
Por que usar RP?
None
callback É a maneira mais primitiva de trabalhar com async
no JavaScript getSomeData((data) => { console.log('data received', data); });
Callback Hell
Promises Provê uma solução simples getData(id) .then(data => { doStuff(data);
return getSomeData(data.parentId); }) .then(data => { doStuff(data); return getSomeData(data.parentId); })
Promises • Garante o Futuro • Imutável • Único valor
• Caching
Promises let promise = new Promise((resolve, reject) => { let
success = doSomethingAsync(); if (success) { resolve("Stuff worked!"); } else { reject(Error("It broke")); } });
Promises let promise = new Promise((resolve, reject) => { let
success = doSomethingAsync(); if (success) { resolve("Stuff worked!"); } else { reject(Error("It broke")); } });
Promises let promise = new Promise((resolve, reject) => { let
success = doSomethingAsync(); if (success) { resolve("Stuff worked!"); } else { reject(Error("It broke")); } });
Promises Pendente Realizada Rejeitado Estabelecido
Promises Pendente Realizada Rejeitado Estabelecido Não pode ser cancelada!!!
GET /search?q=pagode Search com Promises
GET /search?q=pop GET /search?q=pagode Search com Promises
GET /search?q=pagode GET /search?q=pop Search com Promises
Processará algo inútil Search com Promises GET /search?q=pagode GET /search?q=pop
GET /search?q=pagode Cenário ideal
GET /search?q=pop GET /search?q=pagode Cenário ideal
GET /search?q=pop GET /search?q=pagode Cenário ideal Abortar a requisição anterior
RxJS
RxJS is a library for composing asynchronous and event-based programs
by using observable sequences.
ReactiveX is a combination of the best ideas from the
Observer pattern, the Iterator pattern, and functional programming
Java: RxJava JavaScript: RxJS C#: Rx.NET Python: RxPY Ruby: Rx.rb
PHP: RxPHP Go: RxGo Kotlin: RxKotlin C++: RxCpp Lua: RxLua Groovy: RxGroovy JRuby: RxJRuby Swift: RxSwift Elixir: reaxive Dart: RxDart C# (Unity): UniRx
Demo
Hello World Rx.Observable .of(1, 2, 3, 4, 5) .subscribe(n =>
console.log(n)); http://jsbin.com/muxigepeju/edit?js,console
const btn = document.querySelector('button'); Rx.Observable.fromEvent(btn, 'click') .throttleTime(250) .scan(count => count
+ 1, 0) .subscribe(count => console.log(`Clicked ${count} times`)); Contador de Cliques http://jsbin.com/qifumej/edit?js,console,output
None
Transformation Operators • buffer • bufferCount • bufferTime • bufferToggle
• bufferWhen • concatMap • concatMapTo • exhaustMap • expand • groupBy • map • mapTo • mergeMap • mergeMapTo • mergeScan • pairwise • partition • pluck • scan • switchMap • switchMapTo • window • windowCount • windowTime • windowToggle • windowWhen
Demo http://jsbin.com/fuviwin/edit?js,console,output
Observable
Single Multiple Pull Function Iterator Push Promise Observable
Exemplo let observable = Rx.Observable.create((observer) => { observer.next(1); observer.next(2); observer.next(3);
setTimeout(() => { observer.next(4); observer.complete(); }, 1000); });
let observable = Rx.Observable.create((observer) => { observer.next(1); observer.next(2); observer.next(3); setTimeout(()
=> { observer.next(4); observer.complete(); }, 1000); }); console.log('just before subscribe'); observable.subscribe({ next: x => console.log('got value ' + x), error: err => console.error('something wrong occurred: ' + err), complete: () => console.log('done'), }); console.log('just after subscribe');
Subjects
Demo http://jsbin.com/ribosa/edit?js,console
Onde posso aprender mais sobre RxJS?
Referências • http://reactivex.io/rxjs/manual/overview.html#subject • https://www.gitbook.com/book/btroncone/learn-rxjs/ details • https://xgrommx.github.io/rx-book/why_rx.html • https://github.com/ReactiveX/rxjs
• https://www.youtube.com/watch?v=COviCoUtwx4
Obrigado! @JonataWeber