Overview
These helpers extend the core atom model for two common needs: timed writes (debouncedAtom) and a reactive page index (paginationAtom).
debouncedAtom(sourceOrValue, delay) accepts either a plain initial value or a source atom. Writes (or mirrored source changes) wait until delay ms of quiet — only the last value in the window commits. Timer cleanup is registered automatically.
paginationAtom(initial?) is a full AtomType<number> plus next(), prev() (floors at 1), reset(), and a currentPage alias — not a separate pageSize/totalPages object.
Browser persistence bags (lsStore / ssStore) live on useUtils() — see Storage. Theme and document title are covered under themeAtom / titleAtom.
Which helper
|
Helper
|
Role
|
Notes
|
|---|---|---|
debouncedAtom
| timed writes | Last write in the delay window fires; good for search / autosave. |
paginationAtom
| page number | Atom<number> helpers — use with your own total/pageSize logic. |
lsStore / ssStore
| persist | Dedicated page — /docs/state/storage. |
Pagination cheatsheet
// paginationAtom — AtomType<number> helpers
const page = paginationAtom(1);
page.next(); // 2
page.prev(); // 1 (never below 1)
page.set(10); // jump
page.reset(); // back to 1
// Persistence → useUtils().lsStore / ssStore
// See /docs/state/storage
debouncedAtom — debounced search
The raw query atom updates on every keystroke, but the debounced atom only propagates changes after the user stops typing for 400 ms — ideal for search inputs that trigger API calls.
paginationAtom — page index
next / prev / reset helpers on a normal number atom. prev() floors at 1; pair with your own totalPages math.