Atom

Atom is a unit of state in Space.

The instance created serves as a key to store values of a specified type in AtomStore. It is designed so that the instance itself acts as the reference key, instead of the user having to assign a unique key. Therefore, even if the definitions are exactly the same, different instances will be managed as separate keys.

Note: Specifying a saver is optional, but if you expect state restoration on the Android platform, it is crucial to specify it.

Usage:

val counterAtom = atom(0)
val titleAtom = atom("hello, world", saverKey = "title")

Parameters

T

The type of the value to be stored.

Properties

Link copied to clipboard

The initial value to be stored.

Link copied to clipboard
val saver: AtomSaver<T>? = null

The saver to be used to save and restore the value.

Link copied to clipboard
val scope: AtomScope? = null

The scope to be used to manage the value.