From 5f0d7d863974fe42e937e9b3ae6b1563fd9d673c Mon Sep 17 00:00:00 2001 From: Nate VanBuskirk Date: Tue, 9 Sep 2025 05:36:48 -0500 Subject: [PATCH] Create switchmanager.ts and populate it so we no longer need a shared object that is "dumb" - instead we can "enlighten" it by transforming it into a manager for the SwitchContext instances --- classes/switchmanager.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 classes/switchmanager.ts diff --git a/classes/switchmanager.ts b/classes/switchmanager.ts new file mode 100644 index 0000000..9335234 --- /dev/null +++ b/classes/switchmanager.ts @@ -0,0 +1,20 @@ +namespace switchblock { + class SwitchManager { + private switches: { [name: string]: SwitchContext } = {}; + + create(name: string): SwitchContext { + const ctx = new SwitchContext(); + this.switches[name] = ctx; + return ctx; + } + + get(name: string): SwitchContext { + return this.switches[name]; + } + + debug(name: string): void { + const ctx = this.switches[name]; + console.log(`Switch "${name}" has ${ctx.caseCount()} cases`); + } + } +}