Last active
June 21, 2019 21:21
-
-
Save shapkarin/bc473e4d3f944a57ecb9b1ab2e3dc719 to your computer and use it in GitHub Desktop.
redux-saga fetch worker 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
import { fork, debounce } from 'redux-saga/effects'; | |
import fetch from './fetch'; | |
import { fetchSomeInfo } from './someApi'; | |
import { | |
loadSomeInfoStart, | |
loadSomeInfoSuccess, | |
loadSomeInfoError | |
} from './actions'; | |
function* autocompleteExample (action){ | |
yield fork(fetch, { | |
action, | |
method: fetchSomeInfo, | |
start: loadSomeInfoStart, | |
success: loadSomeInfoSuccess, | |
error: loadSomeInfoError | |
}); | |
} | |
function* mySaga () { | |
yield debounce(300, 'INPUT_CHANGED', autocompleteExample); | |
} |
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
/* | |
not it's npm package | |
https://www.npmjs.com/package/saga-fetch | |
https://github.com/shapkarin/saga-fetch | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment