Last active
July 13, 2016 14:40
-
-
Save chodorowicz/b8fedd405dcb1f54b4864902ed7d68a7 to your computer and use it in GitHub Desktop.
redux saga
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
/** | |
* 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