redux-promise-middleware
Advanced tools
Comparing version 0.0.1 to 0.1.0
@@ -12,38 +12,40 @@ 'use strict'; | ||
function promiseMiddleware(next) { | ||
return function (action) { | ||
if (!_isPromise2['default'](action.payload)) { | ||
return next(action); | ||
} | ||
function promiseMiddleware() { | ||
return function (next) { | ||
return function (action) { | ||
if (!_isPromise2['default'](action.payload)) { | ||
return next(action); | ||
} | ||
var types = action.types; | ||
var types = action.types; | ||
var promise = action.payload; | ||
var PENDING = types[0]; | ||
var FULFILLED = types[1]; | ||
var REJECTED = types[2]; | ||
var promise = action.payload; | ||
var PENDING = types[0]; | ||
var FULFILLED = types[1]; | ||
var REJECTED = types[2]; | ||
/** | ||
* Dispatch the first async handler. This tells the | ||
* reducer that an async action has been dispatched. | ||
*/ | ||
next({ | ||
type: PENDING | ||
}); | ||
/** | ||
* Dispatch the first async handler. This tells the | ||
* reducer that an async action has been dispatched. | ||
*/ | ||
next({ | ||
type: PENDING | ||
}); | ||
/** | ||
* Return either the fulfilled action object or the rejected | ||
* action object. | ||
*/ | ||
return promise.then(function (payload) { | ||
return next({ | ||
payload: payload, | ||
type: FULFILLED | ||
/** | ||
* Return either the fulfilled action object or the rejected | ||
* action object. | ||
*/ | ||
return promise.then(function (payload) { | ||
return next({ | ||
payload: payload, | ||
type: FULFILLED | ||
}); | ||
}, function (error) { | ||
return next({ | ||
payload: error, | ||
type: REJECTED | ||
}); | ||
}); | ||
}, function (error) { | ||
return next({ | ||
payload: error, | ||
type: REJECTED | ||
}); | ||
}); | ||
}; | ||
}; | ||
@@ -50,0 +52,0 @@ } |
{ | ||
"name": "redux-promise-middleware", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Redux middleware for handling promises", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
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
4711
52