Mutation Helpers Update reactive values without the boilerplate of manual get/mutate/set patterns edit Guide

Mutation Helpers

Helper Usage

A very common pattern when dealing with signals is to modify an existing signal value then update its underlying value triggering reactivity.

This can create a lot of boilerplate because you will need to access the value nonreactively and then update the underlying value before finally setting the value again.

Without Helpers
const numbers = signal([1, 2, 3]);
const newNumbers = numbers.peek();
newNumbers.push(4);
numbers.set(newNumbers);

Helpers handle updating an underlying reactive value without having to retrieve and manipulate the value.

With Helpers
const numbers = signal([1, 2, 3]);
numbers.push(4);

Types of Helpers

Helpers are provided for various types of signal primitives that help with the most common ways they are used.

Array Helpers

Array helpers make it easy to update array values with push, unshift and non-standard helpers like removeIndex, setIndex and others.

Collection Helpers

Collection helpers make it easy to update specific values in an array of records by their ID. id will match against _id, id, hash, key fields on any object in the array

Boolean Helpers

Boolean helpers like toggle make it easier to toggle boolean values.

API Reference

API Reference - You can learn more about individual mutation helpers in the API reference guide for reactivity.