Skip to content

Commit

Permalink
Reuse RxJava built-in disposed Disposable (#1841)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwwdfsad authored Mar 4, 2020
1 parent d831a86 commit 8d8a8fb
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions reactive/kotlinx-coroutines-rx2/src/RxConvert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,7 @@ public fun <T: Any> ObservableSource<T>.asFlow(): Flow<T> = callbackFlow {
}

subscribe(observer)
awaitClose { disposableRef.getAndSet(Disposed)?.dispose() }
}

private object Disposed : Disposable {
override fun isDisposed() = true
override fun dispose() = Unit
awaitClose { disposableRef.getAndSet(Disposables.disposed())?.dispose() }
}

/**
Expand Down

0 comments on commit 8d8a8fb

Please sign in to comment.