Created
November 5, 2015 16:35
-
-
Save jpetitto/b2e0a532fa63b59576aa to your computer and use it in GitHub Desktop.
Polling at Dynamic Rate with RxJava
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
BehaviorSubject<Integer> timerSubject = BehaviorSubject.create(1); | |
timerSubject | |
.switchMap(interval -> Observable.timer(interval, TimeUnit.SECONDS, Schedulers.newThread())) | |
.flatMap(i -> Observable.just(randomInt())) | |
.doOnNext(timerSubject::onNext) | |
.subscribe(System.out::println); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment