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 25 26 | 4x 4x 5x | import { hub } from '../hub'
import type { Fn } from '../../RuneHub'
/**
* Executes an action without tracking dependencies.
* Temporarily disables dependency tracking during execution.
* Useful when you need to read values without creating reactive relationships.
* @template A - The action function type
* @param action - The action to execute without tracking
* @returns The result of the action
* @example
* ```ts
* const count = () => 5
*
* const doubled = () => {
* const value = unwatch(() => get(count)) // no dependency created
* return value * 2
* }
* // doubled won't update when count changes
* ```
*/
export function unwatch<A extends Fn<[]>> (action: A): ReturnType<A> {
return hub().unwatch(action)
}
|