My use case is to compare what is observed with the reduction actions of success and failure. I am making a network call (with a function that makes a promise), if it succeeds, I need to direct the action to succeed if it is not completed, than the action with the error. Compliance itself must continue. For all that I could perform the search, RxJS has no mechanism for this error correction and restarting the original. In my code there is the following solution which does not suit me:
error$ = new Rx.Subject(); searchResultAction$ = search$ .flatMap(getSearchResultsPromise) .map((resuls) => { return { type: 'SUCCESS_ACTION', payload: { results } } }) .retryWhen((err$) => { return err$ .pluck('query') .do(error$.onNext.bind(error$)); }); searchErrorAction$ .map((query) => { return { type: 'ERROR_ACTION', payload: { query, message: 'Error while retrieving data' } } }); action$ = Observable .merge( searchResultAction$, searchErrorAction$ ) .doOnError(err => console.error('Ignored error: ', err)) .retry(); action$.subscribe(dispatch);
ie I create a topic and insert errors into this topic and create an Observable from errors.
Is there a better alternative for this in RxJS that I am missing? Basically, I want to issue a notification of an error that has occurred, and then continue with what Observable is already running.
source share