Skip to content

Instantly share code, notes, and snippets.

@MathiasSeguy-Android2EE
Created June 11, 2020 09:08
Show Gist options
  • Save MathiasSeguy-Android2EE/a199bf8440dd60f88f31e7e488b99f0e to your computer and use it in GitHub Desktop.
Save MathiasSeguy-Android2EE/a199bf8440dd60f88f31e7e488b99f0e to your computer and use it in GitHub Desktop.
Markdium-Chapter 9: Observable's action operators
/**
* Using the observableWithErrorSrc skip error items and return a bad day item instead of the error
* @return
*/
public static Observable getObservableWithOnErrorReturn() {
return observableWithErrorSrc
.onErrorReturn(th->"Bad day");
}
/**
* OutPut result:
* value emitted is Monday
* value emitted is Bad day
* onCompleteCalled
*/
@Test
public void testObservableWithOnErrorReturn() {
Answer9_ObservableActions.getObservableWithOnErrorReturn()
.subscribe(it -> System.out.println("value emitted is " + it),
Throwable::printStackTrace,
() -> System.out.println("onCompleteCalled"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment