@zedux/react
Version:
A Molecular State Engine for React
25 lines (24 loc) • 1.13 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getReactContext = exports.destroyed = exports.Static = exports.External = exports.Explicit = exports.ecosystemContext = void 0;
const react_1 = require("react");
exports.ecosystemContext = (0, react_1.createContext)('@@global');
/**
* These are copied from packages/atoms/src/utils/general.ts
*
* IMPORTANT: keep these in-sync with the ones in the atoms package
*/
exports.Explicit = 1;
exports.External = 2;
exports.Static = 4;
// export const Deferred = 8
exports.destroyed = Symbol.for(`@@zedux/destroyed`);
const getReactContext = (ecosystem, atom) => {
var _a, _b;
const reactStorage = ((_a = ecosystem._storage).react || (_a.react = {}));
const contexts = (reactStorage.contexts || (reactStorage.contexts = new WeakMap()));
const windowContexts = contexts.get(react_1.createContext) ||
contexts.set(react_1.createContext, {}).get(react_1.createContext);
return (windowContexts[_b = atom.key] || (windowContexts[_b] = (0, react_1.createContext)(undefined)));
};
exports.getReactContext = getReactContext;
;