UNPKG

jotai

Version:

👻 Next gen state management that will spook you

34 lines (30 loc) • 776 B
System.register(['jotai'], (function (exports) { 'use strict'; var atom; return { setters: [function (module) { atom = module.atom; }], execute: (function () { exports('atomWithStore', atomWithStore); function atomWithStore(store) { const baseAtom = atom(store.getState()); baseAtom.onMount = (setValue) => { const callback = () => { setValue(store.getState()); }; const unsub = store.subscribe(callback); callback(); return unsub; }; const derivedAtom = atom( (get) => get(baseAtom), (_get, _set, action) => { store.dispatch(action); } ); return derivedAtom; } }) }; }));