Skip to content

Instantly share code, notes, and snippets.

@tymbark
Created May 22, 2017 08:53
Show Gist options
  • Save tymbark/d147a3be7900fae6045f93bcf269ef98 to your computer and use it in GitHub Desktop.
Save tymbark/d147a3be7900fae6045f93bcf269ef98 to your computer and use it in GitHub Desktop.
@Test
public void switchMap() throws Exception {
final List<String> items = Lists.newArrayList("a", "b", "c", "d", "e", "f");
final TestScheduler scheduler = new TestScheduler();
Observable.from(items)
.concatMap( 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);
}
@hk0i
Copy link

hk0i commented Nov 6, 2018

this is testing concatMap() but the method name is public void switchMap(). Not a huge deal but you might want to update the name for consistency. I'm assuming the method should be called concatMap()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment