MCPcopy Create free account
hub / github.com/byte-fe/react-model / getNewState

Function getNewState

src/middlewares.ts:25–49  ·  view source on GitHub ↗
(context, restMiddlewares)

Source from the content-addressed store, hash-verified

23}
24
25const getNewState: Middleware = async (context, restMiddlewares) => {
26 const {
27 action,
28 modelName,
29 consumerActions,
30 params,
31 next,
32 Global,
33 type
34 } = context
35 if (type === 'u') {
36 // @ts-ignore
37 context.newState = action()
38 } else {
39 context.newState =
40 (await action(params, {
41 actions: consumerActions(Global.Actions[modelName], { modelName }),
42 state: Global.State[modelName],
43 ...(Global.Context['__global'] || {}),
44 ...(Global.Context[modelName] || {})
45 })) || null
46 }
47
48 return await next(restMiddlewares)
49}
50
51const getNewStateWithCache = (maxTime: number = 5000): Middleware => async (
52 context,

Callers

nothing calls this directly

Calls 1

consumerActionsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…