Kyle Hayes

Tech, Musings, Life

Cairngorm: One-to-One Events and Commands Doesn't Make Sense

| Comments

I am struggling with a particular concept in Cairngorm. I don’t understand why it is considered best practice that your custom cairngorm events and commands are to have a one-to-one ratio. Flex itself is not even modeled this way. For example, when a button is clicked, you don’t listen for a class called ButtonClickEvent. Instead, you listen for the ButtonEvent.CLICK or ButtonEvent.DOWN or whatever the case is. In Cairngorm, how come you cannot do the same thing and list multiple event types in your event classes.

I am not suggesting to put all your types in one event class. But let’s say you have a UserEvent. You could call UserEvent.ADD_USER, UserEvent.DELETE_USER, UserEvent.LOGIN_USER, etc. That is all in one class instead of having three separate classes. Can someone please explain to me the reasoning for the one-to-one ratio please?

Thanks in advance!

Comments