1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jotai')) :
|
3 | typeof define === 'function' && define.amd ? define(['exports', 'jotai'], factory) :
|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jotaiRedux = {}, global.jotai));
|
5 | })(this, (function (exports, jotai) { 'use strict';
|
6 |
|
7 | function atomWithStore(store) {
|
8 | var baseAtom = jotai.atom(store.getState());
|
9 |
|
10 | baseAtom.onMount = function (setValue) {
|
11 | var callback = function callback() {
|
12 | setValue(store.getState());
|
13 | };
|
14 |
|
15 | var unsub = store.subscribe(callback);
|
16 | callback();
|
17 | return unsub;
|
18 | };
|
19 |
|
20 | var derivedAtom = jotai.atom(function (get) {
|
21 | return get(baseAtom);
|
22 | }, function (_get, _set, action) {
|
23 | store.dispatch(action);
|
24 | });
|
25 | return derivedAtom;
|
26 | }
|
27 |
|
28 | exports.atomWithStore = atomWithStore;
|
29 |
|
30 | Object.defineProperty(exports, '__esModule', { value: true });
|
31 |
|
32 | }));
|