Overview
setter wraps a plain function so that calling it also notifies subscribers and schedules the host component to re-render. Your state stays as ordinary let variables — there is no atom, no dependency tracking, and no per-read subscription cost.
Aliases $ and _ are identical to setter. Use them when you want a shorter call site; behavior is the same.
This is the lightest way to drive UI from local mutations. Prefer atom when you need derived values, effects, or shared reactive reads across components.
Compared to atom
|
Member
|
Status
|
Notes
|
|---|---|---|
let count + setter
| manual notify | Re-renders only when a setter is called. Reads are not tracked. |
atom(0)
| reactive |
Reads subscribe templates/effects; .set / .update notify automatically.
|
setter — plain local state
Plain let variables are not reactive. setter() wraps any mutation function and schedules a component re-render after the mutation runs — no atom overhead needed.
setter.set() — swap the fn
Keep the same callable identity (handlers stay valid) while swapping the underlying mutation with .set(). $ is an alias for setter.