redux-promise-middleware
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -106,2 +106,40 @@ 'use strict'; | ||
/* | ||
* @function handleReject | ||
* @description Dispatch the rejected action and return | ||
* an error object. The error object should contain the | ||
* reason and the dispatched action. | ||
* @params reason The reason the promise was rejected | ||
* @returns {object} | ||
*/ | ||
var handleReject = function handleReject() { | ||
var reason = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; | ||
var rejectedAction = getAction(reason, true); | ||
dispatch(rejectedAction); | ||
var error = new Error(); | ||
error.reason = reason; | ||
error.action = rejectedAction; | ||
return error; | ||
}; | ||
/* | ||
* @function handleFulfill | ||
* @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() { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; | ||
var resolvedAction = getAction(value, false); | ||
dispatch(resolvedAction); | ||
return { value: value, action: resolvedAction }; | ||
}; | ||
/** | ||
@@ -136,26 +174,3 @@ * Second, dispatch a rejected or fulfilled action. This flux standard | ||
*/ | ||
return new Promise(function (resolve, reject) { | ||
promise.then(function () { | ||
var value = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; | ||
var resolvedAction = getAction(value, false); | ||
dispatch(resolvedAction); | ||
resolve({ value: value, action: resolvedAction }); | ||
return; | ||
}, function () { | ||
var reason = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; | ||
var rejectedAction = getAction(reason, true); | ||
dispatch(rejectedAction); | ||
var error = new Error(); | ||
error.reason = reason; | ||
error.action = rejectedAction; | ||
reject(error); | ||
return; | ||
}); | ||
}); | ||
return promise.then(handleFulfill, handleReject); | ||
}; | ||
@@ -162,0 +177,0 @@ }; |
{ | ||
"name": "redux-promise-middleware", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Redux middleware for handling promises and optimistic updates", | ||
@@ -47,2 +47,3 @@ "main": "dist/index.js", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"bluebird": "^3.4.0", | ||
"chai": "^3.5.0", | ||
@@ -49,0 +50,0 @@ "coveralls": "^2.11.9", |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
262596
5697
34
1