Looking for a more efficient way to implement a switch statement in TypeScript? Here is the current code snippet from a component:
switch (actionType) {
case Type.Cancel {
this.cancel();
break;
}
case Type.Discard {
this.discard();
break;
}
case Type.Delete {
this.delete();
break;
}
}
I've been exploring the strategy and/or factory pattern as alternatives, but they involve creating different classes for each case. I'm undecided on whether this is the best approach for my situation, so any insights on this topic would be greatly appreciated.