Slide 71
Slide 71 text
class LoadingChannel(val lifecycle: Lifecycle,_
val view: View,_
val loadFunction: () -> T) {_
infix fun then(uiFunction: (T) -> Unit) {_
val job = Job()
val actor = actor(context = UI,
parent = job) { }_
_
lifecycle.addObserver(CoroutineLifecycleListener(job))_
_
view.setOnClickListener { actor.offer(Unit) }_
}_
}_