Created
August 19, 2018 11:05
-
-
Save anitaa1990/ec976c29b5b2535112b47a6283554275 to your computer and use it in GitHub Desktop.
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
Observable | |
.create(emitter -> { | |
for(int i=0; i<= 6; i++) { | |
Thread.sleep(1000); | |
emitter.onNext(i); | |
} | |
emitter.onComplete(); | |
}) | |
.takeWhile(new Predicate<Object>() { | |
@Override | |
public boolean test(Object o) { | |
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