Created
December 4, 2018 04:15
-
-
Save tcw165/38090c0b7ac5e84a766c3aaf34af72e1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val upstream = PublishSubject.create<Int>() | |
upstream.doOnDispose { Timber.d("Uh, the upstream gets disposed") } // This log will never print. | |
val tester = upstream | |
.flatMap { v -> | |
when (v) { | |
0 -> { | |
Timber.d("flatMap produces an empty") | |
Observable.empty<Int>() | |
} | |
else -> Observable.just(v) | |
} | |
} | |
.test() | |
upstream.onNext(0) // Will return a complete in flatMap. | |
upstream.onNext(1) // If the stream dies, we'll never emit this value successfully. | |
tester.assertValueCount(1) // Actually, the stream is still alive because flatMap ignores the complete! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment