20 Feb 2012 1:05 PM #1
Best practices for configuration option that is an array?
I am porting a couple of applications and libraries over to ST2, and am really liking what I see. I have run into a bit of a question on the configuration system though. I have a custom component that is configured with a list of item configurations. I am not sure how to handle array values.
Are their any recommended best practices for configuration options that are arrays?
For example when adding an item to an array, it seems like you would call getMyItems() and then call push on it, but this would skip all the infrastructure for apply and update methods. How should this be handled with the new configuration system?
Also, in the previous class I had to initialize my configuration item list with a value of null to make sure it didn't get reused (ie. shared) across class instantiations. Is this handled automatically by the configuration system now, or do I need to do something explicit to make sure that default values don't get shared across multiple instances?
21 Feb 2012 7:54 AM #2
- Join Date
- Mar 2007
- Gainesville, FL
- Vote Rating
For items, if you want to add an item anywhere you can use the add/insert method. For custom ones, you can push to the array but I would then execute the set method with that new array. Then in the apply or update method you can take action on that array.Mitchell Simoens @SenchaMitch
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.