-
25 Jul 2009 8:32 AM #1
Ability to NOT batch a request?
Ability to NOT batch a request?
I have a case where I'm loading a Portal page, and each portlet then goes off and asks for its content from the server. I'm converting this from RemoteComponent to an Ext.Direct based model.
I got it all working but realized that my portlets, which are asking for their content via Ext.Direct methods, are being batched up and sent to the server all at once. This makes sense, to keep server traffic down, and my router can handle it (Evan's .Net router) so it all "works", but it could be detrimental to the Portal experience. If one portlet takes a while to load, it holds up all of the others which could come back immediately.
What I'd like to do is, per call, tell Ext.Direct that I don't want it to batch the call with others. This way, I could tell my portlet calls to all go separately and be handled by the server on their own.
Is there a way to do this already and I'm just missing it? If not, is it something we could discuss and possibly add in? Or, is there a different way I should be handling the portlets in this case? (Yes, I know I can go back to RemoteComponent, but if there's an Ext.Direct way to do it, I'd rather do it that way.)
Thanks
Dave
-
25 Jul 2009 9:59 AM #2
Ok, I found the "enableBuffer" property on the provider level. I think this is exactly what I need, BUT it would be nice if this were defined on the method level.
I think what I might end up doing is creating multiple providers, one to contain the non-buffered actions and the other to contain everything else. This will be a bit of a pain because I'll have to further modify the router to be able to handle this, but its doable.
Dave
-
25 Jul 2009 10:53 AM #3
Ok, if anyone on the Ext dev team wants to do this, there here is my suggestion on one way to implement this:
change Ext.direct.RemotingProvider.queueTransaction to
And add this line in Ext.direct.RemotingProvider.doCall:Code:queueTransaction: function(t){ if(t.form){ this.processForm(t); return; } if (t.enableBuffer != undefined && !t.enableBuffer) { this.combineAndSend(); this.callBuffer.push(t); this.combineAndSend(); }else{ this.callBuffer.push(t); if(this.enableBuffer){ if(!this.callTask){ this.callTask = new Ext.util.DelayedTask(this.combineAndSend, this); } this.callTask.delay(typeof this.enableBuffer == 'number' ? this.enableBuffer : 10); }else{ this.combineAndSend(); } } },
in the "var t = new Ext.Direct.Transaction({" section.Code:enableBuffer: m.enableBuffer,
Then, if the API provider sends in "enableBuffer:false" on their method declaration, then buffering won't be enabled for that method, regardless of what the provider says.
I'll probably implement this as a UX on my side, but it would be nice if this were in the code properly as an optional feature.
-
25 Jul 2009 11:01 AM #4
And here's the quick and dirty ux if anyone else wants it.
Code:Ext.ux.BufferedProvider = Ext.extend(Ext.direct.RemotingProvider, { queueTransaction: function(t){ if(t.form){ this.processForm(t); return; } if (t.enableBuffer != undefined && !t.enableBuffer) { this.combineAndSend(); this.callBuffer.push(t); this.combineAndSend(); }else{ this.callBuffer.push(t); if(this.enableBuffer){ if(!this.callTask){ this.callTask = new Ext.util.DelayedTask(this.combineAndSend, this); } this.callTask.delay(typeof this.enableBuffer == 'number' ? this.enableBuffer : 10); }else{ this.combineAndSend(); } } }, doCall : function(c, m, args){ var data = null, hs = args[m.len], scope = args[m.len+1]; if(m.len !== 0){ data = args.slice(0, m.len); } var t = new Ext.Direct.Transaction({ provider: this, args: args, action: c, method: m.name, enableBuffer: m.enableBuffer, data: data, cb: scope && Ext.isFunction(hs) ? hs.createDelegate(scope) : hs }); if(this.fireEvent('beforecall', this, t) !== false){ Ext.Direct.addTransaction(t); this.queueTransaction(t); this.fireEvent('call', this, t); } } });
-
27 Jul 2009 1:37 PM #5
Very Nice! Thank you for sharing this
-
27 Jul 2009 4:11 PM #6
Seems like a good idea.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
27 Jul 2009 7:57 PM #7
Yes, it is definitely a very good idea. I'm thinking it would be okay to let Ext.Direct buffer requests by default unless a request contains an option, that indicates otherwise, like buffered:false. What do you think?
Eugene
Ext.Direct for ASP.NET MVC
-
27 Jul 2009 8:09 PM #8
I would think the behaviour should be that the request will default to whatever is specified in the provider, unless an option is explicitly defined on the request itself.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
27 Jul 2009 8:58 PM #9
Eugene
Ext.Direct for ASP.NET MVC
-
27 Jul 2009 11:09 PM #10


Reply With Quote

So are you guys going to make this change in SVN or something?