3 ms·
I'm pretty sure you can await any javascript Promise! For example, running `await Promise.resolve(3)` in Chrome's js console prints `3`.
by bijection 8y ago
I'm pretty sure you can await any javascript Promise!
For example, running `await Promise.resolve(3)` in Chrome's js console prints `3`.
- alexkavon 8y agoAlso MDN has a fantastic Promise article with examples about wrapping a function with a promise.[0] [0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- JonathonW 8y agoIt's a little unclear, but I think he wants to integrate Python (Pyodide) coroutines into the JS event loop-- so async/await of Python code works seamlessly in the browser, and you can await Python code from within JS (and vice versa). Any JS Promise is awaitable from JS; JS async/await is (more or less) syntactic sugar on top of promises.
- bayesian_horse 8y agoSorry, I meant to use "await" in Python to await Javascript Promises.