Skip to content

Redux middleware to return the resolved value of an async action's payload when using `redux-promise-middleware`.

Notifications You must be signed in to change notification settings

makaivelli/resolve-promise-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Resolve Promise Middleware

resolve-promise-middleware combined with redux-promise-middleware allows to use the resolved value of an async payload without accessing the store.

Install

$ npm install resolve-promise-middleware --save

Setup

Apply it before promiseMiddleware

import promiseMiddleware from 'redux-promise-middleware';
import { resolvePromiseMiddleware } from "resolve-promise-middleware";

composeStoreWithMiddleware = applyMiddleware(
    resolvePromiseMiddleware
    promiseMiddleware(),
)(createStore)

Usage

action.js

const asyncAction = () => ({
  type: 'PROMISE',
  payload: new Promise(...)
})

component.js

getDogs().then(dogs => this.dogs = dogs);

service.js

getDogs() {
    return store.dispatch(asyncAction)
        .catch(handleError)

About

Redux middleware to return the resolved value of an async action's payload when using `redux-promise-middleware`.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published