Created
June 11, 2020 09:08
-
-
Save MathiasSeguy-Android2EE/998e6c8a3aaade1449797ecbf3457e40 to your computer and use it in GitHub Desktop.
Markdium-Chapter 9: Observable's action operators
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
/** | |
* Using the observableWithErrorSrc skip error items and retry twice | |
* @return | |
*/ | |
public static Observable getObservableWithOnErrorRetry() { | |
//you can also return an empty Observable and then quit the Observable nicely | |
return observableWithErrorSrc | |
.retry(2); | |
} | |
/** | |
* OutPut result: | |
* value emitted is Monday | |
* value emitted is Monday | |
* value emitted is Monday | |
exception thrown java.lang.NullPointerException: onNext called with null. Null values are generally not allowed in 2.x operators and sources. | |
* java.lang.NullPointerException: onNext called with null. Null values are generally not allowed in 2.x operators and sources. | |
*/ | |
@Test | |
public void testObservableWithOnErrorRecover() { | |
Answer9_ObservableActions.getObservableWithOnErrorRetry() | |
.subscribe(it -> System.out.println("value emitted is " + it), | |
th -> { | |
System.out.println("exception thrown " + th); | |
th.printStackTrace(); | |
}, | |
() -> System.out.println("onCompleteCalled")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment