Last active
November 10, 2018 18:54
-
-
Save productioncoder/9a3a51fb855985e0797ccd62c5e4eacd to your computer and use it in GitHub Desktop.
Youtube in React: consecutive requests in saga
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
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