@pburtchaell pburtchaell released this Apr 18, 2018 · 6 commits to master since this release

Assets 2

This release adds Typescript bindings, thanks to @franklixuefei!

@pburtchaell pburtchaell released this Apr 18, 2018 · 9 commits to master since this release

Assets 2

This release adds peer dependency support for Redux 4. This is backwards compatible release, meaning there are no API changes. Should you experience any bugs, please file an issue and we'll get to it!

@pburtchaell pburtchaell released this Nov 19, 2017 · 20 commits to master since this release

Assets 2

Breaking Changes 🔥 🚒

The promiseTypeSeparator config property is now promiseTypeDelimiter.

Why? Because delimiters are one or more characters used to specify the boundaries in strings. It’s a delimiter, not a separator!

applyMiddleware(
  promiseMiddleware({
    promiseTypeDelimiter: '/'
  })
)

With the above configuration, given FOO async action, the type will be appended with a forward slash / delimiter.

{
  type: 'FOO/PENDING'
}

New

  • Async functions—using async/wait—are supported. Thanks to @mikew for the PR!
  • Development dependencies and example project dependencies are upgraded.
  • The middleware code comments were extended to provide a clearer picture of how it works.

Here’s an async/await example:

{
  type: 'TYPE',
  async payload () {
    const fooData = await getFooData();
    const barData = await getBarData(fooData);

    return barData;
  }
}

See the Async/Await guide for more.

@pburtchaell pburtchaell released this Aug 27, 2017 · 41 commits to master since this release

Assets 2

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.

@pburtchaell pburtchaell released this May 15, 2017 · 56 commits to master since this release

Assets 2

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!

@pburtchaell pburtchaell released this May 15, 2017 · 59 commits to master since this release

Assets 2

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!

@pburtchaell pburtchaell released this Nov 29, 2016 · 83 commits to master since this release

Assets 2

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

@pburtchaell pburtchaell released this Oct 8, 2016 · 109 commits to master since this release

Assets 2

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.

@pburtchaell pburtchaell released this Aug 22, 2016 · 119 commits to master since this release

Assets 2

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'
});

@pburtchaell pburtchaell released this Jul 6, 2016 · 131 commits to master since this release

Assets 2

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".