Created
June 27, 2016 12:55
-
-
Save skellock/78219bc704250bf6a1b1992d995f9130 to your computer and use it in GitHub Desktop.
This file contains hidden or 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, call, select } from 'redux-saga/effects' | |
export function acquireDataFromSomewhere (numberOfThings) { | |
return new Promise((resolve, reject) => { | |
resolve(`here are ${numberOfThings} things`) | |
}) | |
} | |
// Fires when we see TIME_TO_SHINE come through. | |
// Its pretty random what we do here. | |
// The point is to really show how tests work. | |
export default function * (action) { | |
// step 1 | |
yield put({ type: 'INCREMENT' }) | |
// step 2 | |
const state = yield select() | |
const currentCounterValue = state.counter.value | |
// step 3 | |
const data = yield call( | |
acquireDataFromSomewhere, | |
currentCounterValue | |
) | |
// step 4 | |
yield put({type: 'SAVE_DATA', randomPieceOfData: data}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment