Skip to content

Instantly share code, notes, and snippets.

@MathiasSeguy-Android2EE
Created June 11, 2020 09:08
Show Gist options
  • Save MathiasSeguy-Android2EE/b86fca82a560637f1b71078e2d4109a7 to your computer and use it in GitHub Desktop.
Save MathiasSeguy-Android2EE/b86fca82a560637f1b71078e2d4109a7 to your computer and use it in GitHub Desktop.
Markdium-Chapter 9: Observable's action operators
/**
* Using the observableWithErrorSrc skip error and return twice "Buggy Day"
* @return
*/
public static Observable getObservableWithOnErrorResumeNext() {
return observableWithErrorSrc
.onErrorResumeNext(Observable.just("Buggy day").repeat(2));
}
/**
* OutPut result:
* value emitted is Monday
* value emitted is Buggy day
* value emitted is Buggy day
* onCompleteCalled
*/
@Test
public void testObservableWithOnErrorResumeNext() {
Answer9_ObservableActions.getObservableWithOnErrorResumeNext()
.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