i'm refactoring code to make some better abstractions. partway thru, i end up with a thing that looks like
interface IFoo {
readonly id: string;
foo: () => boolean;
bar: (x: number) => () => void;
}
class FooDispatcher {
private map = new Map<string, IFoo>();
public constructor(fooList: IFoo[]) {
fooList.forEach((foo) => this.map.set(foo.id, foo));
}
public foo(id: string) {
return this.map.get(id)?.foo() ?? false;
}
public bar(id: string, x: number) {
return this.map.get(id)?.bar(x) ?? (() => {});
}
}
my eye twitches. i daydream about writing some awesomely complicated metaprogramming solution in Haskell. i sigh, save & close the file, and wait an entire minute for Typescript to typecheck everything during the commit hook.
