Created
August 19, 2018 06:11
-
-
Save anitaa1990/3413a914cc200aab1147f4d4fb3b95d2 to your computer and use it in GitHub Desktop.
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
/* | |
* There are 2 Observables each emitting values after an interval of 100 ms and 150 ms | |
* respectively. The combineLatest() operator combines both the observables and | |
* emits the result at each particular intervals. | |
*/ | |
Observable<Long> observable1 = Observable.interval(100, TimeUnit.MILLISECONDS); | |
Observable<Long> observable2 = Observable.interval(50, TimeUnit.MILLISECONDS); | |
Observable.combineLatest(observable1, observable2, | |
(observable1Times, observable2Times) -> | |
"Refreshed Observable1: " + observable1Times + " refreshed Observable2: " + observable2Times) | |
.subscribe(item -> System.out.println(item)); | |
Thread.sleep(1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment