Skip to content

Commit 5f0d7d8

Browse files
authored
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
1 parent 513bc04 commit 5f0d7d8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

classes/switchmanager.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace switchblock {
2+
class SwitchManager {
3+
private switches: { [name: string]: SwitchContext } = {};
4+
5+
create(name: string): SwitchContext {
6+
const ctx = new SwitchContext();
7+
this.switches[name] = ctx;
8+
return ctx;
9+
}
10+
11+
get(name: string): SwitchContext {
12+
return this.switches[name];
13+
}
14+
15+
debug(name: string): void {
16+
const ctx = this.switches[name];
17+
console.log(`Switch "${name}" has ${ctx.caseCount()} cases`);
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)