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

Function logger

test/typescript/middleware.ts:15–33  ·  view source on GitHub ↗

* Logger middleware doesn't add any extra types to dispatch, just logs actions * and state.

()

Source from the content-addressed store, hash-verified

13 * and state.
14 */
15function logger() {
16 const loggerMiddleware: Middleware =
17 ({ getState }) =>
18 next =>
19 action => {
20 console.log('will dispatch', action)
21
22 // Call the next dispatch method in the middleware chain.
23 const returnValue = next(action)
24
25 console.log('state after dispatch', getState())
26
27 // This will likely be the action itself, unless
28 // a middleware further in chain changed it.
29 return returnValue
30 }
31
32 return loggerMiddleware
33}
34
35/**
36 * Promise middleware adds support for dispatching promises.

Callers 1

applyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected