coletz
10/08/2018, 5:23 PMconst browser = await puppeteer.launch()
.
My issue is that I can't use await with kotlin js, and I don't know if "await" is just syntactic sugar for a callback (sort of stuff done on Java with coroutines)Casey Brooks
10/08/2018, 5:55 PMCasey Brooks
10/08/2018, 5:56 PMasync/await
is pretty much just syntactic sugar over the Promises API https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function. So if puppeteer.launch()
needs to be awaited, it really just returns a Promise
object, and you can then wrap that up in a Kotlin coroutinecoletz
10/08/2018, 6:04 PMgildor
10/09/2018, 3:37 AMawait()
extension for promises
https://github.com/Kotlin/kotlinx.coroutines/blob/master/js/kotlinx-coroutines-core-js/src/Promise.kt#L113