atom
Creates a reactive state container.
Signature
Section titled “Signature”import { atom } from '@reaxium/core';
function atom<T>( initial: T, storageFactory?: StorageFactory<T>): Atom<T>
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
initial | T | Initial value of the atom. |
storageFactory | StorageFactory<T> | (Optional) Storage system to persist the atom’s value. Defaults to memory. |
Returns
Section titled “Returns”Type | Description |
---|---|
Atom<T> | An atom instance. |
Example
Section titled “Example”const count = atom(0);