Skip to content

Instantly share code, notes, and snippets.

@productioncoder productioncoder/video.js
Last active Nov 8, 2018

Embed
What would you like to do?
Youtube robust watch details reducer
function reduceWatchDetails(responses, prevState) {
const videoDetailResponse = responses.find(r => r.result.kind === 'youtube#videoListResponse');
// we know that items will only have one element
// because we explicitly asked for a video with a specific id
const video = videoDetailResponse.result.items[0];
return {
...prevState,
byId: {
...prevState.byId,
[video.id]: video
},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.