(oref: string, key: T)
| 137 | } |
| 138 | |
| 139 | function getOrefMetaKeyAtom<T extends keyof MetaType>(oref: string, key: T): Atom<MetaType[T]> { |
| 140 | const orefCache = getSingleOrefAtomCache(oref); |
| 141 | const metaAtomName = "#meta-" + key; |
| 142 | let metaAtom = orefCache.get(metaAtomName); |
| 143 | if (metaAtom != null) { |
| 144 | return metaAtom; |
| 145 | } |
| 146 | metaAtom = atom((get) => { |
| 147 | const objAtom = WOS.getWaveObjectAtom(oref); |
| 148 | const objData = get(objAtom); |
| 149 | return objData?.meta?.[key]; |
| 150 | }); |
| 151 | orefCache.set(metaAtomName, metaAtom); |
| 152 | return metaAtom; |
| 153 | } |
| 154 | |
| 155 | function useOrefMetaKeyAtom<T extends keyof MetaType>(oref: string, key: T): MetaType[T] { |
| 156 | return useAtomValue(getOrefMetaKeyAtom(oref, key)); |
no test coverage detected