Skip to content

Instantly share code, notes, and snippets.

@grundmanise
Created February 12, 2018 13:57
Show Gist options
  • Save grundmanise/6db63b3edd956c9a796904317a664a4c to your computer and use it in GitHub Desktop.
Save grundmanise/6db63b3edd956c9a796904317a664a4c to your computer and use it in GitHub Desktop.
RXJS Ajax example
const searchEpic = (action$, store) =>
action$.ofType('SEARCH')
.map(action => action.payload)
.debounceTime(400)
.switchMap(query =>
ajax.post('http://localhost:8080/search', {query})
.takeUntil(action$.ofType('CANCEL_SEARCH')))
.map(res => ({type: 'SEARCH_DATA', result: res.response}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment