3 ms·
How about this slightly more realistic example? https://gist.github.com/spion/33b3bf013cc9181171b9#example https://gist.github.com/spion/33b3bf013cc9181171b9#e
by spion 13y ago
How about this slightly more realistic example?
https://gist.github.com/spion/33b3bf013cc9181171b9#example https://gist.github.com/spion/33b3bf013cc9181171b9#example
- ufo 13y agoThe TL;DR: * Callbacks passed to cb-based libraries may be called twice - promises are only resolved once, either fulfilled or rejected. * Callback-based libraries may blow up if the callback throws - promise libraries shield the callback stack from "blowing up" (but do require slightly less careless management of resources at the call-stack site) * Callbacks passed to cb-based libraries may be called before the current even tick completes, potentially creating the zalgo problem - callbacks attached to promises are always called after the currently executed function finishes.