()
| 39 | type PromiseDispatch = <T extends Action>(promise: Promise<T>) => Promise<T> |
| 40 | |
| 41 | function promise() { |
| 42 | const promiseMiddleware: Middleware<PromiseDispatch> = |
| 43 | ({ dispatch }) => |
| 44 | next => |
| 45 | action => { |
| 46 | if (action instanceof Promise) { |
| 47 | action.then(dispatch) |
| 48 | return action |
| 49 | } |
| 50 | |
| 51 | return next(action) |
| 52 | } |
| 53 | |
| 54 | return promiseMiddleware |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Thunk middleware adds support for dispatching thunks. |