Created
August 19, 2018 08:32
-
-
Save anitaa1990/3c232c91dd673354bd74bea1303274de 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
/* Example of doOnNext() */ | |
Observable.just("A", "B", "C", "D", "E", "F") | |
.doOnNext(new Consumer<String>() { | |
@Override | |
public void accept(String s) { | |
System.out.println("doOnNext: " + s); | |
} | |
}) | |
.subscribe(); | |
/* Example of doOnSubscribe(), doOnUnSubscribe(), doOnEach() */ | |
Observable.range(1, 5) | |
.doOnEach(new Observer<Integer>() { | |
@Override | |
public void onError(Throwable e) { | |
e.printStackTrace(); | |
} | |
@Override | |
public void onComplete() { | |
System.out.println("Complete is called"); | |
} | |
@Override | |
public void onSubscribe(Disposable d) { | |
System.out.println("onSubscribe is called"); | |
} | |
@Override | |
public void onNext(Integer value) { | |
System.out.println("onNext: " + value); | |
} | |
}) | |
.doOnSubscribe(new Consumer<Disposable>() { | |
@Override | |
public void accept(Disposable disposable) { | |
System.out.println("onUnSubscribe is called"); | |
} | |
}) | |
.subscribe(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment