Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let RetryStrategy = attempts => attempts
- .zip(Observable.range(1, 4))
- .flatMap(([error, i]) => {
- if (i > 3) {
- return Observable.throw('Network error occured')
- }
- return Observable.timer(i * 1000)
- })
- export const deleteSurveyQuestionEpic = (action$, {getState, dispatch}) =>
- action$.ofType('MY_ACTION')
- .switchMap(
- action => ajax.delete(`myURL`)
- .map(res => res.response)
- .flatMap(response => {
- console.log(response) // <-- returns null
- return arrayRemove('formName', 'questions', 1) // <-- redux-form action-creator
- })
- .retryWhen(RetryStrategy)
- .takeUntil(action$.ofType('MY_CANCEL_ACTION'))
- .catch((e) => {
- return Observable.of(
- errorSurvey((e.xhr && `Error ${e.xhr.statusText}: ${e.xhr.statusText}`) || 'Network error occured')
- )
- })
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement