Skip to content

Commit 8ba8fe2

Browse files
committed
Update README to include link to middleware docs
1 parent 7630380 commit 8ba8fe2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,20 +256,26 @@ is in fact a shortcut for this:
256256

257257
```js
258258
import { createRedux, createDispatcher, composeStores } from 'redux';
259+
import thunkMiddleware from 'redux/lib/middleware/thunk';
259260
import * as stores from '../stores/index';
260261

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

264265
// Create a Dispatcher function for your composite Store:
265-
const dispatcher = createDispatcher(store);
266+
const dispatcher = createDispatcher(
267+
store,
268+
getState => [thunkMiddleware(getState)] // Pass the default middleware
269+
);
266270

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

271275
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.
272276

277+
`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.
278+
273279
When in doubt, use the shorter option!
274280

275281
## FAQ

0 commit comments

Comments
 (0)