Created
February 12, 2018 13:57
-
-
Save grundmanise/6db63b3edd956c9a796904317a664a4c to your computer and use it in GitHub Desktop.
RXJS Ajax example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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