mardi 27 avril 2021

Command Design Pattern VS Callback in JS/TS

I read a lot of examples in the internet with the same idea that not to hardcode some action you use a command.

Example

Let's say you are developing a fancy UI kit. You are of course developing something that needs to be reused, so if you build a Button component, you want it to be able to execute any action, you don't want to hard-code one.

Assuming i don't need an undo mechanism when should i prefer command over callbacks?

Aucun commentaire:

Enregistrer un commentaire