Skip to content

Commit

Permalink
Update README to include link to middleware docs
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Jun 13, 2015
1 parent 7630380 commit 8ba8fe2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,20 +256,26 @@ is in fact a shortcut for this:

```js
import { createRedux, createDispatcher, composeStores } from 'redux';
import thunkMiddleware from 'redux/lib/middleware/thunk';
import * as stores from '../stores/index';

// Compose all your Stores into a single Store function with `composeStores`:
const store = composeStores(stores);

// Create a Dispatcher function for your composite Store:
const dispatcher = createDispatcher(store);
const dispatcher = createDispatcher(
store,
getState => [thunkMiddleware(getState)] // Pass the default middleware
);

// Create a Redux instance using the dispatcher function:
const redux = createRedux(dispatcher);
```

Why would you want to write it longer? Maybe you're an advanced user and want to provide a custom Dispatcher function, or maybe you have a different idea of how to compose your Stores (or you're satisfied with a single Store). Redux lets you do all of this.

`createDispatcher()` also gives you the ability to specify middleware -- for example, to add support for promises. [Learn more](https://github.com/gaearon/redux/blob/master/docs/middleware.md) about how to create and use middleware in Redux.

When in doubt, use the shorter option!

## FAQ
Expand Down

0 comments on commit 8ba8fe2

Please sign in to comment.