Skip to content

Instantly share code, notes, and snippets.

@jtomaszewski
Last active July 9, 2019 07:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jtomaszewski/0d4b97099fed9f703b4d900086618096 to your computer and use it in GitHub Desktop.
Save jtomaszewski/0d4b97099fed9f703b4d900086618096 to your computer and use it in GitHub Desktop.
// Fetch results when:
// - page is changed (immediately after):
// - "sort by" filter is changed (immediately after),
// - search query is changed (after 500 ms debounce),
// - filters are changed (after 300 ms debounce)
const refetchResultsEpic = action$ => {
return Observable.merge(
action$.ofType(CHANGE_QUERY).debounceTime(500),
action$.ofType(CHANGE_FILTERS).debounceTime(300),
action$.ofType(CHANGE_PAGE),
action$.ofType(CHANGE_SORT_BY),
)
.mapTo({ type: FETCH_RESULTS });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment