views:

22

answers:

1

I have ItemRenderers that need to listen for events. When they hear an event (and when data changes), they dispatch an event with their current data value.

As item renderers are reused, each of them is going to add its callback in set data(value...)and pass the callback function in the event as well as the current data value.

So, the listener of the item renderer's bubbling event will set someEventDispatcher.addEventListener("someEvent", itemRendererEvent.callbackListener). This will happen more than once.

Does setting the same event listener on the same event for the same dispatcher waste resources? Does the displatcher see that it already has the listener?

A: 

I believe other than the initial call to add the listener, it doesn't waste resources.

However it's a good idea not to add any listeners unnecessarily, and it's also a good idea to keep any sort of business logic out of getter / setters, but that's strictly for the sake of code legibility.

quoo