Javascript asynchronous
Callback (or continuation) ... so call me maybe :)
continuation passing style
Callback HELLLLL
Callback HELLLLL
Callbacks - Two Problems
A lose of control ( Inversion of Control ? can I trust you ? )
Hard to reason about ( its a time loooooooop and the temporal dependency)
A thunk is a function that has everything already that it needs to do (clojure state), to give you some value back; you simply call it, give it a callback and it will give you your value back;
Thunks ? what are you smoking
Promise land!
Promises ... i owe you
future values
Completion event or error event...
i fix the inversion of control problem
Promises ... i owe you
Promises ... i owe you
Still callbacks ????
Promise Trust:
only resolved once
either success or error
messages passed/kept
exceptions become errors
immutable once resolved
can't be canceld
Generators (yield) Wu shu
Ruuuuuuun to complition
Generators (yield) what are you ?
It's a state machine oO
I fix the non local, non sequential reasonability problem!
a function will run till completion ! or will they ?
should I stay or should I go ...
Generators (yield) what are you ?
a generator invocation will return a iterator
Iterators
Generators (yield) what are you ?
i can use yield to return a message
and yes we can use the it.next to pass in a value :)
Generators (yield)
we still have a ... aa ... inversion of control here :(( why youuuuu
ok ok chill, so we have promises to resolve the inversion of control so put that with generators and you get ....
a generator that yields promises ...
Generators (yield)
so we yield out promises and the promise will resume the generator ... sounds easy
Generators (yield) - i love using apply
Coroutines are a programming concept that allows functions to pause themselves and give control to another function. The functions pass control back and forth.
Coroutines
Generators (yield) what are you ?
synchronous looking asynchronous code
Coroutines - getting back the controle
Coroutines - getting back the controle
Does this look familiar ?
Coroutines - getting back the controle
Does this look familiar ?
Async functions!
Async functions
Rxjs
js-csp
Javascript async. 2.0
By Stefan Hagiu
Javascript async. 2.0
- 560