MCPcopy Index your code
hub / github.com/tinyplex/tinybase / useCreate

Function useCreate

src/ui-react/hooks.ts:384–402  ·  view source on GitHub ↗
(
  store: Store | undefined,
  create: (store: Store) => any,
  createDeps: DependencyList = EMPTY_ARRAY,
)

Source from the content-addressed store, hash-verified

382const isEqual = (thing1: any, thing2: any) => thing1 === thing2;
383
384const useCreate = (
385 store: Store | undefined,
386 create: (store: Store) => any,
387 createDeps: DependencyList = EMPTY_ARRAY,
388) => {
389 const [, rerender] = useState<[]>();
390 const [thing, setThing] = useState();
391 useEffect(
392 () => {
393 const newThing = store ? create(store) : undefined;
394 setThing(newThing);
395 rerender([]);
396 return newThing?.destroy;
397 },
398 // eslint-disable-next-line react-hooks/exhaustive-deps
399 [store, ...createDeps],
400 );
401 return thing;
402};
403
404const addAndDelListener = (thing: any, listenable: string, ...args: any[]) => {
405 const listenerId = thing?.[ADD + listenable + LISTENER]?.(...args);

Callers 5

useCreateMetricsFunction · 0.70
useCreateIndexesFunction · 0.70
useCreateRelationshipsFunction · 0.70
useCreateQueriesFunction · 0.70
useCreateCheckpointsFunction · 0.70

Calls 1

setThingFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…