Browse documentation

createMutableStore

Creates a mutable store with named pulse methods.

Table of contents

Category

Value

Import

js
import { createMutableStore } from "valyrian.js/pulses";

Public signature

ts
createMutableStore<StateType extends Record<string, any>, PulsesType extends Record<string, Pulse<StateType, any>>>(initialState: StateType, pulses: PulsesType & ThisType<PulsesType & PulseContext>): StorePulses<PulsesType> & { state: ProxyState<StateType>; on: (event: string, callback: Function) => void; off: (event: string, callback: Function) => void; }

API form

createMutableStore is a factory. It returns the same named pulse surface as createPulseStore with publicly mutable state.

Returned surface and restriction

Direct writes to state do not notify rendered subscribers. Named pulse methods retain the normal pulse notification path.

ts
type ProxyState<StateType> = StateType & { [key: string]: any };

state: ProxyState<StateType>
...namedPulseMethods
on("pulse", callback): void
off("pulse", callback): void