You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-1Lines changed: 21 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -308,7 +308,25 @@ When in doubt, use the shorter option!
308
308
309
309
### Can I use this in production?
310
310
311
-
I wouldn't. Many use cases haven't been considered yet. If you find some use cases this lib can't handle yet, please file an issue.
311
+
Yep. People already do that although I warned them! The API surface is minimal so migrating to 1.0 API when it comes out won't be difficult. Let us know about any issues.
312
+
313
+
### How do I do async?
314
+
315
+
There's already a built-in way of doing async action creators:
316
+
317
+
```js
318
+
// Can also be async if you return a function
319
+
exportfunctionincrementAsync() {
320
+
returndispatch=> {
321
+
setTimeout(() => {
322
+
// Yay! Can invoke sync or async actions with `dispatch`
323
+
dispatch(increment());
324
+
}, 1000);
325
+
};
326
+
}
327
+
```
328
+
329
+
It's also easy to implement support for returning Promises or Observables with a custom middleware. [See an example of a custom Promise middleware.](https://github.com/gaearon/redux/issues/99#issuecomment-112212639)
312
330
313
331
### But there are switch statements!
314
332
@@ -336,6 +354,8 @@ It's all just functions.
336
354
Fancy stuff like generating stores from handler maps, or generating action creator constants, should be in userland.
337
355
Redux has no opinion on how you do this in your project.
338
356
357
+
See also [this gist](https://gist.github.com/skevy/8a4ffc3cfdaf5fd68739) for an example implementation of action constant generation.
358
+
339
359
### What about `waitFor`?
340
360
341
361
I wrote a lot of vanilla Flux code and my only use case for it was to avoid emitting a change before a related Store consumes the action. This doesn't matter in Redux because the change is only emitted after *all* Stores have consumed the action.
0 commit comments