Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created August 19, 2018 10:59
Show Gist options
  • Save anitaa1990/72de811f44a65030adf7c26cef4772bc to your computer and use it in GitHub Desktop.
Save anitaa1990/72de811f44a65030adf7c26cef4772bc to your computer and use it in GitHub Desktop.
Observable
.create(emitter -> {
for(int i=0; i<= 6; i++) {
Thread.sleep(1000);
emitter.onNext(i);
}
emitter.onComplete();
})
.skipWhile(new Predicate<Object>() {
@Override
public boolean test(Object o) throws Exception {
return (((Integer)o < 2));
}
})
.subscribe(new Observer<Object>() {
@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