|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Re: IO Pipeline TopicsCan we use existing I/O topics for that?
Eugene Lazutkin Dojo Toolkit, Committer http://lazutkin.com/ On 08/26/2009 01:22 PM, James Burke wrote: > You could override dojo.xhr() to add that onError block to each set of > args passed in. Warning, this has not been tested, but hopefully gives > you enough to work out a proper solution: > > var oldXhr = dojo.xhr; > dojo.xhr = function(method, args, hasBody){ > //Make sure to not mess with original args in case they are reused > var oldError = args.error; > args = dojo.delegate(args); > args.error = function(err, ioArgs) { > //Call the old error function. > if(oldError){ > oldError.apply(args, arguments); > } > > //Do general work here. > if(request.xhr.status == 403){ > alert("expired"); > } > } > return oldXhr.call(dojo, method, args, hasBody); > } > > James > > On Wed, Aug 26, 2009 at 8:53 AM, Zhaidarbek > Ayazbayev<zhaidarbek@...> wrote: >> Good morning everyone! >> Resending my previous email: >> >> I need to handle session timeouts wiht ajax. If session is invalid my server >> responds with 403 status code. In simplest case it is handled as: >> dojo.xhrGet({ >> onError: function(errorData, request){ >> if(request.xhr.status == 403){ >> alert("Your session expired!"); >> } >> }}); >> >> But i have different dojo xhr requests (get, post, put, delete) throughout >> the page, also data stores uses ajax to fetch data from server. So i need to >> do it at one place. What is the best/right way to implement it? Seems like >> dojo pipelines is the way to go, but i don't know how to use it, could you >> please provide an example code. >> Thanks in advance. >> _______________________________________________ >> FAQ: http://dojotoolkit.org/support/faq >> Book: http://docs.dojocampus.org >> Dojo-interest@... >> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest >> >> > _______________________________________________ > FAQ: http://dojotoolkit.org/support/faq > Book: http://docs.dojocampus.org > Dojo-interest@... > http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest > _______________________________________________ FAQ: http://dojotoolkit.org/support/faq Book: http://docs.dojocampus.org Dojo-interest@... http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest |
|
|
Re: IO Pipeline TopicsWhat I meant is to use "/dojo/io/error". It can be used as a default
fallback for errors. Obviously for it to work properly an application should not set error handlers or ignore globally processed errors. Something like that: var d = dojo; d.subscribe("/dojo/io/error", function(err, ioArgs){ switch(ioArgs.xhr.status){ case 403: alert("Your session expired!"); break; case 500: alert("Server is down, please try again in 5 minutes."); break; ... } }); ... // let topics handle all errors d.xhrGet({ ... // no error() at all }); ... // let's ignore common errors d.xhrGet({ ... error: function(err, ioArgs){ if(ioArgs.xhr.status == 403){ // skip it => defer to the global processing }else{ // other error processing alert("Some bad thing happened!"); } } }); Or something like that. Topics look like the appropriate place for all default error handling. Another good use of topics is to show I/O indicator ("Loading...", "Busy", or an animated GIF) with "/dojo/io/start" and "/dojo/io/stop". The same topics can be used to warn end users against navigating from a page when I/O is still active, but if we ignore all read-only I/O and want to track a particular "write" I/O request, we can use "/dojo/io/send" and "/dojo/io/done". With properly designed I/O between clients and a server (e.g., a "universal" structure of transferred data, so it can be inspected without going into much specifics) the possibilities are endless. Thanks, Eugene Lazutkin Dojo Toolkit, Committer http://lazutkin.com/ On 08/27/2009 10:24 PM, James Burke wrote: > The IO topics are after the fact, they notify that an IO action > happened, not something that happens before. > > We might be able use a default mixin set of properties that are mixed > in with all requests, but that would be something new. > > James > > On Thu, Aug 27, 2009 at 3:23 PM, Eugene > Lazutkin<eugene.lazutkin@...> wrote: >> Can we use existing I/O topics for that? >> >> Eugene Lazutkin >> Dojo Toolkit, Committer >> http://lazutkin.com/ >> >> On 08/26/2009 01:22 PM, James Burke wrote: >>> You could override dojo.xhr() to add that onError block to each set of >>> args passed in. Warning, this has not been tested, but hopefully gives >>> you enough to work out a proper solution: >>> >>> var oldXhr = dojo.xhr; >>> dojo.xhr = function(method, args, hasBody){ >>> //Make sure to not mess with original args in case they are reused >>> var oldError = args.error; >>> args = dojo.delegate(args); >>> args.error = function(err, ioArgs) { >>> //Call the old error function. >>> if(oldError){ >>> oldError.apply(args, arguments); >>> } >>> >>> //Do general work here. >>> if(request.xhr.status == 403){ >>> alert("expired"); >>> } >>> } >>> return oldXhr.call(dojo, method, args, hasBody); >>> } >>> >>> James >>> >>> On Wed, Aug 26, 2009 at 8:53 AM, Zhaidarbek >>> Ayazbayev<zhaidarbek@...> wrote: >>>> Good morning everyone! >>>> Resending my previous email: >>>> >>>> I need to handle session timeouts wiht ajax. If session is invalid my server >>>> responds with 403 status code. In simplest case it is handled as: >>>> dojo.xhrGet({ >>>> onError: function(errorData, request){ >>>> if(request.xhr.status == 403){ >>>> alert("Your session expired!"); >>>> } >>>> }}); >>>> >>>> But i have different dojo xhr requests (get, post, put, delete) throughout >>>> the page, also data stores uses ajax to fetch data from server. So i need to >>>> do it at one place. What is the best/right way to implement it? Seems like >>>> dojo pipelines is the way to go, but i don't know how to use it, could you >>>> please provide an example code. >>>> Thanks in advance. >>>> _______________________________________________ >>>> FAQ: http://dojotoolkit.org/support/faq >>>> Book: http://docs.dojocampus.org >>>> Dojo-interest@... >>>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest >>>> >>>> >>> _______________________________________________ >>> FAQ: http://dojotoolkit.org/support/faq >>> Book: http://docs.dojocampus.org >>> Dojo-interest@... >>> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest >>> >> >> _______________________________________________ >> FAQ: http://dojotoolkit.org/support/faq >> Book: http://docs.dojocampus.org >> Dojo-interest@... >> http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest >> > _______________________________________________ > FAQ: http://dojotoolkit.org/support/faq > Book: http://docs.dojocampus.org > Dojo-interest@... > http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest > _______________________________________________ FAQ: http://dojotoolkit.org/support/faq Book: http://docs.dojocampus.org Dojo-interest@... http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest |
| Free embeddable forum powered by Nabble | Forum Help |