sycamore::reactive

Function batch

pub fn batch<T>(f: impl FnOnce() -> T) -> T
Expand description

Batch updates from related signals together and only run memos and effects at the end of the scope.

ยงExample

let state = create_signal(1);
let double = create_memo(move || state.get() * 2);
batch(move || {
    state.set(2);
    assert_eq!(double.get(), 2);
});
assert_eq!(double.get(), 4);