API reference / @evolu/common / Store / createStore

Function: createStore()

function createStore<T>(initialState, eq): Store<T>;

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

Creates a store with the given initial state. The store encapsulates its state, which can be read with get and updated with set or modify. All changes are broadcast to subscribers.

By default, state changes are detected using === (shallow equality). You can provide a custom equality function as the second argument.

Type Parameters

Type Parameter
T

Parameters

ParameterTypeDefault value
initialStateTundefined
eqEq<T>eqStrict

Returns

Store<T>

Was this page helpful?