kevin.cianfarini
09/03/2019, 8:28 PMCorotuineScope
job be descended from the job in a fragment (and maybe the fragment is descended from the activity)? I'm thinking something like this.Pablichjenkov
09/03/2019, 9:02 PMkevin.cianfarini
09/03/2019, 9:17 PMSupervisorJob
has an optional parameter of parent: Job
Pablichjenkov
09/03/2019, 9:19 PMkevin.cianfarini
09/03/2019, 9:19 PMPablichjenkov
09/03/2019, 9:20 PMkevin.cianfarini
09/03/2019, 9:20 PMJob
from an already existing CorotuineScope, eg lifecycleScope
Pablichjenkov
09/03/2019, 9:32 PMSupervisorJob
to intercept exception propagation from child to parent. To get the Job of a given scope this should work:
scope.coroutineContext[Job]
kevin.cianfarini
09/03/2019, 9:45 PMgildor
09/04/2019, 4:58 AMPablichjenkov
09/04/2019, 11:33 PMkevin.cianfarini
09/05/2019, 12:38 AMabstract class CoroutineViewHolder(
itemView: View,
scope: CoroutineScope
) : RecyclerView.ViewHolder(itemView), CoroutineScope by scope {
/**
* This establishes a lifecycle for recycling of views for
* coroutine aware ViewHolders. Cancel the work that's being
* done if this view is recycled and no longer needed.
*/
@CallSuper
fun onRecycled() {
this.cancel("${this}.onRecycled called")
}
}
Pablichjenkov
09/05/2019, 1:07 AMkevin.cianfarini
09/05/2019, 1:09 AMPablichjenkov
09/05/2019, 1:36 AM