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.6 to 1.1.0

31

dist/js/modern/plugin.js

@@ -5,7 +5,19 @@ 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); }

import { createPromise } from 'redux-promise-middleware';
import thunk from 'redux-thunk';
const isReduxPromiseFulfilled = data => {
return typeof data === 'object' && data.action && data.value;
};
const isPromise = value => {
if (value !== null && typeof value === 'object') {
return value && typeof value.then === 'function';
}
return false;
};
/**
* Generate dispatch action from effects definitions.
*/
const createDispatchActionsFromEffects = (store, name, effects, setDispatchAction) => {

@@ -27,4 +39,11 @@ const path = [name];

if (value instanceof Promise || typeof value === 'function') {
return dispatch(value);
if (isPromise(value) || typeof value === 'function') {
const res = dispatch(value);
if (isPromise(res)) {
// parse redux-promise result, return orginal value of the effect
return res.then(data => isReduxPromiseFulfilled(data) ? data.value : data);
}
return res;
}

@@ -49,6 +68,6 @@

return _extends({}, storeConfig, {
middlewares: [...(storeConfig.middlewares || []), createPromise({
middlewares: [createPromise({
promiseTypeDelimiter: '/'
}), thunk // currently thunk cannot work with reduck correctlly, maybe we can just remove this style of effects
]
}), // middlewares from config are at the end
...(storeConfig.middlewares || [])]
});

@@ -55,0 +74,0 @@ },

34

dist/js/node/plugin.js

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

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; }

@@ -23,5 +19,18 @@

const isReduxPromiseFulfilled = data => {
return typeof data === 'object' && data.action && data.value;
};
const isPromise = value => {
if (value !== null && typeof value === 'object') {
return value && typeof value.then === 'function';
}
return false;
};
/**
* Generate dispatch action from effects definitions.
*/
const createDispatchActionsFromEffects = (store, name, effects, setDispatchAction) => {

@@ -43,4 +52,11 @@ const path = [name];

if (value instanceof Promise || typeof value === 'function') {
return dispatch(value);
if (isPromise(value) || typeof value === 'function') {
const res = dispatch(value);
if (isPromise(res)) {
// parse redux-promise result, return orginal value of the effect
return res.then(data => isReduxPromiseFulfilled(data) ? data.value : data);
}
return res;
}

@@ -65,6 +81,6 @@

return _objectSpread(_objectSpread({}, storeConfig), {}, {
middlewares: [...(storeConfig.middlewares || []), (0, _reduxPromiseMiddleware.createPromise)({
middlewares: [(0, _reduxPromiseMiddleware.createPromise)({
promiseTypeDelimiter: '/'
}), _reduxThunk.default // currently thunk cannot work with reduck correctlly, maybe we can just remove this style of effects
]
}), // middlewares from config are at the end
...(storeConfig.middlewares || [])]
});

@@ -71,0 +87,0 @@ },

import _extends from "@babel/runtime/helpers/esm/extends";
import { createPlugin } from '@modern-js-reduck/store';
import { createPromise } from 'redux-promise-middleware';
import thunk from 'redux-thunk';
const isReduxPromiseFulfilled = data => {
return typeof data === 'object' && data.action && data.value;
};
const isPromise = value => {
if (value !== null && typeof value === 'object') {
return value && typeof value.then === 'function';
}
return false;
};
/**
* Generate dispatch action from effects definitions.
*/
const createDispatchActionsFromEffects = (store, name, effects, setDispatchAction) => {

@@ -25,4 +37,11 @@ const path = [name];

if (value instanceof Promise || typeof value === 'function') {
return dispatch(value);
if (isPromise(value) || typeof value === 'function') {
const res = dispatch(value);
if (isPromise(res)) {
// parse redux-promise result, return orginal value of the effect
return res.then(data => isReduxPromiseFulfilled(data) ? data.value : data);
}
return res;
}

@@ -47,6 +66,6 @@

return _extends({}, storeConfig, {
middlewares: [...(storeConfig.middlewares || []), createPromise({
middlewares: [createPromise({
promiseTypeDelimiter: '/'
}), thunk // currently thunk cannot work with reduck correctlly, maybe we can just remove this style of effects
]
}), // middlewares from config are at the end
...(storeConfig.middlewares || [])]
});

@@ -53,0 +72,0 @@ },

@@ -9,7 +9,7 @@ interface Config {

}
export default function handleEffect(config?: Config): {
pending: (state: any) => any;
fulfilled: (state: any, payload: any) => any;
rejected: (state: any, error: any) => any;
export default function handleEffect<State = any, Payload = any, Error = string>(config?: Config): {
pending: (state: State) => State | void;
fulfilled: (state: State, payload: Payload) => State | void;
rejected: (state: State, error: Error) => State | void;
};
export {};
{
"name": "@modern-js-reduck/plugin-effects",
"version": "1.0.6",
"version": "1.1.0",
"files": [

@@ -36,7 +36,6 @@ "dist"

"redux": "^4.1.1",
"redux-promise-middleware": "^6.1.2",
"redux-thunk": "^2.3.0"
"redux-promise-middleware": "^6.1.2"
},
"devDependencies": {
"@modern-js-reduck/store": "1.0.6",
"@modern-js-reduck/store": "1.1.0",
"@modern-js/module-tools": "^1.7.1",

@@ -54,3 +53,3 @@ "@modern-js/plugin-testing": "^1.6.0",

"peerDependencies": {
"@modern-js-reduck/store": "^1.0.6"
"@modern-js-reduck/store": "^1.1.0"
},

@@ -57,0 +56,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