Skip to content

Instantly share code, notes, and snippets.

@gimmi
Created September 25, 2011 17:51
Show Gist options
  • Save gimmi/1240891 to your computer and use it in GitHub Desktop.
Save gimmi/1240891 to your computer and use it in GitHub Desktop.
Ext.Direct with MVC
/*
First problem: referencing direct action in proxies/FormPanels
When using Ext.Direct with either Ext.data.proxy.Direct or Ext.form.Basic, you have to specify the function directly, so the function MUST previously be defined by calling Ext.direct.Manager.addProvider. This is a problem because normally the call to addProvider comes after the config evaluation.
For example
*/
Ext.create('Ext.data.proxy.Direct', {
api: {
create: MyApp.mynamespace.MyAction.myMethod // This work only if Direct API is already defined
}
});
/*
A solution for this problem can be to support specifying Direct methods by string, eg:
*/
Ext.create('Ext.data.proxy.Direct', {
api: {
create: 'MyApp.mynamespace.MyAction.myMethod' // This is a string, that will be evaluated to a Direct function just before it will be called
}
});
/*
At this point you can safely add Ext.direct.Manager.addProvider call in Ext.app.Application constructor, eg:
*/
Ext.define('Ext.app.Application', {
constructor: function(config) {
if(config.directApi) {
Ext.syncRequire('Ext.direct.Manager');
Ext.direct.Manager.addProvider(directApi);
}
// The rest ...
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment