CodeVetter · Repo Unpack · Extension points
pmndrs/jotai
Atoms and store adapters are the principal composition interfaces. Public utilities accept application-supplied selectors, equality functions, storage implementations, observables, and callbacks. Internal store hooks and replaceable building blocks offer deeper instrumentation but explicitly carry compatibility warnings. Website documentation extends through MDX content and a shared component map.
- New state abstractions can be implemented as atom(read, write): read receives dependency get and an AbortSignal option, while write receives get/set plus arbitrary typed arguments and can return an application-defined result.
- Writable atoms support onMount(setAtom) returning cleanup; INTERNAL_onInit receives the store on first reference. The latter is explicitly internal and unstable.
- createStore provides independently owned state, Provider accepts an existing store, and INTERNAL_overrideCreateStore receives the previous override to replace store construction.
- SyncStorage/AsyncStorage define getItem/setItem/removeItem plus optional subscribe; createJSONStorage accepts string-storage factories and JSON reviver/replacer functions, enabling sessionStorage or custom async backends.
- selectAtom accepts selector and equality callbacks, splitAtom accepts a keyExtractor, and unwrap accepts a fallback using the previously resolved value; memoization depends on these function/object identities.
- atomWithObservable accepts a dependency-aware getObservable factory and subscribable or Symbol.observable-style sources; subject-like sources additionally expose writes through next(data). useAtomCallback adapts arbitrary get/set callbacks to a memoized write-only atom.
- INTERNAL_buildStoreRev4 merges Partial<BuildingBlocks> into defaults, freezes the block table, and exports keyed accessors; experimental store hooks provide creation/read/change/mount/unmount/flush listeners. Internal consumers are told to pin versions.
- Adding MDX under docs feeds Gatsby's filesystem source and slug-based page template; frontmatter.nav controls navigation sorting, while gatsby-shared.js maps MDX elements and embedded demo components to website renderers.