Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 4x 4x 6x 6x | import { hub } from '../hub'
import type { Rune, Slot } from '../../RuneHub'
/**
* Gets an existing slot for a rune without creating it.
* Returns undefined if the slot doesn't exist yet.
* @template T - The rune function type
* @param rune - The rune to get the slot for
* @returns The slot if it exists, undefined otherwise
* @example
* ```ts
* const count = () => 5
* getSlot(count) // undefined (not created yet)
* get(count) // 5 (creates slot)
* getSlot(count) // Slot instance
* ```
*/
export function getSlot<T extends Rune> (rune: T): Slot<ReturnType<T>> | undefined {
const currentHub = hub()
return currentHub.slots.get(rune) as Slot<ReturnType<T>>
}
|