Skip to content

Instantly share code, notes, and snippets.

@TheComfyChair
Created April 3, 2017 13:14
Show Gist options
  • Save TheComfyChair/f11badbfe5cb094089a25b4de9d06c70 to your computer and use it in GitHub Desktop.
Save TheComfyChair/f11badbfe5cb094089a25b4de9d06c70 to your computer and use it in GitHub Desktop.
import {
call,
put,
cancelled,
} from 'redux-saga/effects';
import {
REQUEST_BUTTER_ERROR,
} from './constants';
import { api } from './someApi';
function* fetchCarStatus(requestCancelToken = cancelToken()) {
try {
const response = yield call(apiCall, {
cancelToken: requestCancelToken.token,
});
put(someAction(someMapping(response)));
} catch (error) {
put({ type: REQUEST_BUTTER_ERROR, payload: error });
} finally {
if (yield cancelled()) {
requestCancelToken.cancel();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment