3 ms·
Sure, it's not the only option, just the better option for Javascript. Your example isn't representative of Javascript. This is an example for something that m
by gridlockd 6y ago
Sure, it's not the only option, just the better option for Javascript. Your example isn't representative of Javascript.
This is an example for something that might come up in Javascript, using async/await:
const a = await fetchA();
const b = await fetchB(a);
const stuff = await fetchStuff(a, b);
const transformedStuff = await Promise.all(stuff.map(someAsyncTransform));
Error handling is just try/catch.
Note that you generally have no control over most of these function being asynchronous. Threads or coroutines do nothing to help you write straightforward code when all your libraries are based on fine-grained callbacks/promises. Writing out that chain of dependencies in CPS would be a nightmare.
- anonymoushn 6y agoThey really do though. In the modal case you would just write the same code as in js but without all the extra keywords. If you need fanout you'd call some special function to do that, like you do now.