@jsvision/ui / untrack
Function: untrack()
untrack<
T>(fn):T
Defined in: ui/src/reactive/scheduler.ts:342
Run fn without subscribing the current computation to anything it reads. Use it inside an effect or computed to read a signal's current value without making that signal a dependency, so a later change to it will not trigger a re-run. The tracking context is restored afterwards.
Type Parameters
T
T
Parameters
fn
() => T
The function to run untracked.
Returns
T
Whatever fn returns.
Example
ts
import { signal, effect, untrack } from '@jsvision/ui';
const value = signal(0);
const label = signal('count');
effect(() => {
// Re-runs when `value` changes, but NOT when `label` changes (read untracked).
console.log(untrack(() => label()), '=', value());
});