Skip to content

Instantly share code, notes, and snippets.

@robfletcher
Created March 17, 2015 18:53
Show Gist options
  • Select an option

  • Save robfletcher/fb3546d248bf0398d741 to your computer and use it in GitHub Desktop.

Select an option

Save robfletcher/fb3546d248bf0398d741 to your computer and use it in GitHub Desktop.
Test for backpressure when using Observable.interval
@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