Created
March 17, 2015 18:53
-
-
Save robfletcher/fb3546d248bf0398d741 to your computer and use it in GitHub Desktop.
Test for backpressure when using Observable.interval
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
| @Grab("io.reactivex:rxjava:1.0.8") | |
| import rx.* | |
| import static java.util.concurrent.TimeUnit.* | |
| import static java.time.LocalTime.* | |
| def sub = Observable.interval(1, SECONDS) | |
| .doOnNext { tick-> | |
| println "tick $tick at ${now()}" | |
| } | |
| .subscribe { tick -> | |
| println "received tick $tick, sleeping..." | |
| sleep 2_000 | |
| println "woke up after tick $tick" | |
| } | |
| sleep 60_000 | |
| sub.unsubscribe() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment