( id: MaybeAccessor<Id | undefined>, offset: Offsets, )
| 85 | createContext<ContextValueAccessor>(EMPTY_CONTEXT_VALUE)); |
| 86 | |
| 87 | export const useThing = <UsedThing extends Thing>( |
| 88 | id: MaybeAccessor<Id | undefined>, |
| 89 | offset: Offsets, |
| 90 | ): Accessor<UsedThing | undefined> => { |
| 91 | const contextValue = useContext(Context)?.value ?? EMPTY_CONTEXT; |
| 92 | return () => { |
| 93 | const resolvedContextValue = contextValue(); |
| 94 | const resolvedId = getValue(id); |
| 95 | return ( |
| 96 | isUndefined(resolvedId) |
| 97 | ? resolvedContextValue[offset * 2] |
| 98 | : isString(resolvedId) |
| 99 | ? objGet( |
| 100 | resolvedContextValue[offset * 2 + 1] as IdObj<UsedThing>, |
| 101 | resolvedId, |
| 102 | ) |
| 103 | : resolvedId |
| 104 | ) as UsedThing; |
| 105 | }; |
| 106 | }; |
| 107 | |
| 108 | export const useThings = <UsedThing extends Thing>( |
| 109 | offset: Offsets, |
no test coverage detected
searching dependent graphs…