API reference › @evolu/common › Store › Store

Defined in: packages/common/src/Store.ts:20

A store for managing state with change notifications. Like a Ref with subscriptions.

Store is a valid dependency in Evolu's Dependency Injection pattern—use it when functions need shared mutable state with subscriptions.

Extends

Methods

[dispose]()

dispose: void;

Defined in: node_modules/@typescript/old/lib/lib.esnext.disposable.d.ts:34

Inherited from

ReadonlyStore.[dispose]

Properties

get

readonly get: () => T;

Defined in: packages/common/src/Store.ts:31

Returns the current state of the store.

Inherited from

ReadonlyStore.get


getAndSet

readonly getAndSet: (value: T) => T;

Defined in: packages/common/src/Ref.ts:54

Sets the current value and returns the previous value.

Inherited from

Ref.getAndSet


getAndUpdate

readonly getAndUpdate: (updater: (current: T) => T) => T;

Defined in: packages/common/src/Ref.ts:63

Updates the current value and returns the previous value.

Inherited from

Ref.getAndUpdate


modify

readonly modify: <R>(modifier: (current: T) => readonly [R, T]) => R;

Defined in: packages/common/src/Ref.ts:69

Modifies the current value and returns a computed result.

Inherited from

Ref.modify


set

readonly set: (value: T) => void;

Defined in: packages/common/src/Ref.ts:51

Sets the current value.

Inherited from

Ref.set


setAndGet

readonly setAndGet: (value: T) => T;

Defined in: packages/common/src/Ref.ts:57

Sets the current value and returns it.

Inherited from

Ref.setAndGet


subscribe

readonly subscribe: (listener: Listener) => Unsubscribe;

Defined in: packages/common/src/Store.ts:37

Registers a listener to be called on state changes and returns a function to unsubscribe.

Inherited from

ReadonlyStore.subscribe


update

readonly update: (updater: (current: T) => T) => void;

Defined in: packages/common/src/Ref.ts:60

Updates the current value.

Inherited from

Ref.update


updateAndGet

readonly updateAndGet: (updater: (current: T) => T) => T;

Defined in: packages/common/src/Ref.ts:66

Updates the current value and returns it.

Inherited from

Ref.updateAndGet