Skip to content

Instantly share code, notes, and snippets.

@tricoder42
Created June 13, 2017 07:50
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 tricoder42/b0f7981043861e3e5019b666c7e55d01 to your computer and use it in GitHub Desktop.
Save tricoder42/b0f7981043861e3e5019b666c7e55d01 to your computer and use it in GitHub Desktop.
2017/06/13 [Medium] redux-saga factories and decorators
function ApiGetUser({ id }) {
return fetch(url`/user/${id}`)
}
// Just an example. Action creators are usually
// created using `createAction` from `redux-actions`
const getUser = {
request: (id) => ({
type: 'USER_GET@REQUEST',
payload: { id }
}),
response: (user) => ({
type: 'USER_GET@RESPONSE',
payload: user
})
}
const fetchUser = fetchSaga(getUser, ApiGetUser)
export default function* () {
yield takeEvery(getUser.request, fetchUser)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment