Skip to content

Instantly share code, notes, and snippets.

@Calvin-Huang
Created September 6, 2017 03:17
Show Gist options
  • Save Calvin-Huang/dbfa4b979b422d541a669314eef26ada to your computer and use it in GitHub Desktop.
Save Calvin-Huang/dbfa4b979b422d541a669314eef26ada to your computer and use it in GitHub Desktop.
// Throttling
const inputEpic = (action$) =>
action$.ofType('INPUT_CHANGED')
.throttleTime(500)
...
// Deboucing
const inputEpic = (action$) =>
action$.ofType('INPUT_CHANGED')
.debounceTime(500)
...
// 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 >= 2) {
throw err;
}
return errorCount + 1;
}, 0);
})
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment