Atom
TheAtom<T> type represents a writable reactive state container that can be read, written, and subscribed to for changes.
Type Definition
Properties
set
Sets the value of the atom. Can be called with either a new value directly or a function that receives the previous value and returns the new value.
Type:
get
Inherited from Readable<T>. Returns the current value of the atom.
Type:
subscribe
Inherited from Subscribable<T>. Subscribes to changes in the atom’s value.
Type:
Usage Examples
Setting values directly
Setting values with a function
Reading and subscribing
Working with complex state
Related Types
- ReadonlyAtom - A read-only version of Atom
- Observer - The observer pattern for subscriptions
- Subscription - The subscription object returned by subscribe
- AtomOptions - Configuration options for creating atoms