Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Created November 10, 2018 10:31
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/740536369b7482bddb0193e4ee81f152 to your computer and use it in GitHub Desktop.
Save productioncoder/740536369b7482bddb0193e4ee81f152 to your computer and use it in GitHub Desktop.
Youtube in React: video details for watch component
function* fetchVideoDetails(responses) {
const searchListResponse = responses.find(response => response.result.kind === SEARCH_LIST_RESPONSE);
const relatedVideoIds = searchListResponse.result.items.map(relatedVideo => relatedVideo.id.videoId);
const requests = relatedVideoIds.map(relatedVideoId => {
return buildVideoDetailRequest.bind(null, relatedVideoId);
});
try {
const responses = yield all(requests.map(fn => call(fn)));
yield put(watchActions.videoDetails.success(responses));
} catch (error) {
yield put(watchActions.videoDetails.failure(error));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment