Youtube in React: video details for watch component
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
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