Skip to content

Instantly share code, notes, and snippets.

@karlbright
Created December 2, 2015 04:50
Show Gist options
  • Save karlbright/9b542a7c27cb744a4c1b to your computer and use it in GitHub Desktop.
Save karlbright/9b542a7c27cb744a4c1b to your computer and use it in GitHub Desktop.
import Immutable from 'immutable'
import { GET_VIDEOS, GET_VIDEO } from 'actions/videos'
export default function videos (state = Immutable.Map(), action) {
switch (action.type) {
case GET_VIDEO:
return state.updateIn([action.meta.id], Immutable.Map(), video => {
if (action.pending) return video.set('loading', true)
if (action.error) return video.set('loading', false)
return Immutable.fromJS(action.payload).set('loading', false)
})
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment