Created
April 7, 2017 07:54
-
-
Save stepango/dd6f326cccb499f940cda7f8a7b64658 to your computer and use it in GitHub Desktop.
Arguments forwarding test
This file contains 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
class RxTest { | |
@Test fun forward() { | |
fun <T : Any, R : Any> Observable<T>.forwardFlatMap(block: () -> Observable<R>): Observable<Pair<T, R>> | |
= flatMap { item -> block().map { item to it } } | |
Observable.just("") | |
.flatMap { str -> | |
Observable.just(1) | |
.map { str to it } | |
} | |
.map { (x, y) -> "$x$y" } | |
.test() | |
.assertValue("1") | |
Observable.just("") | |
.forwardFlatMap { Observable.just(1) } | |
.map { (x, y) -> "$x$y" } | |
.test() | |
.assertValue("1") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment