take( pattern | matcher | channel )
Stop generator until matching action is dispatched
function* saga() {
const action = yield take('SOME_ACTION');
}
put( action )
Dispatch action and continue
function* saga() {
yield put({
type: 'SOME_ACTION',
});
}
call( saga | function , ...args )
Run saga or function and wait until completed
function* saga() {
yield call(fn, ...args);
}
fork( saga | function , ...args )
Run saga or function without waiting
function* saga() {
yield fork(fn, ...args);
}
select( selector , ...args )
Return state from redux store
function* saga() {
const state = yield select();
}
[ ...effects ]
Run effects and wait until all have completed
function* saga() {
const results = yield [
call(fn, ...args),
take('SOME_ACTION'),
take('OTHER_ACTION'),
];
}
race({ ...effects })
Run effects and wait until one has completed
function* saga() {
const results = yield race({
response: call(fn, ...args),
someAction: take('SOME_ACTION'),
otherAction: take('OTHER_ACTION'),
});
}
takeEvery( pattern | matcher , saga , ...args )
Run saga for each matching action
function* saga() {
yield takeEvery('SOME_ACTION', someSaga, ...args);
}
takeLatest( pattern | matcher , saga , ...args )
Run saga for most recent matching action
function* saga() {
yield takeLatest('SOME_ACTION', someSaga, ...args);
}