18 Nov 2012 8:34 AM #1
Advanced class system: how does Evented, eventedConfig, and fireAction work
I am trying to decipher some of the sencha touch components so I can extend them. It looks like they make pretty extensive use of a capability in the class system that I can't find documented anywhere. Namely how Evented, eventedConfig, and fireAction work together to to provide common functionality to components.
From what I have been able to determine so far, If an object derived from Evented has a config for 'eventedConfig', it will define configuration settings that are treated differently from normal class configuration.
It appears to override the setters for properties to introduce:
* calls applier to get value to apply
* if value has changed from old to new (value to apply)
* If it has been initialized in past, fireAction [property]change
* Internally calls before and after listeners??
* Call doSet[Property] method to set the value
Is this accurate and is this documented more completely somewhere else? What else does it do beyond the capabilities of "normal" configuration properties?
What exactly does fireAction do and what does it cause the system to send out?
What can the user do with these capabilities? For example can we intercept some of the events sent by fireAction to change or abort setting values?
Sorry for all the questions, I am just trying to understand this area more completely so I can understand the base components better in the system.
20 Nov 2012 5:59 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
The Evented class is just an abstract class that mixes in the Observable mixin so it can work with events.
eventedConfig differs from the config object in that Evented generates the setters for it and uses fireAction. The config object doesn't use the fireAction for it's setters.
fireAction allows for configurable events and will execute a method. You can use the order event option to specify when you want to listen to an event before or after the method is executed. So if you have order : 'before' it will fire the event before the method is executed and you can return false in that listener to prevent the method from being executed. If you have order : 'after' it will fire the event after the method has been executed.Mitchell Simoens @LikelyMitch
Sencha Inc, Senior Software Engineer
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services email@example.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!
When posting code, please use BBCode's CODE tags.