scratch-www/src/redux/reducer.js

28 lines
648 B
JavaScript
Raw Normal View History

2016-03-18 11:51:22 -04:00
var combineReducers = require('redux').combineReducers;
var actionTypes = require('./actions.js').types;
var sessionReducer = function (state, action) {
// Reducer for handling changes to session state
if (typeof state === 'undefined') {
state = {};
}
switch (action.type) {
case actionTypes.SET_SESSION:
return action.session;
case actionTypes.SET_SESSION_ERROR:
// TODO: do something with action.error
return state;
default:
return state;
}
};
var appReducer = combineReducers({
session: sessionReducer
});
module.exports = appReducer;