redux-promise-middleware
Advanced tools
Comparing version 4.4.0 to 4.4.1
@@ -37,2 +37,3 @@ 'use strict'; | ||
var promiseTypeSuffixes = config.promiseTypeSuffixes || defaultTypes; | ||
var promiseTypeSeparator = config.promiseTypeSeparator || '_'; | ||
@@ -76,3 +77,3 @@ return function (ref) { | ||
return _extends({ | ||
type: type + '_' + (isRejected ? _REJECTED : _FULFILLED) | ||
type: [type, isRejected ? _REJECTED : _FULFILLED].join(promiseTypeSeparator) | ||
}, newPayload === null || typeof newPayload === 'undefined' ? {} : { | ||
@@ -108,25 +109,19 @@ payload: newPayload | ||
next(_extends({ | ||
type: type + '_' + _PENDING | ||
type: [type, _PENDING].join(promiseTypeSeparator) | ||
}, data !== undefined ? { payload: data } : {}, meta !== undefined ? { meta: meta } : {})); | ||
/* | ||
* @function transformFulfill | ||
* @description Transforms a fulfilled value into a success object. | ||
* @function handleReject | ||
* @description Dispatch the rejected action and return | ||
* an error object. The error object is the original error | ||
* that was thrown. The user of the library is responsible for | ||
* best practices in ensure that they are throwing an Error object. | ||
* @params reason The reason the promise was rejected | ||
* @returns {object} | ||
*/ | ||
var transformFulfill = function transformFulfill() { | ||
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; | ||
var resolvedAction = getAction(value, false); | ||
return { value: value, action: resolvedAction }; | ||
}; | ||
/* | ||
* @function handleReject | ||
* @description Dispatch the rejected action. | ||
* @returns {void} | ||
*/ | ||
var handleReject = function handleReject(reason) { | ||
var rejectedAction = getAction(reason, true); | ||
dispatch(rejectedAction); | ||
throw reason; | ||
}; | ||
@@ -136,8 +131,15 @@ | ||
* @function handleFulfill | ||
* @description Dispatch the fulfilled action. | ||
* @param successValue The value from transformFulfill | ||
* @returns {void} | ||
* @description Dispatch the fulfilled action and | ||
* return the success object. The success object should | ||
* contain the value and the dispatched action. | ||
* @param value The value the promise was resloved with | ||
* @returns {object} | ||
*/ | ||
var handleFulfill = function handleFulfill(successValue) { | ||
dispatch(successValue.action); | ||
var handleFulfill = function handleFulfill() { | ||
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; | ||
var resolvedAction = getAction(value, false); | ||
dispatch(resolvedAction); | ||
return { value: value, action: resolvedAction }; | ||
}; | ||
@@ -174,9 +176,3 @@ | ||
*/ | ||
var promiseValue = promise.then(transformFulfill); | ||
var sideEffects = promiseValue.then(handleFulfill, handleReject); | ||
return sideEffects.then(function () { | ||
return promiseValue; | ||
}, function () { | ||
return promiseValue; | ||
}); | ||
return promise.then(handleFulfill, handleReject); | ||
}; | ||
@@ -183,0 +179,0 @@ }; |
{ | ||
"name": "redux-promise-middleware", | ||
"version": "4.4.0", | ||
"description": "Redux middleware for promises and optimistic updates", | ||
"description": "Redux middleware for handling promises and optimistic updates", | ||
"version": "4.4.1", | ||
"main": "dist/index.js", | ||
@@ -11,3 +11,3 @@ "module": "dist/es/index.js", | ||
"prebuild": "npm run test", | ||
"build": "npm run build-commonjs & npm run build-es & npm run build-umd & npm run build-umd-min", | ||
"build": "rm -rf dist & npm run build-commonjs & npm run build-es & npm run build-umd & npm run build-umd-min", | ||
"build-es": "BABEL_ENV=es `npm bin`/babel src -d dist/es", | ||
@@ -14,0 +14,0 @@ "build-commonjs": "`npm bin`/babel src -d dist", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
200081
12
573
1