untrack
Runs a function and returns its result without subscribing the current observer to anything it reads.
untrack<T>(fn: () => T): Timport { observe, untrack } from "https://cdn.jsdelivr.net/npm/@realmorg/realm@alpha/dist/index.js";
observe(() => {
const query = search.query;
const limit = untrack(() => settings.limit);
run(query, limit);
});The observer above re-runs when search.query changes, not when settings.limit changes.
Notes
- Writes inside
fnstill notify other observers. - In a component script,
untrackis available as a helper, likeobserve. Outside components, import it from the module.