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
ember-concurrency: an experience report
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Reg Braithwaite
June 05, 2017
Programming
170
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ember-concurrency: an experience report
An informal talk given at the EmberTO meetup in June, 2017
Reg Braithwaite
June 05, 2017
More Decks by Reg Braithwaite
See All by Reg Braithwaite
Courage
raganwald
0
150
Waste in Software Development
raganwald
0
210
First-Class Commands, the 2017 Edition
raganwald
1
240
Optimism and the Growth Mindset
raganwald
0
340
Optimism II
raganwald
0
440
Optimism
raganwald
0
2.1k
First-Class Commands: an unexpectedly fertile design pattern
raganwald
4
3k
JavaScript Combinators, the “six” edition
raganwald
8
1.5k
Duck Typing, Compatibility, and the Adaptor Pattern
raganwald
7
11k
Other Decks in Programming
See All in Programming
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
220
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
170
CLIであることを活かしたGitHub Copilot CLI活用術 / GitHub Copilot CLI Pro Tips & Tricks
nao_mk2
1
1.2k
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
140
Swiftのレキシカルスコープ管理
kntkymt
0
210
dRuby over BLE
makicamel
2
320
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.2k
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
4.2k
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
120
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
440
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
840
CSC307 Lecture 17
javiergs
PRO
0
310
Featured
See All Featured
30 Presentation Tips
portentint
PRO
1
320
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
840
Designing for Timeless Needs
cassininazir
1
250
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
180
So, you think you're a good person
axbom
PRO
2
2.1k
It's Worth the Effort
3n
188
29k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.4k
Designing Experiences People Love
moore
143
24k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Transcript
ember-concurrency "an experience report" Reginald @raganwald Braithwaite, PagerDuty Inc.
ember-concurrency ember-concurrency is an Ember Addon that makes it easy
to write concise, robust, and beautiful asynchronous code. --http://ember-concurrency.com/ Reginald @raganwald Braithwaite, PagerDuty Inc.
tasks and instances aTask = task(function * () { const
{ geolocation, store } = this.get(...); const coords = yield geolocation.getCoords(); const result = yield store.getNearbyStores(coords); this.set('result', result); }); anInstance = someTask.perform(); Reginald @raganwald Braithwaite, PagerDuty Inc.
problems ember-concurrency solves, easily Reginald @raganwald Braithwaite, PagerDuty Inc.
mashing the "submit" button on an update Reginald @raganwald Braithwaite,
PagerDuty Inc.
! Reginald @raganwald Braithwaite, PagerDuty Inc.
concurrency protocols task(function * () { // ... }).drop() (ember-concurrency
calls these "modifiers") Reginald @raganwald Braithwaite, PagerDuty Inc.
! Reginald @raganwald Braithwaite, PagerDuty Inc.
displaying a loading spinner Reginald @raganwald Braithwaite, PagerDuty Inc.
! this.set('isLoading', true); this.xhr = fetch(id).then( success => { this.set('isLoading',
false); // ... }, failure => { this.set('isLoading', false); // ... }); Reginald @raganwald Braithwaite, PagerDuty Inc.
! isLoading: reads('fetchTask.isRunning') Reginald @raganwald Braithwaite, PagerDuty Inc.
using ember-concurrency to solve other problems Reginald @raganwald Braithwaite, PagerDuty
Inc.
chunking updates to our api Reginald @raganwald Braithwaite, PagerDuty Inc.
progress const chunks = _.chunk(incidents, CHUNK_SIZE); let done = 0;
this.set('done', done); for (const theseIncidents of chunks) { yield this.resolve(theseIncidents); done = done + theseIncidents.length); this.set('done', done); } Reginald @raganwald Braithwaite, PagerDuty Inc.
Reginald @raganwald Braithwaite, PagerDuty Inc.
cancellation aTask.cancelAll(); anInstance.cancel(); Reginald @raganwald Braithwaite, PagerDuty Inc.
a bigger challenge Reginald @raganwald Braithwaite, PagerDuty Inc.
In JavaScript, AJAX requests happen concurrently. Reginald @raganwald Braithwaite, PagerDuty
Inc.
Reginald @raganwald Braithwaite, PagerDuty Inc.
⛈ websocket ping: [-----------------] submit update: [-----------] Reginald @raganwald Braithwaite,
PagerDuty Inc.
☀ Reginald @raganwald Braithwaite, PagerDuty Inc.
sharing one task task(function * (promissoryThunk) { let result; yield
promissoryThunk().then(value => { result = value; }); return result; }).enqueue() Reginald @raganwald Braithwaite, PagerDuty Inc.
serialized results websocket ping: [--------] submit update: [-------] Reginald @raganwald
Braithwaite, PagerDuty Inc.
⁉ Reginald @raganwald Braithwaite, PagerDuty Inc.
task groups tasks: taskGroup().enqueue(), handlePing: task(function * () { //
... }).group('tasks'), submitUpdate: task(function * () { // ... }).group('tasks') Reginald @raganwald Braithwaite, PagerDuty Inc.
ember-concurrency conclusion Reginald @raganwald Braithwaite, PagerDuty Inc.
Simple things are easy, complex things are possible. Reginald @raganwald
Braithwaite, PagerDuty Inc.
Reginald @raganwald Braithwaite, PagerDuty Inc.