Last active
May 22, 2017 08:31
-
-
Save tymbark/6945fd25b96ac8daa6aad50675243c5d 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
@Test | |
public void flatMap() throws Exception { | |
final List<String> items = Lists.newArrayList("a", "b", "c", "d", "e", "f"); | |
final TestScheduler scheduler = new TestScheduler(); | |
Observable.from(items) | |
.flatMap( s -> { | |
final int delay = new Random().nextInt(10); | |
return Observable.just(s + "x") | |
.delay(delay, TimeUnit.SECONDS, scheduler); | |
}) | |
.toList() | |
.doOnNext(System.out::println) | |
.subscribe(); | |
scheduler.advanceTimeBy(1, TimeUnit.MINUTES); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment