Javascript asynchronous
Callback (or continuation) ... so call me maybe :)
continuation passing style
Callback HELLLLL
Callback HELLLLL
Exercise 1
Callbacks - Tow Problems
A lose of control ( Inversion of Control ? can i trust you ? )
Hard to reason about ( its a time loooooooop and the temporal dependency)
Thunks ? what are you smoking
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 ? time independent ... are you a promise
Ex 2 ?
Promises ... i owe you
our saver ...
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
Promises ... i owe you
Still callbacks ????
Promise Trust:
only resolved once
either success or error
messages passed/kept
exceptions become errors
immutable once resolved
Ex 3 :) and the flow control
Ex 4 ... if you didn't had enough
i has to show you something map and reduce
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 reasonable 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
the iterator will be used to resume the execution of the generator function.
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) - i love using apply
Generators (yield = i need something ... call me maybe or promise me luke)
on resume the yield is replace with the value passed back into the function
Generators (yield) what are you ?
synchronous looking asynchronous code
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
Ex 7 ? maybe ...
Done thank you :D
we has book we give book :)
Javascript async.
By Stefan Hagiu
Javascript async.
- 497