Skip to content

Commit

Permalink
Revert v6 documentation (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Burtchaell authored Jan 16, 2019
1 parent 15dfa1a commit 0b61389
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 36 deletions.
6 changes: 2 additions & 4 deletions docs/guides/custom-suffixes.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Type Suffix Configuration

In the case you need to use different type suffixes, you can configure this globally for all actions or locally (action-by-action) using the exported function `createPromise`.
In the case you need to use different type suffixes, you can configure this globally for all actions or locally (action-by-action).

To change suffixes, you can supply an optional configuration object to `createPromise`. This object accepts an array of suffix strings that can be used instead of the default with a key of `promiseTypeSuffixes`.
To change suffixes, you can supply an optional configuration object to the middleware. This object accepts an array of suffix strings that can be used instead of the default with a key of `promiseTypeSuffixes`.

```js
import { createPromise } from 'redux-promise-middleware'

applyMiddleware(
promiseMiddleware({
promiseTypeSuffixes: ['LOADING', 'SUCCESS', 'ERROR']
Expand Down
44 changes: 12 additions & 32 deletions docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,21 @@

## Installation

First, install the middleware with npm:
First, install the middleware.

```
npm i redux-promise-middleware -s
```

Or with Yarn:

```
yarn add redux-promise-middleware
```
npm: `npm i redux-promise-middleware -S`
yarn: `yarn add redux-promise-middleware`

## Setup

Import the middleware and include it in `applyMiddleware` when creating the Redux store:

```js
import promiseMiddleware from 'redux-promise-middleware'
import promiseMiddleware from 'redux-promise-middleware';

composeStoreWithMiddleware = applyMiddleware(
promiseMiddleware,
)(createStore)
promiseMiddleware()
)(createStore);
```

## Use
Expand All @@ -33,8 +26,8 @@ Dispatch a promise as the value of the `payload` property of the action.
```js
const foo = () => ({
type: 'FOO',
payload: new Promise(),
})
payload: new Promise()
});
```

A pending action is immediately dispatched.
Expand Down Expand Up @@ -68,27 +61,14 @@ On the other hand, if the promise is rejected, a rejected action is dispatched.
}
```

If you need to send extra information not included in the `payload` property, you can use the `meta` property.

```js
const foo = () => ({
type: 'FOO',
payload: new Promise(),
meta: {
...
},
})
```

That's it!

## TypeScript

The middleware does support TypeScript.

## Further Reading

- [Catching Errors Thrown by Rejected Promises](guides/rejected-promises.md)
- [Use with Reducers](guides/reducers.md)
- [Optimistic Updates](guides/optimistic-updates.md)
- [Custom Types](guides/custom-suffixes.md)
- [Design Principles](guides/design-principles.md)

---
Copyright (c) 2017 Patrick Burtchaell. [Code licensed with the MIT License (MIT)](/LICENSE). [Documentation licensed with the CC BY-NC License](LICENSE).

0 comments on commit 0b61389

Please sign in to comment.