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

Function Provider

src/ui-react/Provider.tsx:48–192  ·  view source on GitHub ↗
({
  store,
  storesById,
  metrics,
  metricsById,
  indexes,
  indexesById,
  relationships,
  relationshipsById,
  queries,
  queriesById,
  checkpoints,
  checkpointsById,
  persister,
  persistersById,
  synchronizer,
  synchronizersById,
  children,
}: ProviderProps & {readonly children: ReactNode})

Source from the content-addressed store, hash-verified

46];
47
48export const Provider: typeof ProviderDecl = ({
49 store,
50 storesById,
51 metrics,
52 metricsById,
53 indexes,
54 indexesById,
55 relationships,
56 relationshipsById,
57 queries,
58 queriesById,
59 checkpoints,
60 checkpointsById,
61 persister,
62 persistersById,
63 synchronizer,
64 synchronizersById,
65 children,
66}: ProviderProps & {readonly children: ReactNode}): any => {
67 const parentValue = useContext(Context);
68 const [extraThingsById, setExtraThingsById] = useState<ExtraThingsById>(
69 () => arrayNew(8, () => ({})) as ExtraThingsById,
70 );
71 const addExtraThingById = useCallback(
72 <Offset extends Offsets>(
73 thingOffset: Offset,
74 id: Id,
75 thing: ThingsByOffset[Offset],
76 ) =>
77 setExtraThingsById((extraThingsById) =>
78 objGet(extraThingsById[thingOffset] as any, id) == thing
79 ? extraThingsById
80 : (arrayWith(extraThingsById, thingOffset, {
81 ...extraThingsById[thingOffset],
82 [id]: thing,
83 } as any) as ExtraThingsById),
84 ),
85 [],
86 );
87
88 const delExtraThingById = useCallback(
89 (thingOffset: Offsets, id: Id) =>
90 setExtraThingsById((extraThingsById) =>
91 !objHas(extraThingsById[thingOffset], id)
92 ? extraThingsById
93 : (arrayWith(
94 extraThingsById,
95 thingOffset,
96 objDel(extraThingsById[thingOffset] as any, id),
97 ) as ExtraThingsById),
98 ),
99 [],
100 );
101
102 return (
103 <Context.Provider
104 value={useMemo(
105 () => [

Callers

nothing calls this directly

Calls 6

arrayNewFunction · 0.90
objGetFunction · 0.90
arrayWithFunction · 0.90
objHasFunction · 0.90
objDelFunction · 0.90
mergeParentThingsFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…