Skip to content

Instantly share code, notes, and snippets.

@chodorowicz
Last active July 13, 2016 14:40
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 chodorowicz/b8fedd405dcb1f54b4864902ed7d68a7 to your computer and use it in GitHub Desktop.
Save chodorowicz/b8fedd405dcb1f54b4864902ed7d68a7 to your computer and use it in GitHub Desktop.
redux saga
/**
* shortcut for fork (no need to define separate watch functions
* https://yelouafi.github.io/redux-saga/docs/basics/UsingSagaHelpers.html
*/
import { takeLatest } from 'redux-saga'
import { fork } from 'redux-saga/effects'
function* fetchUsers(action) { }
function* createUser(action) { }
// will start takeEvery in the background and provide it with the subsequent arguments
export default function* rootSaga() {
yield fork(takeLatest, 'FETCH_USERS', fetchUsers)
yield fork(takeLatest, 'CREATE_USER', createUser)
}
/** use select effect to get state */
import { select } from 'redux-saga/effects';
export function* selectBuyer(action) {
const accessToken = yield select((state) => state.user.accessToken);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment