Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created August 18, 2018 19:13
Show Gist options
  • Save anitaa1990/b1cd4708f4b40546cd1b4f25b2f5d36a to your computer and use it in GitHub Desktop.
Save anitaa1990/b1cd4708f4b40546cd1b4f25b2f5d36a to your computer and use it in GitHub Desktop.
Observable timedObservable = Observable
.just(1, 2, 3, 4, 5, 6)
.zipWith(Observable.interval(
0, 1, TimeUnit.SECONDS), (item, time) -> item);
timedObservable
.sample(2, TimeUnit.SECONDS)
.subscribe(new Observer() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(Object o) {
System.out.println("onNext: " + o);
}
@Override
public void onError(Throwable e) {
}
@Override
public void onComplete() {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment