adeln
02/01/2017, 8:13 PMsuspend fun <T> Observable<T>.await(): T =
suspendCoroutine { cont ->
subscribe(object : Observer<T> {
override fun onComplete() = Unit
override fun onSubscribe(d: Disposable) = Unit
override fun onError(e: Throwable) = cont.resumeWithException(e)
override fun onNext(t: T) = cont.resume(t)
})
}