UNPKG

@zedux/atoms

Version:

A Molecular State Engine for React

20 lines (19 loc) 715 B
import { createStore } from '@zedux/core'; import { setStack, stack } from '../classes/EvaluationStack.js'; export let internalStore = createStore(null, {}); export const getEcosystem = (id) => internalStore.getState()[id]; export const getInternals = () => ({ stack, store: internalStore }); /** * Used in child windows. Makes different instances of Zedux reuse the parent * window's internal store and evaluation stack. */ export const setInternals = (internals) => { internalStore = internals.store; setStack(internals.stack); }; export const wipe = () => { const ecosystems = Object.values(internalStore.getState().ecosystems); ecosystems.forEach(es => { es.destroy(true); }); };