[d24f17c] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 |
|
---|
| 7 | var _immutable = require('immutable');
|
---|
| 8 |
|
---|
| 9 | var _immutable2 = _interopRequireDefault(_immutable);
|
---|
| 10 |
|
---|
| 11 | var _utilities = require('./utilities');
|
---|
| 12 |
|
---|
| 13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
| 14 |
|
---|
| 15 | exports.default = function (reducers) {
|
---|
| 16 | var getDefaultState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _immutable2.default.Map;
|
---|
| 17 |
|
---|
| 18 | var reducerKeys = Object.keys(reducers);
|
---|
| 19 |
|
---|
| 20 | // eslint-disable-next-line space-infix-ops
|
---|
| 21 | return function () {
|
---|
| 22 | var inputState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getDefaultState();
|
---|
| 23 | var action = arguments[1];
|
---|
| 24 |
|
---|
| 25 | // eslint-disable-next-line no-process-env
|
---|
| 26 | if (process.env.NODE_ENV !== 'production') {
|
---|
| 27 | var warningMessage = (0, _utilities.getUnexpectedInvocationParameterMessage)(inputState, reducers, action);
|
---|
| 28 |
|
---|
| 29 | if (warningMessage) {
|
---|
| 30 | // eslint-disable-next-line no-console
|
---|
| 31 | console.error(warningMessage);
|
---|
| 32 | }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | return inputState.withMutations(function (temporaryState) {
|
---|
| 36 | reducerKeys.forEach(function (reducerName) {
|
---|
| 37 | var reducer = reducers[reducerName];
|
---|
| 38 | var currentDomainState = temporaryState.get(reducerName);
|
---|
| 39 | var nextDomainState = reducer(currentDomainState, action);
|
---|
| 40 |
|
---|
| 41 | (0, _utilities.validateNextState)(nextDomainState, reducerName, action);
|
---|
| 42 |
|
---|
| 43 | temporaryState.set(reducerName, nextDomainState);
|
---|
| 44 | });
|
---|
| 45 | });
|
---|
| 46 | };
|
---|
| 47 | };
|
---|
| 48 |
|
---|
| 49 | module.exports = exports['default'];
|
---|
| 50 | //# sourceMappingURL=combineReducers.js.map |
---|