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

Function useThing

src/ui-react/context.ts:74–86  ·  view source on GitHub ↗
(
  id: Id | undefined,
  offset: Offsets,
)

Source from the content-addressed store, hash-verified

72 : ((GLOBAL as any)[TINYBASE_CONTEXT] = createContext<ContextValue>([]));
73
74export const useThing = <UsedThing extends Thing>(
75 id: Id | undefined,
76 offset: Offsets,
77): UsedThing | undefined => {
78 const contextValue = useContext(Context);
79 return (
80 isUndefined(id)
81 ? contextValue[offset * 2]
82 : isString(id)
83 ? objGet(contextValue[offset * 2 + 1] as IdObj<UsedThing>, id)
84 : id
85 ) as UsedThing;
86};
87
88export const useThings = <UsedThing extends Thing>(
89 offset: Offsets,

Callers 9

useStoreFunction · 0.90
useMetricsFunction · 0.90
useIndexesFunction · 0.90
useRelationshipsFunction · 0.90
useQueriesFunction · 0.90
useCheckpointsFunction · 0.90
usePersisterFunction · 0.90
useSynchronizerFunction · 0.90
useThingOrThingByIdFunction · 0.70

Calls 3

isUndefinedFunction · 0.90
isStringFunction · 0.90
objGetFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…