Hi Scott. I''ve had the same problem. It would be very good if this
feature will be added to the next prototype release.
For now Iv''e made a simple ''enhanced'' setTimeout
function that I can
use in my classes based on prototype (JSON notation):
//set obj to null if you don''t need it
setTimeout:function(obj, func, delay, args){
//from milliseconds to seconds
var r = delay*1000;
var id=setInterval(callFunk,r);
function callFunk(){
clearInterval(id);
//func is a method of obj
func.apply(obj,args)
}
return id;
},
Usage in a class:
this.classId = this.setTimeout(this,this.classMethod,5,[arg1,arg2]);
To prematurely stop the timer:
clearInterval(this.classId);
Let me know if this is the answer! Luca.
On 1 Mag, 16:25, ScottW <sweik...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> I''ve poked around the API docs for Prototype and have yet to find
> anything related (no searchability, dangit), hence I''m posting
here.
>
> Is there a timeout param of any sort you can set for a Prototype
> function (updater, request, etc) that will cause the function to cease
> if it''s not done within the supplied time?
>
> I''ve got a status page in my main project that I''ve
recently ajaxed-up
> using Prototype. Usually, it will refresh the status info on a 15 sec
> timer (using setTimeout() to call itself). But - when certain criteria
> are present - the timer kicks down to 3 seconds, until the criteria
> change and it goes back to a 15 second interval.
>
> The trick I''m seeing is sometimes, when on the 3 second interval,
> status requests can ''back up'' a bit and stall out. What
I''d like to do
> is put, say, a 2.5 second timeout on the function itself.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---