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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
[AWS 秋のクラウドオペレーション祭り 2026]AWS DevOps Agentで変わるリリースと運用対応 ~リリース管理機能と Directed actions のご紹介~
furuton
4
1.2k
AI時代のPRレビューにどう向き合うか?
kairim0
1
220
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
180
V8のArray.prototype.flatを最大約20倍速くするまでと、巨大OSSへの大規模コミットの道のり
riyaamemiya
0
280
継続的なAIコスト最適化
bgpat
1
290
Snapshot Testing in Practice: Predictable and Reliable SwiftUI Views
fespinoza
0
210
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
120
今さら理解するウェブフォントver.2026
takanorip
3
690
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
AIに攻撃される前に、AIに攻撃させる
tsuchikazu
0
170
AI 時代の Azure エンジニアリング ~ 私たちは何を磨き、何を任せるのか ~
chack411
1
610
PagerDuty Tech Hub-鳴らすけれど、人は動かない
ezaki
0
120
Featured
See All Featured
The Mindset for Success: Future Career Progression
greggifford
PRO
0
530
Ethics towards AI in product and experience design
skipperchong
2
430
Ten Tips & Tricks for a 🌱 transition
stuffmc
1
260
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Become a Pro
speakerdeck
PRO
31
6.3k
Design in an AI World
tapps
1
350
What does AI have to do with Human Rights?
axbom
PRO
1
2.4k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
580
The agentic SEO stack - context over prompts
schlessera
0
970
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
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