"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useMinistore = useMinistore; const react_1 = require("react"); const Application_1 = require("../components/Application"); function useMinistore(key, initialValue) { const ministore = (0, react_1.useContext)(Application_1.MinistoreContext); if (ministore === null) throw new Error(`Expected this hook to run with a ministore context attached`); if (typeof key === `undefined`) return ministore.getAll(); const setValue = (0, react_1.useCallback)((newValue) => { ministore.set(key, newValue); }, [key, ministore.set]); let value = ministore.get(key); if (typeof value === `undefined`) value = initialValue; return [value, setValue]; }