scratch-www/src/redux/reducer.js

26 lines
1 KiB
JavaScript
Raw Normal View History

const combineReducers = require('redux').combineReducers;
const defaults = require('lodash.defaults');
2016-03-18 11:51:22 -04:00
const messageCountReducer = require('./message-count.js').messageCountReducer;
const permissionsReducer = require('./permissions.js').permissionsReducer;
const sessionReducer = require('./session.js').sessionReducer;
2016-03-22 14:43:07 -04:00
/**
* Returns a combined reducer to be used for a page in `render.jsx`.
* The reducers used globally are applied here - session and permissions
* - and any reducers specific to the page should be passed into
* `render()` as an object (which will then be passed to the function
* below).
* @param {object} opts key/value where the key is the name of the
* redux state, value is the reducer function.
* @return {object} combined reducer to be used in the redux store
*/
module.exports = opts => {
opts = opts || {};
return combineReducers(defaults(opts, {
session: sessionReducer,
permissions: permissionsReducer,
messageCount: messageCountReducer
}));
};