Last active
November 8, 2018 21:17
-
-
Save productioncoder/8ea5ce309504ad176f2d066b93891196 to your computer and use it in GitHub Desktop.
Youtube robust watch details reducer
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 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