3 ms·
I get that it returns a wrapper, but the functions like map and toUpperCase would have to wait for the asynchronous callback somehow. How does this work?
by dmak 11y ago
I get that it returns a wrapper, but the functions like map and toUpperCase would have to wait for the asynchronous callback somehow. How does this work?
- igl 11y agoIt basicly a wrapper around Promises. Nothing of your sync functions work until after you do syncify.revert which gives you a function taking a CALLBACK.
- dmak 11y agoI get promises, but in this example: function getFullName( id ){ return ajax( "/user/" + id + "/name" ) + " " + ajax( "/user/" + id + "/lastname" ) } How does it know to to wait for both ajax functions before returning the correct value? Am I misunderstanding something?
- zackmorris 11y agoSee my response to virulent. I believe it re-runs the parent function multiple times until all of the child ajax functions have evaluated to their return values. This probably explains why the author states that the child functions must be idempotent (edit: and the code readonly in its entirety to prevent side effects).