MCPcopy
hub / github.com/reduxjs/redux / promise

Function promise

test/typescript/middleware.ts:41–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39type PromiseDispatch = <T extends Action>(promise: Promise<T>) => Promise<T>
40
41function 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.

Callers 1

applyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected