Is there a better way to write a switch statement in typescript? I have this following code in 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 reading about the strategy and/or factory pattern, but that would mean creating different classes for each case. In my case I'm not so sure it might be the best approach but any advice regarding this topic is very welcomed.
Aucun commentaire:
Enregistrer un commentaire