API Reference / @evolu/common / Store
Store
Interfaces
Interface | Description |
---|---|
Store | A store for managing state with change notifications. Provides methods to retrieve the current state, update it, and notify listeners of changes. The state is immutable externally, with updates controlled via setState . Think of it as a lightweight, observable reference (akin to a Ref in functional programming) tailored for reactive state management. |
Type Aliases
Type Alias | Description |
---|---|
StoreListener | A callback invoked whenever the store's state updates. |
StoreSubscribe | Registers a listener for state changes, returning an unsubscribe function. |
StoreUnsubscribe | A function to remove a previously added listener. |
Functions
Function | Description |
---|---|
createStore | Creates a store with the given initial state. The store encapsulates a mutable reference to its state, exposed immutably via getState and updated via setState , with changes broadcast to subscribers. |