4 ms·
so in your code sample, would 'aOut' be a promise or a value? in case it is a promise, then basically doC() would needed to be re-written to handle when it gets
by lorean_victor 8y ago
so in your code sample, would 'aOut' be a promise or a value? in case it is a promise, then basically doC() would needed to be re-written to handle when it gets a promised value instead of an actual value, and if not, then doA() must be invoked synchronously, i.e. the `let bOut = doB()` statement must be awaiting `let aOut = doA()` statement which is not what the desired async execution flow is.
- jmull 8y agoYes, aOut would be a promise. It would look like this: async function doA() { ... return "the-result-of-a"; } (Which returns a promise. Assuming execution reaches that last line of my sample code, the promise will resolve to "the-result-of-a" when you "await" it.) > ...then basically doC() would needed to be re-written to handle when it gets a promised value instead of an actual value Well, wait a minute... it wasn't written in the first place! Let's write it though. It would look like this: async function doC( param ) { ... // we use "await param" where we want to // access the value of param. e.g.: const paramValue = await param; ... } So not bad.
- lorean_victor 8y agoyeah really not bad at all, didn't think of that solution originally. edited the article accordingly.