PDA

View Full Version : [CLOSED-EXTJSIV-202] Attempted to bind an event listener to a function that...



kyr0
21 Mar 2011, 2:32 AM
Hi,

there is a timing issue in Ext Core when it comes to add listeners.
It's a common behaviour to have listener functions that become available
to the interpreter at a time AFTER addListener() is called.

It only counts for script execution that the event listener function is
available at the time, the listener needs to be executed.

But sadly, addListener checks for the availability of the listener function
at the time the listener is registered for an event. This produces execptions
in all cases written above: "uncaught exception: Ext.util.Event: Attempted
to bind an event listener to a function that does not exist.";

For my understanding this check can be removed.
1. It doesnt help you detect where the missing event listener is at definition time.
The exception provides no additional info!
2. An exception will be fired in any way - if it's checked at definition time or not
3. I don't think users will do:

try {
me.addListener(...);
} catch(e) {...}

Do you? ;)

Regards,

Jacky Nguyen
29 Mar 2011, 9:03 AM
Ext.util.Event#addListener needs a valid function callback as the first argument, which makes perfect sense. Could you describe a use case when an event listener needs to be attached when the callback function is not available yet?

Jacky Nguyen
29 Mar 2011, 9:15 AM
The error message has been made clearer, you should now see something like this:


[{COMPONENT_CLASS_NAME}#addListener -> Ext.util.Event#addListener] Invalid callback function: {GIVEN_ARGUMENT}

For example:


[Ext.button.Button#addListener -> Ext.util.Event#addListener] Invalid callback function: 'something'

You can then simply use the Call Stack feature of Chrome / Safari Developer Tools or Firefox Firebug to hunt down the violated invocation