Redux Promise Middleware Versions Save

Enables simple, yet robust handling of async action creators in Redux

4.4.0

6 years ago

This is a big release that adds new functionality and resolves #159, an outstanding issue from this summer.

Here’s the complete list:

  • Reverts the changes from #126, subsequently released in version 4.3.0.
  • Resolves #159.
  • Adds support for ES6 Modules, thanks to @anajavi. This enables scope hosting on WebPack 3, saving a space and increasing performance.
  • Adds support for custom separators on action types, thanks to @roboslone. Now your actions can be customized to, for example, FOO/FULFILLED or FOO-FULLFILLED instead of FOO_FULFILLED.
  • Updates to WebPack 2, thanks to @GeKorm.
  • Changes UMD paths to dist/umd/redux-promise-middleware.js and dist/umd/redux-promise-middleware.min.js.

4.3.0

7 years ago

This release has been deprecated due to breaking changes in error handling.

This release fixes a bug when a dispatch call throws an error in handleFulfill, changing the promise state to rejected. This can happen when a reducer throws an error or a component's render throws as a result of a Redux store update.

Thanks to @danwang for the PR!

4.2.1

7 years ago

This release adds the default suffix types as module exports, as documented in the Introduction. This is useful for reducers.

import { PENDING, FULFILLED, REJECTED } from 'redux-promise-middleware';

export default function fooReducer(state = {}, action) {
  switch (action.type) {
    case `FOO_${FULFILLED}`:
      return ...
  }
}

Thanks to @piu130 for the PR!

4.2.0

7 years ago

Falsy values of the data and meta properties are now preserved by the middleware.

4.1.0

7 years ago

When a Promise is resolved with a value of 0 or false, it will be included as the value of the fulfilled action payload property.

4.0.0

7 years ago

This release introduces changes to error handling.

Previously, the parameter of the rejected promise callback was both the dispatched action and an Error object. The middleware also always constructed a new Error object, which caused unexpected mutation and circular references.

Now, the parameter of the rejected promise callback is the value of reject. The middleware does not construct a new error; it is your responsibility to make sure the promise is rejected with an Error object.

// before
const bar = () => ({
  type: 'FOO',
  payload: new Promise(() => {
    reject('foo');
  })
});.then(() => null, ({ reason, action }) => {
  console.log(action.type): // => 'FOO'
  console.log(reason.message); // => 'foo'
});

// after
const bar = () => ({
  type: 'FOO',
  payload: new Promise(() => {

    /**
     * Make sure the promise is rejected with an error. You
     * can also use `reject(new Error('foo'));`. It's a best
     * practice to reject a promise with an Error object.
     */
    throw new Error('foo');
  })
});.then(() => null, error => {
  console.log(error instanceof Error); // => true
  console.log(error.message); // => 'foo'
});

3.3.2

7 years ago

This release adds UMD (Universal Module Definition) build tasks. A UMD module is a "universal" module compatible either the AMD or CommonJS loaders, or no module loader at all. This blog post offers a comparison between the module types.

The implementation is adapted from reactjs/react-router-redux@ad0d41d and uses a modified module definition to work around webpack/webpack#706. Specifically, this release uses the umd libraryTarget webpack option to "export to AMD, CommonJS2 or as property in root".

3.3.1

7 years ago

This release extends the functionality introduced in version 3.2.0 to preserve the original error. When the rejection reason instance of Error, the original error object will be used instead of constructing a new error.

3.3.0

7 years ago

🔥🚒 The version 3.2.0 release broke catch() on promises.

// expected functionality
doSomethingAsyncAndReject().catch(() => { 
  // called once 🙂
});

// version 3.2.0
doSomethingAsyncAndReject().catch(() => { 
  // never called ☹️
});

This release fixes the functionality of catch and updates tests. Previously, an error in how async...await was used caused tests to pass even if the assertion failed. Tests now use done to ensure async tests complete with full confidence.

3.2.0

7 years ago

Instead of constructing a new promise and returning the new promise, the middleware returns the original promise. This change was made to avoid an anti-pattern and to ensure the original promise object methods are preserved, such as in the case where a library like Bluebird is used.