Skip to content

Interface: CreateAtom()

API / @xmachines/play-atom / CreateAtom

Defined in: create-atom.ts:33

The two forms of createAtom

A function argument builds a COMPUTED atom, which reads its dependencies and gives a ReadonlyAtom. Any other argument builds a WRITABLE atom, which holds the value and gives an Atom.

A computed getter reads each dependency with the get of that dependency, and the engine records the edge as it reads. Its one parameter is the PREVIOUS value, which is undefined on the first derivation. @xstate/store 3 passed a read helper in that first position and the previous value in the second; version 4 dropped the helper, because get tracked the edge already.

Call Signature

CreateAtom<T>(getValue, options?): ReadonlyAtom<T>;

Defined in: create-atom.ts:34

The two forms of createAtom

A function argument builds a COMPUTED atom, which reads its dependencies and gives a ReadonlyAtom. Any other argument builds a WRITABLE atom, which holds the value and gives an Atom.

A computed getter reads each dependency with the get of that dependency, and the engine records the edge as it reads. Its one parameter is the PREVIOUS value, which is undefined on the first derivation. @xstate/store 3 passed a read helper in that first position and the previous value in the second; version 4 dropped the helper, because get tracked the edge already.

Type Parameters

Type Parameter
T

Parameters

ParameterType
getValue(previous?) => T
options?AtomOptions<T>

Returns

ReadonlyAtom<T>

Call Signature

CreateAtom<T>(initialValue, options?): Atom<T>;

Defined in: create-atom.ts:35

The two forms of createAtom

A function argument builds a COMPUTED atom, which reads its dependencies and gives a ReadonlyAtom. Any other argument builds a WRITABLE atom, which holds the value and gives an Atom.

A computed getter reads each dependency with the get of that dependency, and the engine records the edge as it reads. Its one parameter is the PREVIOUS value, which is undefined on the first derivation. @xstate/store 3 passed a read helper in that first position and the previous value in the second; version 4 dropped the helper, because get tracked the edge already.

Type Parameters

Type Parameter
T

Parameters

ParameterType
initialValueT
options?AtomOptions<T>

Returns

Atom<T>