PeriodicalExecuter that doesn't stack

10 views
Skip to first unread message

williamt

unread,
Nov 10, 2009, 2:55:16 AM11/10/09
to Prototype & script.aculo.us
Im looking for a way to make PeriodicalExecuter not stack plus add in
a max period setting.

If PeriodicalExecuter could call a function instead of a url I could
set/clear some flags
so it would or wouldn't make the call depending on the flags.
But I don't see how I could do that unless I could make it call a
function and not a url.

I think a max period would have to be hacked into prototype. I'm not
sure on that one though.

Anyone have any thoughts on how I could achieve this?
Basically PeriodicalExecuter that doesn't stack plus a max period
setting.

Thanks,
William

Alex McAuley

unread,
Nov 10, 2009, 7:00:46 AM11/10/09
to prototype-s...@googlegroups.com
I wasn't aware that PeriodicalExecuter did call a URL...

Ajax.PeriodicalUpdater does...


If you want to just call a request every X seconds and change things just
use PeriodicalExecutor or simply setTimeout

Alex Mcauley
http://www.thevacancymarket.com

William Taylor

unread,
Nov 10, 2009, 9:06:11 AM11/10/09
to prototype-s...@googlegroups.com
wow I must have been tired when I wrote that.
I said PeriodicalExecuter but I really meant Ajax.PeriodicalUpdater

So ya is there a way to make Ajax.PeriodicalUpdater not stack and to
possibly give it
a maximum frequency limit?

-William

Alex McAuley

unread,
Nov 10, 2009, 9:17:47 AM11/10/09
to prototype-s...@googlegroups.com
You have answered your own question...

In your original post you said that you could fix the problem if you could
get Periodical to "call a function instead of a url" .. and what i suggested
does just that ...

I am not sure i understand what you mean by stacking

As for frequency: you dont need to worry about it if you are usig periodical
executor and opposed to updater

William Taylor

unread,
Nov 10, 2009, 9:48:41 AM11/10/09
to prototype-s...@googlegroups.com
This will call a function and not a url ?
  new Ajax.PeriodicalUpdater(container, url[, options])
stacking: ie multiple request will stack on top of each other whether or not the previous one
has completed or not.
If this is making a request say every second there is the possibility that the request may not finish in time before the
next one gets fired off. I need a way to prevent that.

Im using PeriodicalUpdater not PeriodicalExecutor.  I need the frequency and decay that Updater provides.

Thanks,
 William

Alex McAuley

unread,
Nov 10, 2009, 10:27:44 AM11/10/09
to prototype-s...@googlegroups.com
To stop the stacking just use asynchronous flag and set it to false...
 
Though it does go against the AJAX it will work...
 
Perhaps you can get around the decay/frequency with somehting else

William Taylor

unread,
Nov 10, 2009, 11:01:48 AM11/10/09
to prototype-s...@googlegroups.com
If I turn off async will that only block on that one call or will it block
other calls from happening also?

Alex McAuley

unread,
Nov 10, 2009, 11:42:54 AM11/10/09
to prototype-s...@googlegroups.com
It makes the call asynchronous (it will only do one thing at a time) .. so if you had a stack of 8 ajax calls it would go through them one by one in synchronous fashion until they are done...
 
If you have other ajax calls going on in the page from different functions - this one would sit in the stack until the interpreter is ready and execute then (AFAIK)
 
setting the flag on  one function will not mess with other ajax calls on the page..
 
If you need to check other calls (the number of) use Ajax.ActiveRequestCount - it holds a variable (integer) of how many Ajax requests are going on in the page at any one time.
 
HTH
Reply all
Reply to author
Forward
0 new messages