Skip to content

Instantly share code, notes, and snippets.

@Calvin-Huang
Last active September 9, 2017 19:50
Show Gist options
  • Save Calvin-Huang/df5f4cecc2e98343c48a7d317ab69891 to your computer and use it in GitHub Desktop.
Save Calvin-Huang/df5f4cecc2e98343c48a7d317ab69891 to your computer and use it in GitHub Desktop.
// Retry 5 times without waiting
const inputEpic = (action$) =>
action$.ofType('INPUT_CHANGED')
.retry(5)
...
// Retry 5 times with waiting for 2 seconds
const inputEpic = (action$) =>
action$.ofType('INPUT_CHANGED')
.retryWhen(function(errors) {
return errors
.delay(2000)
.scan((errorCount, err) => {
if(errorCount >= 5) {
throw err;
}
return errorCount + 1;
}, 0);
})
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment