mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-03-02 00:05:50 -05:00
28 lines
648 B
JavaScript
28 lines
648 B
JavaScript
|
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;
|