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

Function extraMethods

test/typescript/enhancers.ts:97–114  ·  view source on GitHub ↗

* Store enhancer that adds methods to the store.

()

Source from the content-addressed store, hash-verified

95 * Store enhancer that adds methods to the store.
96 */
97function extraMethods() {
98 const enhancer: StoreEnhancer<{ method(): string }> =
99 createStore =>
100 (...args) => {
101 const store = createStore(...args)
102 return {
103 ...store,
104 method: () => 'foo'
105 }
106 }
107
108 const store = createStore(reducer, enhancer)
109
110 store.getState()
111 const res: string = store.method()
112 // @ts-expect-error
113 store.wrongMethod()
114}
115
116/**
117 * replaceReducer with a store enhancer

Callers

nothing calls this directly

Calls 2

createStoreFunction · 0.85
getStateMethod · 0.65

Tested by

no test coverage detected