syncing asynckyle simpson
@getifyhttp://getify.me
to get started...
vs.
parallel
async
threads
event-loop concurrency
1234
123
1
2
34
1
23 done!
done!
async patterns
callbacks==
continuations
callbacksgot
problems2 major^
“callback hell”
still “callback hell”
inversion of control
trust:1. not too early2. not too late3. not too many times4. not too few times5. no lost context6. no swallowed errors...
nested callbacksare not
reasonable
we write
such syncmany steps
very wow
we think
js thinks
sync-looking async
synchronoussequentialblocking
hell is callbacks
-Sartre
promise: future value
promise: “completion” event
promises:1. only resolved once2. either success OR error3. messages passed/kept4. exceptions become errors5. immutable once resolved
uninversion of control
promise: flow control
scenario:load files in parallel, render in order, but ASAP
cool story, bro.
but...
scenario:timeout of a promise
blog.getify.com/promises-part-1/
github.com/getify/native-promise-only
promise abstractions
sequence=
series of automatically
chained promises
github.com/getify/asynquence
async + sequence =
asynquence
remember?load files in parallel, render in order, but ASAP
promises without all the fuss
gimme moar sync
ES6 generators
davidwalsh.name/es6-generators
generator + promises
yield promises
what about pre-ES6 browsers?
facebook.github.io/regenerator/
transpiledES5
“generators”
~ES7 async ?
github.com/lukehoban/ecmascript-asyncawait
CSP-likeconcurrency
.done()
chuckle, chuckle
thx!
kyle simpson@getify
http://getify.me