UNPKG

961 BJavaScriptView Raw
1!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("valtio/vanilla"),require("jotai")):"function"==typeof define&&define.amd?define(["exports","valtio/vanilla","jotai"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).jotaiValtio={},t.vanilla,t.jotai)}(this,(function(t,n,e){"use strict";var o=function(t){return"object"==typeof t&&null!==t},i=function t(n,e,i){Object.getOwnPropertyNames(e).forEach((function(a){a in i?Object.is(e[a],i[a])||(o(n[a])&&o(e[a])&&o(i[a])?t(n[a],e[a],i[a]):n[a]=i[a]):delete n[a]})),Object.keys(i).forEach((function(t){t in e||(n[t]=i[t])}))};t.atomWithProxy=function(t,o){var a=e.atom(n.snapshot(t));return a.onMount=function(e){var i=function(){e(n.snapshot(t))},a=n.subscribe(t,i,null==o?void 0:o.sync);return i(),a},e.atom((function(t){return t(a)}),(function(e,o,u){var f="function"==typeof u?u(e(a)):u;i(t,n.snapshot(t),f)}))},Object.defineProperty(t,"__esModule",{value:!0})}));