PDA

View Full Version : MVC: Application events handling



parovoz
28 Sep 2011, 2:24 AM
I have a question concerning two types of application event handling. Both cases are correct and works fine. But it would be nice to know the real difference (performance, etc).

As I mentioned I just want to set up a listener to some application event.

1) Use "ComponentQuery" approach:

MyController.js



...
init: function() {
this.control({
'*' : {
refreshDevelopGrid: this.onRefreshDevelopGrid
}
});
}
...


2) Use "AddListener" approach:

MyController.js



...
init: function() {
this.application.on({
refreshDevelopGrid : this.onRefreshDevelopGrid ,
scope: this
});
}
...


What diff with these two approaches?

mitchellsimoens
28 Sep 2011, 7:53 AM
Under the hood, control() puts the listeners into the EventBus where on() will not.

parovoz
28 Sep 2011, 7:58 AM
Hm, ok. But actually what the difference? Sencha doc doesn't give enouph information about EventBus.
Can you give me suggestion which aproach is the right and the best one?

mitchellsimoens
28 Sep 2011, 8:00 AM
Hm, ok. But actually what the difference? Sencha doc doesn't give enouph information about EventBus.
Can you give me suggestion which aproach is the right and the best one?

Our suggested way of adding listeners is with control().