PDA

View Full Version : Adding Custom Application Events and what is required.



Csegota
6 Feb 2014, 10:03 AM
I'm confused as to why this works, because I feel it should not.

I have a view that fires a custom event (I'm working on moving the logic out of the view but the question remains).
View:
this.fireEvent('someReallyCoolCustomEvent')

In my controller I have :
this.control({
'viewWidgetName': {
someReallyCoolCustomEvent: this.someCoolFunction
})

The bottom line is that I'm not adding(registering) the event name anywhere, there is just that listener in the controller and it works. I would expected to have to use an addEvents() or application.on().

Is this exactly how its supposed to work? Does this seem strange to anyone else? Is this a new feature of Extjs4?

What this tells me is that any events registered with custom names in any controller.control methods are automatically added to the global observable, and available globally in the application?(Am I saying that right?)

Can anyone confirm or deny?

Thanks!

jay@moduscreate.com
10 Feb 2014, 8:20 AM
The acting of adding an event listener OR firing event does the "addEvents()" step for you.

jay@moduscreate.com
10 Feb 2014, 8:20 AM
And yes, it's a new thing to Ext 4. It was discussed in threads a few years back :)

Csegota
10 Feb 2014, 11:10 AM
Cool, thanks for clarifying that for me!