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

Function useCreate

src/ui-solid/primitives.ts:231–243  ·  view source on GitHub ↗
(
  store: MaybeAccessor<Store | undefined>,
  create: (store: Store) => Thing,
)

Source from the content-addressed store, hash-verified

229const EMPTY_LISTENER_ARG_GETTERS: ListenerArgGetters = [];
230
231const useCreate = <Thing extends {destroy?: () => void}>(
232 store: MaybeAccessor<Store | undefined>,
233 create: (store: Store) => Thing,
234): Accessor<Thing | undefined> => {
235 const [thing, setThing] = createSignal<Thing>();
236 createEffect(() => {
237 const resolvedStore = getThing(store);
238 const newThing = resolvedStore ? create(resolvedStore) : undefined;
239 setThing(() => newThing);
240 onCleanup(() => newThing?.destroy?.());
241 });
242 return thing;
243};
244
245const addAndDelListener = (thing: any, listenable: string, ...args: any[]) => {
246 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 3

getThingFunction · 0.70
destroyMethod · 0.65
setThingFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…