Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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