@omnific/store
v0.4.1
Published
Jotai store helpers for Omnific applications
Readme
@omnific/store
Jotai store helpers for Omnific applications.
Installation
pnpm add @omnific/store jotai react@omnific/store includes its draft update engine internally. Applications no longer need to install
immer or jotai-immer for this package.
Draft atoms
createAtom creates a writable Jotai atom that accepts either a replacement value or a draft updater.
import { createAtom, setStoreValue } from '@omnific/store';
const userAtom = createAtom({
count: 0,
user: {
name: 'Ada',
},
});
setStoreValue(userAtom, draft => {
draft.count += 1;
draft.user.name = 'Grace';
});
setStoreValue(userAtom, {
count: 2,
user: {
name: 'Lin',
},
});Migration from Immer-backed atoms
createAtomkeeps the same runtime update shape for replacement values and draft updater callbacks.- The exported atom type is now
DraftAtom; replace imports ofImmerAtomwithDraftAtom. AtomDraftUpdaternow uses the draft type frommutativeinstead ofimmer.- Remove direct
immerandjotai-immerdependencies if they were only installed for@omnific/store.
