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

redux-promise-middleware

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-promise-middleware - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

9

dist/index.js

@@ -20,4 +20,5 @@ 'use strict';

var types = action.types;
var promise = action.payload;
var _action$payload = action.payload;
var promise = _action$payload.promise;
var data = _action$payload.data;
var PENDING = types[0];

@@ -32,3 +33,4 @@ var FULFILLED = types[1];

next({
type: PENDING
type: PENDING,
payload: data
});

@@ -48,2 +50,3 @@

payload: error,
error: true,
type: REJECTED

@@ -50,0 +53,0 @@ });

'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.__esModule = true;
exports['default'] = isPromise;
function isPromise(value) {
return value && typeof value.then === 'function';
if (value !== null && typeof value === 'object') {
return value.promise && typeof value.promise.then === 'function';
}
}
module.exports = exports['default'];
{
"name": "redux-promise-middleware",
"version": "0.1.0",
"version": "0.2.0",
"description": "Redux middleware for handling promises",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -21,3 +21,3 @@ # Redux Promise Middleware

To use the middleware, dispatch a promise as the `payload` of the action and specify a `types` array.
To use the middleware, dispatch a promise within the `payload` of the action and specify a `types` array. You may pass an optional `data` object. This is dispatched from the pending action and is useful for optimistic updates.

@@ -27,3 +27,3 @@ The pending action is dispatched immediately. The fulfilled action is dispatched only if the promise is resolved, e.g., if it was successful; and the rejected action is dispatched only if the promise is rejected, e.g., if an error occurred.

```js
export function myAsyncActionCreator() {
export function myAsyncActionCreator(data) {
return {

@@ -35,3 +35,6 @@ types: [

],
payload: doSomethingAyncAndReturnPromise()
payload: {
promise: doSomethingAyncAndReturnPromise(data),
data: data
}
};

@@ -38,0 +41,0 @@ }

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