|
@@ -5,31 +5,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
});
|
|
|
exports.composeReducers = exports.subReducer = exports.cowValueModel = undefined;
|
|
|
|
|
|
-var _cowValueModel2 = require("./cow-value-model");
|
|
|
+var _cowValueModel = require("./cow-value-model");
|
|
|
|
|
|
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
|
|
|
|
-exports.cowValueModel = _cowValueModel2.cowValueModel;
|
|
|
+exports.cowValueModel = _cowValueModel.cowValueModel;
|
|
|
var subReducer = exports.subReducer = function subReducer(key, reducer) {
|
|
|
for (var _len = arguments.length, otherKeys = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
|
otherKeys[_key - 2] = arguments[_key];
|
|
|
}
|
|
|
|
|
|
- var _cowValueModel = (0, _cowValueModel2.cowValueModel)(key),
|
|
|
- getValue = _cowValueModel.get,
|
|
|
- setValue = _cowValueModel.set,
|
|
|
+ var value = (0, _cowValueModel.cowValueModel)(key),
|
|
|
otherParts = otherKeys.map(function (each) {
|
|
|
- return (0, _cowValueModel2.cowValueModel)(each).get;
|
|
|
+ return (0, _cowValueModel.cowValueModel)(each);
|
|
|
});
|
|
|
|
|
|
return function (state, action) {
|
|
|
- var newSubState = reducer.apply(undefined, [getValue(state), action].concat(_toConsumableArray(otherParts.map(function (getValue) {
|
|
|
- return getValue(state);
|
|
|
+ var newSubState = reducer.apply(undefined, [value(state), action].concat(_toConsumableArray(otherParts.map(function (value) {
|
|
|
+ return value(state);
|
|
|
}))));
|
|
|
if (typeof newSubState === "undefined") {
|
|
|
throw new Error("The '" + key + "' reducer must not return undefined.");
|
|
|
}
|
|
|
- return setValue(state, newSubState);
|
|
|
+ return value(state, newSubState);
|
|
|
};
|
|
|
};
|
|
|
|