Function sycamore_reactive::untrack
source · [−]pub fn untrack<T>(f: impl FnOnce() -> T) -> T
Expand description
Run the passed closure inside an untracked dependency scope.
See also ReadSignal::get_untracked()
.
Example
let state = create_signal(cx, 1);
let double = create_memo(cx, || untrack(|| *state.get() * 2));
// ^^^^^^^
assert_eq!(*double.get(), 2);
state.set(2);
// double value should still be old value because state was untracked
assert_eq!(*double.get(), 2);