Allan Wang
01/01/2019, 11:44 PMlaunch {
val cookie = web.loadLogin { refresh(it != 100) }
L.d { "Login found" }
FbCookie.save(cookie.id)
web.fadeOut(onFinish = {
profile.fadeIn()
this@LoginActivity.launch { loadInfo(cookie) }
})
}
This is inside an android activity, which implements coroutine scope on the main dispatcher. It took me a while to debug, buy if the second launch
was not from the activity scope, but rather a child of the parent launch
, it would never actually run. Fade out is a normal method with a callback, and loadInfo is a suspended function using withContext(Dispatchers.Main)
.
Why is this the case?gildor
01/02/2019, 12:54 AMloadInfo(cookie)
)ghedeon
01/02/2019, 1:54 AML.d
🙂Allan Wang
01/02/2019, 2:47 AMDico
01/02/2019, 3:28 AMfadeOut()
suspend and remove the callback, inlining it after the call.Allan Wang
01/02/2019, 5:01 AMDico
01/02/2019, 5:03 AMAllan Wang
01/02/2019, 7:09 AMDico
01/02/2019, 7:10 AM