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

Function getActions

src/index.tsx:326–353  ·  view source on GitHub ↗
(
  modelName: string,
  baseContext: Partial<Context> = { type: 'o' }
)

Source from the content-addressed store, hash-verified

324}
325
326const getActions = (
327 modelName: string,
328 baseContext: Partial<Context> = { type: 'o' }
329) => {
330 const updaters: any = {}
331 Object.keys(Global.Actions[modelName]).forEach(
332 (key) =>
333 (updaters[key] = async (params: any, middlewareConfig?: any) => {
334 const context: InnerContext = {
335 action: Global.Actions[modelName][key],
336 actionName: key,
337 consumerActions,
338 middlewareConfig,
339 modelName,
340 newState: null,
341 params,
342 ...baseContext,
343 Global
344 }
345 if (Global.Middlewares[modelName]) {
346 return await applyMiddlewares(Global.Middlewares[modelName], context)
347 } else {
348 return await applyMiddlewares(actionMiddlewares, context)
349 }
350 })
351 )
352 return updaters
353}
354
355const useStore = (modelName: string, selector?: Function) => {
356 const setState = useState({})[1]

Callers 6

ModelFunction · 0.85
useStoreFunction · 0.85
getActions.spec.tsFile · 0.85
getActions.spec.tsFile · 0.85
model.spec.tsFile · 0.85

Calls 1

applyMiddlewaresFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…