MCPcopy
hub / github.com/tinyplex/tinybase / useSetCallback

Function useSetCallback

src/ui-react/hooks.ts:461–494  ·  view source on GitHub ↗
(
  storeOrQueries: StoreOrQueries | undefined,
  settable: string,
  get: (parameter: Parameter, obj: StoreOrQueries) => Thing,
  getDeps: DependencyList = EMPTY_ARRAY,
  then: (obj: StoreOrQueries, thing: Thing) => void = getUndefined,
  thenDeps: DependencyList = EMPTY_ARRAY,
  methodPrefix?: string,
  ...args: (Id | GetId<Parameter>)[]
)

Source from the content-addressed store, hash-verified

459 );
460
461const useSetCallback = <Parameter, Thing, StoreOrQueries>(
462 storeOrQueries: StoreOrQueries | undefined,
463 settable: string,
464 get: (parameter: Parameter, obj: StoreOrQueries) => Thing,
465 getDeps: DependencyList = EMPTY_ARRAY,
466 then: (obj: StoreOrQueries, thing: Thing) => void = getUndefined,
467 thenDeps: DependencyList = EMPTY_ARRAY,
468 methodPrefix?: string,
469 ...args: (Id | GetId<Parameter>)[]
470): ParameterizedCallback<Parameter> =>
471 useCallback(
472 (parameter?: Parameter) =>
473 ifNotUndefined(storeOrQueries, (obj: any) =>
474 ifNotUndefined(get(parameter as any, obj), (thing: Thing) =>
475 then(
476 obj[methodPrefix + settable](
477 ...argsOrGetArgs(args, obj, parameter),
478 thing,
479 ),
480 thing,
481 ),
482 ),
483 ),
484 /* eslint-disable react-hooks/exhaustive-deps */
485 [
486 storeOrQueries,
487 settable,
488 ...getDeps,
489 ...thenDeps,
490 methodPrefix,
491 ...nonFunctionDeps(args),
492 ],
493 /* eslint-enable react-hooks/exhaustive-deps */
494 );
495
496const useStoreSetCallback = <Parameter, Thing>(
497 storeOrStoreId: StoreOrStoreId | undefined,

Callers 2

useStoreSetCallbackFunction · 0.70
useQueriesSetCallbackFunction · 0.70

Calls 2

argsOrGetArgsFunction · 0.70
nonFunctionDepsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…