You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 5, 2021. It is now read-only.
I am reading the code out of curiosity and was just wondering about this piece of code
fun Any.async(c: suspend AsynkHandler.() -> Unit): AsynkHandler {
val controller = AsynkHandler(this)
keepCoroutineForCancelPurpose(controller)
return async(c, controller)
}
fun Activity.async(c: suspend AsynkHandler.() -> Unit): AsynkHandler {
val controller = AsynkHandler(this)
keepCoroutineForCancelPurpose(controller)
return async(c, controller)
}
fun Fragment.async(c: suspend AsynkHandler.() -> Unit): AsynkHandler {
val controller = AsynkHandler(this)
keepCoroutineForCancelPurpose(controller)
return async(c, controller)
}
fun android.support.v4.app.Fragment.async(c: suspend AsynkHandler.() -> Unit): AsynkHandler {
val controller = AsynkHandler(this)
keepCoroutineForCancelPurpose(controller)
return async(c, controller)
}
Wouldn't the first extension function just work for all the other definitions since it's an extension function of Any ? Why override it per activity/fragment?
fun Any.async(c: suspend AsynkHandler.() -> Unit): AsynkHandler {
val controller = AsynkHandler(this)
keepCoroutineForCancelPurpose(controller)
return async(c, controller)
}
Would you consider a PR to remove them ?
Thanks!
The text was updated successfully, but these errors were encountered:
Hi, thanks for the suggestion.
Yes. I was experimenting with the Any.async(...)
In activity/Fragment when you start coroutine block with async{...}, you've to take care of the memory leaks so you have to use async.cancelAll(). That code I let for experiment and Was trying to port this one for non-android platforms as well. Yes sure you are right I'll rather remove the Any.async() instead of other extensions of async. OR, There's one possible solution to register viewLifeCycleObserver with async so that in onDestroy() we could cancel it all internally and user is free from lifting that cleanup stuff. You can raise a PR.
I am reading the code out of curiosity and was just wondering about this piece of code
Wouldn't the first extension function just work for all the other definitions since it's an extension function of
Any
? Why override it per activity/fragment?Would you consider a PR to remove them ?
Thanks!
The text was updated successfully, but these errors were encountered: