Store Utilities

createMutable

Edit this page

createMutable creates a new mutable Store proxy object that provides a way to selectively trigger updates only when values change.

By intercepting property access, it allows automatic tracking of deep nesting via proxy making it useful for integrating external systems or serving as a compatibility layer with frameworks like MobX or Vue.

function createMutable<T extends StoreNode>(state: T | Store<T>): Store<T>;
import { createMutable } from "solid-js/store";
const state = createMutable({
someValue: 0,
list: [],
});
// read value
state.someValue;
// set value
state.someValue = 5;
state.list.push(anotherValue);

Mutables support setters along with getters.

const user = createMutable({
firstName: "John",
lastName: "Smith",
get fullName() {
return `${this.firstName} ${this.lastName}`;
},
set setFullName(value) {
[this.firstName, this.lastName] = value.split(" ");
},
});
Report an issue with this page