New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

oo-redux-utils

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oo-redux-utils - npm Package Compare versions

Comparing version 1.21.2 to 1.22.0

lib/AbstractDispatchingAction.js

99

lib/AbstractAction.js

@@ -8,18 +8,2 @@ "use strict";

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(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -36,3 +20,3 @@

function () {
function AbstractAction(stateNamespace, dispatchAction) {
function AbstractAction(stateNamespace) {
_classCallCheck(this, AbstractAction);

@@ -44,6 +28,3 @@

_defineProperty(this, "dispatchAction_", void 0);
this.stateNamespace = stateNamespace;
this.dispatchAction_ = dispatchAction;
this.actionClassName = this.constructor.name;

@@ -53,83 +34,7 @@ }

_createClass(AbstractAction, [{
key: "getBaseActionClass",
value: function getBaseActionClass() {
throw new Error('Abstract method called');
}
}, {
key: "performAction",
value: function performAction(action, currentState) {
if (action.getBaseActionClass() === this.getBaseActionClass()) {
return action.performActionAndReturnNewState(currentState);
} else {
throw new Error('Cannot perform actions from different base class');
}
return action.performActionAndReturnNewState(currentState);
}
}, {
key: "dispatchAction",
value: function dispatchAction(action) {
if (action.getBaseActionClass() === this.getBaseActionClass() && action.getStateNamespace() === this.stateNamespace) {
throw new Error('Cannot dispatch actions from same base class');
}
if (this.dispatchAction_) {
this.dispatchAction_(action);
} else {
throw new Error('dispatchAction must be given as constructor parameter');
}
}
}, {
key: "dispatchAsyncAction",
value: function dispatchAsyncAction(action) {
if (this.dispatchAction_) {
this.dispatchAction_(action);
} else {
throw new Error('dispatchAction must be given as constructor parameter');
}
}
}, {
key: "dispatchActionWithDi",
value: function dispatchActionWithDi(diContainer, actionClass) {
var _this = this;
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.dispatchAsyncAction(action);
});
}
}, {
key: "dispatchActions",
value: function dispatchActions(actions) {
var _this2 = this;
actions.forEach(function (action) {
return _this2.dispatchAction(action);
});
}
}, {
key: "dispatchActionsWithDi",
value: function dispatchActionsWithDi(diContainer, actionDefs) {
var _this3 = this;
actionDefs.forEach(function (actionDef) {
if (Array.isArray(actionDef)) {
var _actionDef = _slicedToArray(actionDef, 2),
actionClass = _actionDef[0],
_args = _actionDef[1];
if (Array.isArray(_args)) {
_this3.dispatchActionWithDi.apply(_this3, [diContainer, actionClass].concat(_toConsumableArray(_args)));
} else {
_this3.dispatchActionWithDi(diContainer, actionClass, _args);
}
} else if (typeof actionDef === 'function') {
_this3.dispatchActionWithDi(diContainer, actionDef);
} else {
_this3.dispatchAction(actionDef);
}
});
}
}, {
key: "performActionAndReturnNewState",

@@ -136,0 +41,0 @@ value: function performActionAndReturnNewState(currentState) {

@@ -16,3 +16,3 @@ "use strict";

var ControllerFactory = function ControllerFactory(dispatch) {
var ControllerFactory = function ControllerFactory(dispatch, stateNamespace) {
_classCallCheck(this, ControllerFactory);

@@ -22,3 +22,6 @@

_defineProperty(this, "stateNamespace", void 0);
this.dispatchAction = _DispatchUtils.default.createActionDispatcher(dispatch);
this.stateNamespace = stateNamespace;
};

@@ -25,0 +28,0 @@

@@ -18,2 +18,8 @@ "use strict";

});
Object.defineProperty(exports, "AbstractDispatchingAction", {
enumerable: true,
get: function get() {
return _AbstractDispatchingAction.default;
}
});
Object.defineProperty(exports, "DispatchUtils", {

@@ -42,2 +48,4 @@ enumerable: true,

var _AbstractDispatchingAction = _interopRequireDefault(require("./AbstractDispatchingAction"));
var _DispatchUtils = _interopRequireDefault(require("./DispatchUtils"));

@@ -44,0 +52,0 @@

@@ -12,2 +12,4 @@ "use strict";

var _AbstractDispatchingAction = _interopRequireDefault(require("./AbstractDispatchingAction"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -31,11 +33,7 @@

function _createStateReducer(initialState, actionBaseClass, stateNamespace) {
if (actionBaseClass === _AbstractAction.default) {
throw new Error('actionBaseClass must be a class extended from AbstractAction');
}
function _createStateReducer(initialState, actionBaseClasses, stateNamespace) {
return function () {
var currentState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
var action = arguments.length > 1 ? arguments[1] : undefined;
return action.type instanceof actionBaseClass && action.type.getStateNamespace() === stateNamespace ? action.type.performActionAndReturnNewState(currentState) : currentState;
return (action.type instanceof actionBaseClasses[0] || actionBaseClasses[1] && action.type instanceof actionBaseClasses[1]) && action.type.getStateNamespace() === stateNamespace ? action.type.performActionAndReturnNewState(currentState) : currentState;
};

@@ -68,4 +66,4 @@ }

key: "createStateReducer",
value: function createStateReducer(initialState, actionBaseClass) {
return _createStateReducer(initialState, actionBaseClass, '');
value: function createStateReducer(initialState, actionBaseClasses) {
return _createStateReducer(initialState, actionBaseClasses, '');
} // noinspection JSUnusedGlobalSymbols

@@ -75,4 +73,4 @@

key: "createNamespacedStateReducer",
value: function createNamespacedStateReducer(initialState, actionBaseClass, stateNamespace) {
return _createStateReducer(initialState, actionBaseClass, stateNamespace);
value: function createNamespacedStateReducer(initialState, actionBaseClasses, stateNamespace) {
return _createStateReducer(initialState, actionBaseClasses, stateNamespace);
}

@@ -79,0 +77,0 @@ }]);

{
"name": "oo-redux-utils",
"version": "1.21.2",
"version": "1.22.0",
"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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc