$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ember-concurrency: an experience report
Search
Reg Braithwaite
June 05, 2017
Programming
1
150
ember-concurrency: an experience report
An informal talk given at the EmberTO meetup in June, 2017
Reg Braithwaite
June 05, 2017
Tweet
Share
More Decks by Reg Braithwaite
See All by Reg Braithwaite
Courage
raganwald
0
130
Waste in Software Development
raganwald
0
190
First-Class Commands, the 2017 Edition
raganwald
1
190
Optimism and the Growth Mindset
raganwald
0
310
Optimism II
raganwald
0
420
Optimism
raganwald
0
2k
First-Class Commands: an unexpectedly fertile design pattern
raganwald
4
2.9k
JavaScript Combinators, the “six” edition
raganwald
8
1.4k
Duck Typing, Compatibility, and the Adaptor Pattern
raganwald
7
10k
Other Decks in Programming
See All in Programming
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
480
生成AIを利用するだけでなく、投資できる組織へ
pospome
2
330
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
150
Integrating WordPress and Symfony
alexandresalome
0
150
TypeScriptで設計する 堅牢さとUXを両立した非同期ワークフローの実現
moeka__c
6
3k
なあ兄弟、 余白の意味を考えてから UI実装してくれ!
ktcryomm
11
11k
エディターってAIで操作できるんだぜ
kis9a
0
730
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
400
30分でDoctrineの仕組みと使い方を完全にマスターする / phpconkagawa 2025 Doctrine
ttskch
4
870
俺流レスポンシブコーディング 2025
tak_dcxi
14
8.7k
AIエンジニアリングのご紹介 / Introduction to AI Engineering
rkaga
7
2.3k
関数実行の裏側では何が起きているのか?
minop1205
1
690
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
What's in a price? How to price your products and services
michaelherold
246
13k
Writing Fast Ruby
sferik
630
62k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
Bash Introduction
62gerente
615
210k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
36
6.2k
Become a Pro
speakerdeck
PRO
31
5.7k
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.