Created
December 7, 2018 09:02
-
-
Save hilfritz/18776d94d4c6d113c30cde9ed4a04f10 to your computer and use it in GitHub Desktop.
Android: Rxjava RxAndroid Countdown timer
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
//source: https://github.com/ReactiveX/RxJava/issues/3505 | |
####Emit each item 5 seconds after the previous item: | |
List<Integer> list = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6)); | |
Observable | |
.interval(5, TimeUnit.SECONDS) | |
.map(i -> list.get(i.intValue())) | |
.take(list.size()) | |
.toBlocking() | |
.subscribe(System.out::println) | |
; | |
####Emit everything after 5 seconds passed: | |
Observable | |
.from(list) | |
.delay(5, TimeUnit.SECONDS) | |
.toBlocking() | |
.subscribe(System.out::println); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment