Created
November 20, 2015 22:26
-
-
Save michaltakac/c0178317648b96ebad4a to your computer and use it in GitHub Desktop.
Meteorboard - UI reducer
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 * as actions from './actions'; | |
import {Record} from 'immutable'; | |
const InitialState = Record({ | |
isSideMenuOpen: false | |
}); | |
const initialState = new InitialState; | |
export default function uiReducer(state = initialState, action) { | |
if (!(state instanceof InitialState)) return initialState; | |
switch (action.type) { | |
case actions.ON_SIDE_MENU_CHANGE: { | |
const {isOpen} = action.payload; | |
return state.set('isSideMenuOpen', !isOpen); | |
} | |
case actions.TOGGLE_SIDE_MENU: | |
return state.update('isSideMenuOpen', isSideMenuOpen => !isSideMenuOpen); | |
} | |
return state; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment