[Pixlib] When to use custom event classes?
Marcelo de Moraes Serpa
celoserpa at gmail.com
Sun Oct 29 19:58:24 EST 2006
I thought I knew about pixlib's event model. However, I'm a little confused.
In ARP, I used MM's event dispatcher, so, when I wanted to dispatch a event,
I would dispatch an event object. This object had a property with the name
of the event to call.
Pixlib goes one step further providing support for custom event classes.
However, it's not clear on when I should create a custom event class
(extending BasicEvent) instead of using the BasicEvent directly.
Take Michael's (from deja-vue) pixlib MVC example. He has a OrderEvent
class. However, the EventList class has 3 eventTypes registered. Xavier's
sample does not use custom event classes at all.
My conclusion is that, custom event classes are useful only when the event
needs to carry a lot of data. Also, it's best to generalize it to the lower
common denominator (OrderEvent, for example instead of getOrdersEvent,
placeOrderEvent, cancelOrderEvent as all of these would use the same set of
data) instead of creating a event class for each of the events, if possible,
avoiding redundancy.. am I right?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pixlib