Query event listeners

As I go through optimising code, one thing I’d love to get a handle on is the number of event listeners on objects. Particularly the Runtime object.

I notice that there are a few fields like _functionListeners and _tableListeners, but I assume they’re not supposed to be used by developers.

Ideally I’d love to see an addition to the EventListener API which returns the list of listeners, or the number of listeners.

Something like:

local enterFrameListeners=Runtime:listListeners("enterFrame")  
print (#enterFrameListeners .. " enterFrame listeners currently attached to the Runtime object")  

[import]uid: 102086 topic_id: 32497 reply_id: 332497[/import]

Lol, completely forgot about his post, hit the same problem and Google brought me back here again!

Well, turns out I still want to be able to query event listeners!

Hi @tap32,

I know it’s not really a “solution”, but you could build a little module that manages this, and add the name/type/etc. of listener to a table for your reference each time you create (add) it, then remove it by name when you remove it. Again, that’s not the best advice, but it would potentially do the trick.

Best regards,

Brent Sorrentino

Lol, completely forgot about his post, hit the same problem and Google brought me back here again!

Well, turns out I still want to be able to query event listeners!

Hi @tap32,

I know it’s not really a “solution”, but you could build a little module that manages this, and add the name/type/etc. of listener to a table for your reference each time you create (add) it, then remove it by name when you remove it. Again, that’s not the best advice, but it would potentially do the trick.

Best regards,

Brent Sorrentino