PDA

View Full Version : Move config.io to Ext.io.Controller?



existdissolve
5 Jun 2012, 4:47 AM
As part of my experimentation with Ext.io.Controller, I've created an Authentication controller that simply extends Ext.io.Controller and implements custom methods as necessary. Seems to work just fine.

At the moment, all of the config for io is set in the main application config. Just a thought, but does it make sense to allow that configuration to be set in the controller itself (or extends of the controller)?

The following worked for me:


Ext.define('MyApp.controller.Authentication', {
extend: 'Ext.io.Controller',
config: {
io: {
logLevel: 'debug',
appId: '5udcINurg7MjiKE3wpQwemKhnlS',
appSecret: 'Psyp6ttPyBO2W5WU',
authOnStartup: false,
manualLogin: true
}
}
})

And then a slight mod in sencha-io-debug (line 16022, build:0.8.7):


var conf = this.config.io;

16123:

auth: function() {
this.login(!this.config.io.manualLogin);
}

Thoughts?

jason.cline
5 Jun 2012, 7:10 PM
Thanks for the feedback. We could build the controller this way where the developer extends Controller like they do Stores and add their configuration and extensions. We will explore this as we continue to refine the API.

The main reason why the config is part of the application at the moment is because you can only have one sencha.io application configured and running at a time. If the config is part of the controller then someone might be tempted to have two controllers in the same application with different configs which at the moment would cause problems.

existdissolve
5 Jun 2012, 7:31 PM
Ah, that makes sense. Thanks!