JSPM

  • Created
  • Published
  • Downloads 80928
  • Score
    100M100P100Q167862F
  • License MIT

Redux middleware for promises, async functions and conditional optimistic updates

Package Exports

  • redux-promise-middleware
  • redux-promise-middleware/dist/isPromise

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (redux-promise-middleware) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Redux Promise Middleware

npm version Build Status npm downloads

Redux promise middleware enables robust handling of async action creators in Redux: it accepts a promise and dispatches pending, fulfilled and rejected actions.

const promiseAction = () => ({
  type: 'PROMISE',
  payload: Promise.resolve(),
})

The middleware can also be combined with Redux Thunk to chain action creators.

const secondAction = (data) => ({
  type: 'TWO',
  payload: data,
})

const first = () => {
  return (dispatch) => {
    const response = dispatch({
      type: 'ONE',
      payload: Promise.resolve(),
    })

    response.then((data) => {
      dispatch(secondAction(data))
    })
  }
}

Documentation and Help

Issues and Pull Requests

Releases

Older versions:

Maintainers

Please reach out to us if you have any questions!


Copyright (c) 2015-Current Patrick Burtchaell. Code licensed with the MIT License (MIT). Documentation licensed with the CC BY-NC License.