Last active
April 6, 2016 23:15
-
-
Save emilong/c1e108a97558ab627fd908255e90e105 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 { takeLatest } from 'redux-saga' | |
import { call, put } from 'redux-saga/effects' | |
function* fetchThing(action) { | |
try { | |
const thing = yield call(fetch, `https://api.example.com/things/${action.payload.thingId}`); | |
yield put({ type: "THING_RECEIVED", thing }); | |
} catch(err) { | |
yield put({ type: "THING_GETTING_FAILED", message: err.message}); | |
} | |
} | |
export function* thingRequestSaga() { | |
yield* takeLatest("THING_GET_REQUESTED", fetchThing); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment