{
  "version": 3,
  "sources": ["../src/constants.ts", "../src/subscribe.ts"],
  "sourcesContent": ["export const exomeId: unique symbol = Symbol();\nexport const exomeName: unique symbol = Symbol();\nexport const FUNCTION = \"function\";\nexport const CONSTRUCTOR = \"constructor\";\n", "import { exomeId } from \"./constants.ts\";\nimport type { Exome } from \"./constructor.ts\";\n\nexport const subscriptions: Record<string, Set<() => any>> = {};\n\n/**\n * Subscribe to store instance update events.\n */\nexport const subscribe = <T extends Exome>(\n\tstore: T | null | undefined,\n\tfn: (store: T) => void,\n): (() => void) => {\n\tif (store == null) {\n\t\treturn () => {};\n\t}\n\n\tconst set = (subscriptions[store[exomeId]] ??= new Set());\n\tconst update = () => fn(store);\n\n\tset.add(update);\n\n\treturn () => {\n\t\tset.delete(update);\n\t};\n};\n\n/**\n * Sends update event to specific store instance.\n */\nexport const update = (store: Exome): void => {\n\tfor (const fn of subscriptions[store[exomeId]]?.values?.() || []) {\n\t\tfn();\n\t}\n};\n\n/**\n * Sends update event to all existing store instances.\n */\nexport const updateAll = (): void => {\n\tObject.values(subscriptions).map((set) => {\n\t\tfor (const fn of set.values()) {\n\t\t\tfn();\n\t\t}\n\t});\n};\n"],
  "mappings": ";AAAO,IAAMA,IAAyB,OAAO,GAChCC,IAA2B,OAAO;;;ACExC,IAAMC,IAAgD,CAAC,GAKjDC,IAAY,CACxBC,GACAC,MACkB;AAXnB,MAAAC,GAAAC;AAYC,MAAIH,KAAS;AACZ,WAAO,MAAM;AAAA,IAAC;AAGf,MAAMI,KAAOD,IAAAL,EAAAI,IAAcF,EAAMK,CAAO,OAA3B,OAAAF,IAAAL,EAAAI,KAAkC,oBAAI,IAAI,GACjDI,IAAS,MAAML,EAAGD,CAAK;AAE7B,SAAAI,EAAI,IAAIE,CAAM,GAEP,MAAM;AACZ,IAAAF,EAAI,OAAOE,CAAM;AAAA,EAClB;AACD,GAKaA,IAAS,CAACN,MAAuB;AA7B9C,MAAAE,GAAAC;AA8BC,WAAWF,OAAME,KAAAD,IAAAJ,EAAcE,EAAMK,CAAO,CAAC,MAA5B,gBAAAH,EAA+B,WAA/B,gBAAAC,EAAA,KAAAD,OAA6C,CAAC;AAC9D,IAAAD,EAAG;AAEL,GAKaM,IAAY,MAAY;AACpC,SAAO,OAAOT,CAAa,EAAE,IAAI,CAACM,MAAQ;AACzC,aAAWH,KAAMG,EAAI,OAAO;AAC3B,MAAAH,EAAG;AAAA,EAEL,CAAC;AACF;",
  "names": ["exomeId", "exomeName", "subscriptions", "subscribe", "store", "fn", "_a", "_b", "set", "exomeId", "update", "updateAll"]
}
