hikamaeng
09/18/2019, 7:58 AMprivate class Cont<T>(val cont:Continuation<T>) : Continuation<T> {
override val context = cont.context
override fun resumeWith(result: Result<T>) {
window.requestAnimationFrame{cont.resumeWith(result)}
}
}
object JsInterceptor:AbstractCoroutineContextElement(ContinuationInterceptor), ContinuationInterceptor{
override fun <T> interceptContinuation(cont:Continuation<T>): Continuation<T> =
Cont(cont)
}
and use case
GlobalScope.launch(JsInterceptor){
...
}