kirillrakhman
fun Subscription.autoUnsubscribe(naviComponent: NaviComponent) = apply { naviComponent.addListener(Event.DESTROY) { unsubscribe() } } fun NaviComponent.asyncRx(coroutine c: RxController.() -> Continuation<Unit>) { RxController(this).c().resume(Unit) } class RxController internal constructor( private val naviComponent: NaviComponent ) { suspend fun <V> Observable<V>.awaitFirst(x: Continuation<V>) { this.first().subscribeWithContinuation(x) } private fun <V> Observable<V>.subscribeWithContinuation(x: Continuation<V>) { subscribe(x::resume, x::resumeWithException).autoUnsubscribe(naviComponent) } }
A modern programming language that makes developers happier.