Created
September 25, 2011 17:51
-
-
Save gimmi/1240891 to your computer and use it in GitHub Desktop.
Ext.Direct with MVC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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