Created
June 10, 2018 11:51
-
-
Save kiok46/d01f0931fe38662826e2594d5b6fb9a1 to your computer and use it in GitHub Desktop.
Redux, Reactotron, Actions, Reducers and Sagas (2)
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 { put, take, fork } from 'redux-saga/effects'; | |
import { TEXT_CHANGED, TEXT_CHANGED_SUCCESS } from '../types'; | |
// **************** | |
// WORKERS | |
// **************** | |
function* workerTextChanged(action) { | |
console.log(action); | |
// {type: "text_changed", payload: "-_-"} | |
try { | |
yield put({ type: TEXT_CHANGED_SUCCESS, text: action.payload }); | |
} catch (e) { | |
console.log('Error', e); | |
} | |
} | |
// **************** | |
// WATCHERS | |
// **************** | |
export function* watcherTextChanged() { | |
while (true) { | |
const action = yield take(TEXT_CHANGED); | |
yield fork(workerTextChanged, action); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment