selectAction: (actionEvent) => {
if (action1 instanceof Action1) {
// action1 body implementation
} else if (action2 instanceof Action2) {
// action2 body implementation
}
}
The above code snippet reflects that different types of action which does different functionalities.I have used if and else condition to check action.
I feel it's not a better solution since i might have more actions in future and my if-else ladder will keep growing and i need to update my code again when there is a change.
Any Idea in improving this specific scenario
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire