Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active November 10, 2018 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save productioncoder/9a3a51fb855985e0797ccd62c5e4eacd to your computer and use it in GitHub Desktop.
Save productioncoder/9a3a51fb855985e0797ccd62c5e4eacd to your computer and use it in GitHub Desktop.
Youtube in React: consecutive requests in saga
export function* fetchWatchDetails(videoId) {
let requests = [
buildVideoDetailRequest.bind(null, videoId),
buildRelatedVideosRequest.bind(null, videoId),
];
try {
const responses = yield all(requests.map(fn => call(fn)));
yield put(watchActions.details.success(responses));
yield call (fetchVideoDetails, responses);
} catch (error) {
yield put(watchActions.details.failure(error));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment