11 ms·
Yes, aOut would be a promise. It would look like this: async function doA() { ... return "the-result-of-a"; } (Which returns a promise
by jmull 8y ago
Yes, 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.