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

Function useThingOrThingById

src/ui-solid/context.ts:115–137  ·  view source on GitHub ↗
(
  thingOrThingId: MaybeAccessor<UsedThing | Id | undefined>,
  offset: Offsets,
)

Source from the content-addressed store, hash-verified

113};
114
115export const useThingOrThingById = <
116 UsedThing extends
117 | Store
118 | Metrics
119 | Indexes
120 | Relationships
121 | Queries
122 | Checkpoints
123 | AnyPersister
124 | Synchronizer,
125>(
126 thingOrThingId: MaybeAccessor<UsedThing | Id | undefined>,
127 offset: Offsets,
128): Accessor<UsedThing | undefined> => {
129 const thing = useThing(thingOrThingId as MaybeAccessor<Id>, offset);
130 return () => {
131 const resolvedThingOrThingId = getValue(thingOrThingId);
132 return isUndefined(resolvedThingOrThingId) ||
133 isString(resolvedThingOrThingId)
134 ? (thing() as UsedThing | undefined)
135 : (resolvedThingOrThingId as UsedThing);
136 };
137};
138
139export const useProvideThing = <Offset extends Offsets>(
140 thingId: Id,

Calls 5

getValueFunction · 0.90
isUndefinedFunction · 0.90
isStringFunction · 0.90
useThingFunction · 0.70
thingFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…