MCPcopy
hub / github.com/marimo-team/marimo / reducerWithMiddleware

Function reducerWithMiddleware

frontend/src/utils/createReducer.ts:101–116  ·  view source on GitHub ↗
(state: State, action: ReducerActionOf<RH>)

Source from the content-addressed store, hash-verified

99 const { reducer, createActions } = createReducer(initialState, reducers);
100
101 const reducerWithMiddleware = (state: State, action: ReducerActionOf<RH>) => {
102 try {
103 const newState = reducer(state, action);
104 for (const mw of allMiddleware) {
105 try {
106 mw(state, newState, action);
107 } catch (error) {
108 Logger.error(`Error in middleware for action ${action.type}:`, error);
109 }
110 }
111 return newState;
112 } catch (error) {
113 Logger.error(`Error in reducer for action ${action.type}:`, error);
114 return state;
115 }
116 };
117
118 const valueAtom = atom(initialState());
119 // map of SetAtom => Actions

Callers 1

useActionsFunction · 0.85

Calls 2

reducerFunction · 0.85
errorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…