oo-redux-utils
Advanced tools
Comparing version 1.8.5 to 1.8.6
@@ -8,2 +8,16 @@ "use strict"; | ||
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } | ||
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
@@ -72,6 +86,10 @@ | ||
key: "dispatchActionWithDi", | ||
value: function dispatchActionWithDi(diContainer, actionClass, params) { | ||
value: function dispatchActionWithDi(diContainer, actionClass) { | ||
var _this = this; | ||
diContainer.create(actionClass, params).then(function (action) { | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
diContainer.create(actionClass, {}, args).then(function (action) { | ||
return _this.dispatchAction(action); | ||
@@ -86,3 +104,7 @@ }); | ||
actions.forEach(function (action) { | ||
return _this2.dispatchAction(action); | ||
if (typeof action === 'function') { | ||
_this2.dispatchAction(new action()); | ||
} else { | ||
_this2.dispatchAction(action); | ||
} | ||
}); | ||
@@ -99,7 +121,23 @@ } | ||
actionClass = _actionDef[0], | ||
params = _actionDef[1]; | ||
_args = _actionDef[1]; | ||
_this3.dispatchActionWithDi(diContainer, actionClass, params); | ||
if (actionDef.toString().includes('dispatchAction')) { | ||
if (Array.isArray(_args)) { | ||
_this3.dispatchActionWithDi.apply(_this3, [diContainer, actionClass].concat(_toConsumableArray(_args))); | ||
} else { | ||
_this3.dispatchActionWithDi(diContainer, actionClass, _args); | ||
} | ||
} else { | ||
if (Array.isArray(_args)) { | ||
_this3.dispatchAction(_construct(actionClass, _toConsumableArray(_args))); | ||
} else { | ||
_this3.dispatchAction(new actionClass(_args)); | ||
} | ||
} | ||
} else if (typeof actionDef === 'function') { | ||
_this3.dispatchActionWithDi(diContainer, actionDef[0]); | ||
if (actionDef.toString().includes('dispatchAction')) { | ||
_this3.dispatchActionWithDi(diContainer, actionDef); | ||
} else { | ||
_this3.dispatchAction(new actionDef()); | ||
} | ||
} else { | ||
@@ -106,0 +144,0 @@ _this3.dispatchAction(actionDef); |
@@ -14,2 +14,6 @@ "use strict"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
@@ -21,6 +25,2 @@ | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
@@ -67,7 +67,15 @@ | ||
key: "dispatchActionWithDi", | ||
value: function dispatchActionWithDi(actionClass, params) { | ||
value: function dispatchActionWithDi(actionClass) { | ||
var _this = this; | ||
if (this.diContainer) { | ||
this.diContainer.create(actionClass, params).then(function (action) { | ||
var _this$diContainer; | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
(_this$diContainer = this.diContainer).create.apply(_this$diContainer, [actionClass, { | ||
stateNamespace: this.stateNamespace | ||
}].concat(args)).then(function (action) { | ||
return _this.dispatchAction(action); | ||
@@ -94,6 +102,12 @@ }); | ||
accumulatedValue[dispatchFnName] = function () { | ||
var _this2$diContainer; | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
} | ||
return (// $FlowFixMe | ||
_this2.diContainer.create(ActionClass, _objectSpread({}, arguments.length <= 0 ? undefined : arguments[0], { | ||
(_this2$diContainer = _this2.diContainer).create.apply(_this2$diContainer, [ActionClass, { | ||
stateNamespace: _this2.stateNamespace | ||
})).then(function (action) { | ||
}].concat(args)).then(function (action) { | ||
return _this2.dispatchAction(action); | ||
@@ -109,4 +123,4 @@ }) | ||
accumulatedValue[dispatchFnName] = function () { | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { | ||
args[_key3] = arguments[_key3]; | ||
} | ||
@@ -118,4 +132,4 @@ | ||
accumulatedValue[dispatchFnName] = function () { | ||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
args[_key2] = arguments[_key2]; | ||
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { | ||
args[_key4] = arguments[_key4]; | ||
} | ||
@@ -122,0 +136,0 @@ |
{ | ||
"name": "oo-redux-utils", | ||
"version": "1.8.5", | ||
"version": "1.8.6", | ||
"description": "Utility functions for Object-oriented Redux", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
74399
517