Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@modern-js-reduck/plugin-effects

Package Overview
Dependencies
Maintainers
6
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@modern-js-reduck/plugin-effects - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

dist/js/modern/__test__/handleEffect.test.js

10

dist/js/modern/__test__/index.test.js

@@ -1,7 +0,3 @@

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { createStore, model } from '@modern-js-reduck/store';

@@ -18,3 +14,3 @@ import logger from 'redux-logger';

load: {
fulfilled: (state, payload) => _objectSpread(_objectSpread({}, state), {}, {
fulfilled: (state, payload) => _extends({}, state, {
items: payload

@@ -24,3 +20,3 @@ })

loadWithParams: {
fulfilled: (state, payload) => _objectSpread(_objectSpread({}, state), {}, {
fulfilled: (state, payload) => _extends({}, state, {
items: payload

@@ -27,0 +23,0 @@ })

@@ -1,4 +0,4 @@

// eslint-disable-next-line filenames/match-exported
import plugin from "./plugin";
export { plugin };
import handleEffect from "./utils/handleEffect";
export { plugin, handleEffect };
export default plugin;

@@ -1,7 +0,3 @@

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { createPlugin } from '@modern-js-reduck/store';

@@ -12,3 +8,3 @@ import { createPromise } from 'redux-promise-middleware';

/**
* Generare dispatch action from effects definations.
* Generate dispatch action from effects definitions.
*/

@@ -28,3 +24,3 @@ const createDispatchActionsFromEffects = (store, name, effects, setDispatchAction) => {

}); // Handled by promise middleware or redux thunk
// Otherwise, do not dispatch action, just exec the effect fuction.
// Otherwise, do not dispatch action, just exec the effect function.

@@ -52,3 +48,3 @@

config(storeConfig) {
return _objectSpread(_objectSpread({}, storeConfig), {}, {
return _extends({}, storeConfig, {
middlewares: [...(storeConfig.middlewares || []), createPromise({

@@ -55,0 +51,0 @@ promiseTypeDelimiter: '/'

@@ -1,18 +0,7 @@

"use strict";
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _store = require("@modern-js-reduck/store");
var _reduxLogger = _interopRequireDefault(require("redux-logger"));
var _2 = require("..");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const todoModel = (0, _store.model)('todo').define((_, {
import { createStore, model } from '@modern-js-reduck/store';
import logger from 'redux-logger';
import { plugin } from '..';
const todoModel = model('todo').define((_, {
use

@@ -25,3 +14,3 @@ }) => ({

load: {
fulfilled: (state, payload) => _objectSpread(_objectSpread({}, state), {}, {
fulfilled: (state, payload) => _extends({}, state, {
items: payload

@@ -31,3 +20,3 @@ })

loadWithParams: {
fulfilled: (state, payload) => _objectSpread(_objectSpread({}, state), {}, {
fulfilled: (state, payload) => _extends({}, state, {
items: payload

@@ -57,5 +46,5 @@ })

test('promise middleware', async () => {
const store = (0, _store.createStore)({
plugins: [_2.plugin],
middlewares: [_reduxLogger.default]
const store = createStore({
plugins: [plugin],
middlewares: [logger]
});

@@ -69,5 +58,5 @@ const [, actions] = store.use(todoModel);

test('promise middleware params', async () => {
const store = (0, _store.createStore)({
plugins: [_2.plugin],
middlewares: [_reduxLogger.default]
const store = createStore({
plugins: [plugin],
middlewares: [logger]
});

@@ -81,5 +70,5 @@ const [, actions] = store.use(todoModel);

test('thunk middleware', () => {
const store = (0, _store.createStore)({
plugins: [_2.plugin],
middlewares: [_reduxLogger.default]
const store = createStore({
plugins: [plugin],
middlewares: [logger]
});

@@ -86,0 +75,0 @@ const [, actions] = store.use(todoModel);

@@ -1,20 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
Object.defineProperty(exports, "plugin", {
enumerable: true,
get: function () {
return _plugin.default;
}
});
var _plugin = _interopRequireDefault(require("./plugin"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-next-line filenames/match-exported
var _default = _plugin.default;
exports.default = _default;
import plugin from "./plugin";
import handleEffect from "./utils/handleEffect";
export { plugin, handleEffect };
export default plugin;

@@ -1,24 +0,9 @@

"use strict";
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
import { createPlugin } from '@modern-js-reduck/store';
import { createPromise } from 'redux-promise-middleware';
import thunk from 'redux-thunk';
var _store = require("@modern-js-reduck/store");
var _reduxPromiseMiddleware = require("redux-promise-middleware");
var _reduxThunk = _interopRequireDefault(require("redux-thunk"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/**
* Generare dispatch action from effects definations.
* Generate dispatch action from effects definitions.
*/

@@ -38,3 +23,3 @@ const createDispatchActionsFromEffects = (store, name, effects, setDispatchAction) => {

}); // Handled by promise middleware or redux thunk
// Otherwise, do not dispatch action, just exec the effect fuction.
// Otherwise, do not dispatch action, just exec the effect function.

@@ -60,8 +45,8 @@

const plugin = (0, _store.createPlugin)(context => ({
const plugin = createPlugin(context => ({
config(storeConfig) {
return _objectSpread(_objectSpread({}, storeConfig), {}, {
middlewares: [...(storeConfig.middlewares || []), (0, _reduxPromiseMiddleware.createPromise)({
return _extends({}, storeConfig, {
middlewares: [...(storeConfig.middlewares || []), createPromise({
promiseTypeDelimiter: '/'
}), _reduxThunk.default]
}), thunk]
});

@@ -95,3 +80,2 @@ },

}));
var _default = plugin;
exports.default = _default;
export default plugin;

@@ -1,157 +0,70 @@

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
import _regeneratorRuntime from "@babel/runtime/regenerator";
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import _extends from "@babel/runtime/helpers/esm/extends";
import { createStore, model } from '@modern-js-reduck/store';
import logger from 'redux-logger';
import { plugin } from '..';
var todoModel = model('todo').define(function (_, _ref) {
var use = _ref.use;
return {
state: {
items: []
const todoModel = model('todo').define((_, {
use
}) => ({
state: {
items: []
},
actions: {
load: {
fulfilled: (state, payload) => _extends({}, state, {
items: payload
})
},
actions: {
load: {
fulfilled: function fulfilled(state, payload) {
return _objectSpread(_objectSpread({}, state), {}, {
items: payload
});
}
},
loadWithParams: {
fulfilled: function fulfilled(state, payload) {
return _objectSpread(_objectSpread({}, state), {}, {
items: payload
});
}
}
loadWithParams: {
fulfilled: (state, payload) => _extends({}, state, {
items: payload
})
}
},
effects: {
async load() {
return Promise.resolve(['1']);
},
effects: {
load: function load() {
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", Promise.resolve(['1']));
case 1:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
},
loadWithParams: function loadWithParams(a) {
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
return _context2.abrupt("return", Promise.resolve([a]));
async loadWithParams(a) {
return Promise.resolve([a]);
},
case 1:
case "end":
return _context2.stop();
}
}
}, _callee2);
}))();
},
loadThunk: function loadThunk() {
var actions = use(todoModel)[1];
return function () {
actions.load.fulfilled(['2']);
};
}
loadThunk() {
const actions = use(todoModel)[1];
return () => {
actions.load.fulfilled(['2']);
};
}
};
});
describe('reduck effects plugin', function () {
test('promise middleware', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
var store, _store$use, _store$use2, actions;
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
store = createStore({
plugins: [plugin],
middlewares: [logger]
});
_store$use = store.use(todoModel), _store$use2 = _slicedToArray(_store$use, 2), actions = _store$use2[1];
_context3.next = 4;
return actions.load();
case 4:
expect(store.use(todoModel)[0]).toEqual({
items: ['1']
});
case 5:
case "end":
return _context3.stop();
}
}
}, _callee3);
})));
test('promise middleware params', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
var store, _store$use3, _store$use4, actions;
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
store = createStore({
plugins: [plugin],
middlewares: [logger]
});
_store$use3 = store.use(todoModel), _store$use4 = _slicedToArray(_store$use3, 2), actions = _store$use4[1];
_context4.next = 4;
return actions.loadWithParams('dddd');
case 4:
expect(store.use(todoModel)[0]).toEqual({
items: ['dddd']
});
case 5:
case "end":
return _context4.stop();
}
}
}, _callee4);
})));
test('thunk middleware', function () {
var store = createStore({
}
}));
describe('reduck effects plugin', () => {
test('promise middleware', async () => {
const store = createStore({
plugins: [plugin],
middlewares: [logger]
});
var _store$use5 = store.use(todoModel),
_store$use6 = _slicedToArray(_store$use5, 2),
actions = _store$use6[1];
const [, actions] = store.use(todoModel);
await actions.load();
expect(store.use(todoModel)[0]).toEqual({
items: ['1']
});
});
test('promise middleware params', async () => {
const store = createStore({
plugins: [plugin],
middlewares: [logger]
});
const [, actions] = store.use(todoModel);
await actions.loadWithParams('dddd');
expect(store.use(todoModel)[0]).toEqual({
items: ['dddd']
});
});
test('thunk middleware', () => {
const store = createStore({
plugins: [plugin],
middlewares: [logger]
});
const [, actions] = store.use(todoModel);
actions.loadThunk();

@@ -158,0 +71,0 @@ expect(store.use(todoModel)[0]).toEqual({

@@ -1,4 +0,4 @@

// eslint-disable-next-line filenames/match-exported
import plugin from "./plugin";
export { plugin };
import handleEffect from "./utils/handleEffect";
export { plugin, handleEffect };
export default plugin;

@@ -1,19 +0,2 @@

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); 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 = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import _extends from "@babel/runtime/helpers/esm/extends";
import { createPlugin } from '@modern-js-reduck/store';

@@ -24,20 +7,18 @@ import { createPromise } from 'redux-promise-middleware';

/**
* Generare dispatch action from effects definations.
* Generate dispatch action from effects definitions.
*/
var createDispatchActionsFromEffects = function createDispatchActionsFromEffects(store, name, effects, setDispatchAction) {
var path = [name];
const createDispatchActionsFromEffects = (store, name, effects, setDispatchAction) => {
const path = [name];
var traverse = function traverse(_effects) {
const traverse = _effects => {
if (typeof _effects === 'function') {
var type = path.join('/').toUpperCase();
setDispatchAction(path.slice(), function () {
var value = _effects.apply(void 0, arguments);
const type = path.join('/').toUpperCase();
setDispatchAction(path.slice(), (...args) => {
const value = _effects(...args);
var dispatch = function dispatch(payload) {
return store.dispatch({
type: type,
payload: payload
});
}; // Handled by promise middleware or redux thunk
// Otherwise, do not dispatch action, just exec the effect fuction.
const dispatch = payload => store.dispatch({
type,
payload
}); // Handled by promise middleware or redux thunk
// Otherwise, do not dispatch action, just exec the effect function.

@@ -52,3 +33,3 @@

} else {
Object.keys(_effects).forEach(function (key) {
Object.keys(_effects).forEach(key => {
path.push(key);

@@ -64,32 +45,36 @@ traverse(_effects[key]);

var plugin = createPlugin(function (context) {
return {
config: function config(storeConfig) {
return _objectSpread(_objectSpread({}, storeConfig), {}, {
middlewares: [].concat(_toConsumableArray(storeConfig.middlewares || []), [createPromise({
promiseTypeDelimiter: '/'
}), thunk])
});
},
modelMount: function modelMount(_ref, _ref2) {
var modelDesc = _ref.modelDesc,
mountedModel = _ref.mountedModel;
var setDispatchAction = _ref2.setDispatchAction;
var effects = modelDesc.effects;
const plugin = createPlugin(context => ({
config(storeConfig) {
return _extends({}, storeConfig, {
middlewares: [...(storeConfig.middlewares || []), createPromise({
promiseTypeDelimiter: '/'
}), thunk]
});
},
if (!effects) {
return {
modelDesc: modelDesc,
mountedModel: mountedModel
};
}
modelMount({
modelDesc,
mountedModel
}, {
setDispatchAction
}) {
const {
effects
} = modelDesc;
createDispatchActionsFromEffects(context.store, modelDesc.name, modelDesc.effects, setDispatchAction);
if (!effects) {
return {
modelDesc: modelDesc,
mountedModel: mountedModel
modelDesc,
mountedModel
};
}
};
});
createDispatchActionsFromEffects(context.store, modelDesc.name, modelDesc.effects, setDispatchAction);
return {
modelDesc,
mountedModel
};
}
}));
export default plugin;
import plugin from './plugin';
export { plugin };
import handleEffect from './utils/handleEffect';
export { plugin, handleEffect };
export default plugin;
{
"name": "@modern-js-reduck/plugin-effects",
"version": "1.0.2",
"version": "1.0.3",
"files": [
"dist"
],
"jsnext:source": "./src/index.ts",

@@ -32,11 +35,11 @@ "types": "./dist/types/index.d.ts",

"@babel/runtime": "^7",
"redux": "^4.1.1",
"redux-promise-middleware": "^6.1.2",
"redux-thunk": "^2.3.0",
"redux": "^4.1.1"
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@modern-js-reduck/store": "^1.0.1",
"@modern-js/module-tools": "latest",
"@modern-js/plugin-testing": "latest",
"@types/jest": "^26",
"@modern-js-reduck/store": "^1.0.5",
"@modern-js/module-tools": "^1.7.1",
"@modern-js/plugin-testing": "^1.6.0",
"@types/jest": "^27.5.1",
"@types/node": "^14",

@@ -52,3 +55,3 @@ "@types/react": "^17",

"peerDependencies": {
"@modern-js-reduck/store": "^1.0.1"
"@modern-js-reduck/store": "^1.0.5"
},

@@ -55,0 +58,0 @@ "publishConfig": {

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