Created
December 2, 2015 04:50
-
-
Save karlbright/9b542a7c27cb744a4c1b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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