All files / src/hooks/get get.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

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 204x                               4x 157x    
import { slot } from '../slot'
 
import type { Rune } from '../../RuneHub'
 
/**
 * Gets the current value of a rune with dependency tracking.
 * If called within another rune's computation, creates a dependency relationship.
 * @template T - The rune function type
 * @param rune - The rune to get the value from
 * @returns The current value of the rune
 * @example
 * ```ts
 * const count = () => 5
 * const value = get(count) // 5
 * ```
 */
export function get<T extends Rune> (rune: T): ReturnType<T> {
  return slot(rune).get()
}