4 ms·
async/await makes it pretty easy to take an async library and use it in a synchronous context.
by amenghra 8y ago
async/await makes it pretty easy to take an async library and use it in a synchronous context.
- eridius 8y agoNo it doesn't. await doesn't make asynchronous functions synchronous. It just changes how you write the code, not how the code itself works. Notably, await can only be used from inside an async function.
- coldtea 8y agoOnce you go asynchronous (e.g. call an async function, wait for a promise) you can never go back to a synchronous context in that chain of code. async just makes asynchronous look like a synchronous code, but it's still event-based and async.