PDA

View Full Version : [FIXED] Ext.Direct is extremely difficult to use with CMD



themightychris
27 Oct 2012, 9:13 AM
Ext.Direct needs some rethinking with CMD in the picture... in this thread I suggested that directFn method stings be resolved at use instead of at proxy construction, I'm bringing this back up here since that thread was for an old version of Ext: http://www.sencha.com/forum/showthread.php?189632-4.1RC2-ExtDirect-Proxy-API-Config-and-MVC

The problem lie in models instantiating their static proxy at definition time and controllers instantiating their stores before init()/launch(). There is no good place to create your RemotingProvider before that so the directFn strings can be resolved to functions correctly. Controller.init and Controller.launch both run after controller stores get instantiated, and when an app is compiled with CMD you can't even require models before the direct provider has been set up, meaning you have to awkwardly require Ext.direct.* manually, add the provider, and not define or create any part of your application until after all that finishes.

This would easily be solved and Ext.Direct class dependencies would be much simpler to manage if the directFn options were left as string until first use rather than converted during proxy instantiated.

dongryphon
28 Oct 2012, 4:54 PM
Thanks for the report! I am opening a ticket so we can take a look at this.

ldonofrio
9 Nov 2012, 6:28 AM
I'm using this


// direct proxy bugs reparse directFn and api on each request (works with loader)
Ext.define('Ext.bugs.data.proxy.Direct', {
override: 'Ext.data.proxy.Direct',
constructor: function(config) {
var me = this,
api = Ext.clone(config.api),
directFn = Ext.clone(config.directFn);


me.callParent(arguments);


if (directFn && !me.directFn) {
me.directFn = directFn;
}
if (api) {
for (var fn in api) {
if (api.hasOwnProperty(fn) && !me.api[fn]) {
me.api[fn] = api[fn];
}
}
}
},
doRequest: function(operation, callback, scope) {
var me = this;


if (me.directFn) {
me.directFn = Ext.direct.Manager.parseMethod(me.directFn);
}


if (me.api) {
for (var fn in me.api) {
if (me.api.hasOwnProperty(fn)) {
me.api[fn] = Ext.direct.Manager.parseMethod(me.api[fn]);
}
}
}
me.callParent(arguments);
}
});

billtricarico
9 Nov 2012, 9:28 AM
Yes I was about to start a thread of my own on this topic. I copied the DirectApi JSON down from the server side and ran the sencha command line tool to build the jsb3 file but no dice. I think the build command should have a command line option to ignore variables (from DirectApi calls) that do no resolve.