Async JavaScript

Evan Savage

candu
@candusavage

before we start

hey! listen!

these slides are HTML/JS

go here, click "Async JavaScript", enjoy!

https://candu.github.io/presentations

Chrome users:

enable Harmony!

go here, click "Enable", restart browser:

chrome://flags/#enable-javascript-harmony

wait in line

some helper functions
DOM updates wait their turn
the setTimeout(..., 0) trick
events wait their turn
events are queued, part 1
events are queued, part 2
JavaScript: asynchronous ≠ concurrent

i'll have my people call your people

$.ajax(), old-style
the pyramid of doom
named callbacks
DIY series execution
DIY parallel execution

everything but the kitchen async

async

node-style callbacks
async.series()
async.parallel()

i'll be back, i promise

$.ajax(), new-style
chaining promises
DIY promises, part 1
DIY promises, part 2
DiyPromise.all()
for your promise needs:

$.Deferred()

Q

Promise API (ES6)

what's the big event?

$.on(), $.trigger()
DIY event dispatcher, part 1
DIY event dispatcher, part 2
event evaluation is synchronous

alright, i yield!

ES6 generators
yield*
generators and promises, part 1
generators and promises, part 2
generators and promises, part 3
generators and promises, part 4
co

co()
DIY generators?

regenerator

Traceur

TL;DR: sort of. if you like byzantine code transformations. and pain.

i said right this second!

timer resolution
The minimum delay, DOM_MIN_TIMEOUT_VALUE, is 4 ms...the timeout can also fire later when the page (or the OS/browser itself) is busy with other tasks.
setImmediate()
setImmediate?

the postMessage() trick, part 1
the postMessage() trick, part 2

it's all in the timing

WatchdogTimer
_.debounce
animation loops
fps: 0
requestAnimationFrame()
fps: 0

fin

Async JavaScript

Evan Savage

candu
@candusavage