import{_ as i,o as a,c as n,ae as t}from"./chunks/framework.C8AWLET_.js";const o=JSON.parse('{"title":"🛑 Untracking: $.ignore( )","description":"","frontmatter":{},"headers":[],"relativePath":"api/ignore.md","filePath":"api/ignore.md"}'),e={name:"api/ignore.md"};function l(h,s,p,k,r,g){return a(),n("div",null,[...s[0]||(s[0]=[t(`
$.ignore( ) ​The $.ignore function allows you to read a signal's value inside an effect or a computed signal without creating a dependency.
$.ignore(callback: Function): any| Parameter | Type | Required | Description |
|---|---|---|---|
callback | Function | Yes | A function where signals can be read "silently". |
Returns: Whatever the callback function returns.
Normally, reading a signal inside $.effect makes the effect re-run when that signal changes. $.ignore breaks this link.
const count = $(0);
const logLabel = $("System Log");
$.effect(() => {
// This effect tracks 'count'...
const currentCount = count();
// ...but NOT 'logLabel'.
// Changing 'logLabel' will NOT re-run this effect.
const label = $.ignore(() => logLabel());
console.log(\`\${label}: \${currentCount}\`);
});
count(1); // Console: "System Log: 1" (Triggers re-run)
logLabel("UI"); // Nothing happens in console (Ignored)Inside complex UI logic, you might want to take a "snapshot" of a signal without triggering a reactive chain.
const handleClick = () => {
// Accessing state without letting the caller know we touched it
const data = $.ignore(() => mySignal());
process(data);
};If you need to write to a signal based on its own value inside an effect (and you aren't using the functional updater), $.ignore prevents the effect from triggering itself.
$.effect(() => {
const value = someSignal();
if (value > 100) {
// We update the signal, but we ignore the read to avoid a loop
$.ignore(() => someSignal(0));
}
});