...that answer was so good, I'm buying your book :)
...been looking for a book like yours <http://manning.com/crane3/>, didn't
know of it until I saw your links... thanks for the book and the reference
to it. This looks very useful with regards to Pro-taculous development.
cheers-
On 3/12/07, Dave Crane <[EMAIL PROTECTED]> wrote:
>
>
> Hi Kjell,
>
> I'm not 100% sure I understand the problem you're describing - sounds like
> you
> need to generate a lot of PE objects for a variety of tasks, and have a
> way
> of ensuring that they get tidied up correctly.
>
> First off, I assume you're using v1.5.0 or higher of Prototype, as the PE
> in
> earlier versions didn't manage the JavaScript timer objects very well, and
> didn't provide a stop() method.
>
> There's no browser-based list of active timers - you'll need to manage the
> PE
> objects yourself - I'd suggest you either hack Prototype to keep a list,
> or,
> better, provide a factory method to create the PE's, e.g.:
>
> function createTimer(callback,frequency){
> var pe=new PeriodicalExecuter(callback,frequency);
> if (!PeriodicalExecuter.instances){
> PeriodicalExecuter.instances=[];
> }
> PeriodicalExecuter.instances.push(pe);
> return pe;
> }
>
> or, if you only want one instance running at a time for a given named
> task,
> you could store them by key, e.g.:
>
> function createTimer(taskName, callback,frequency){
> var pe=new PeriodicalExecuter(callback,frequency);
> if (!PeriodicalExecuter.instances){
> PeriodicalExecuter.instances={};
> }
> var oldTimer=PeriodicalExecuter.instances[taskName];
> if (oldTimer){ oldTimer.stop(); }
> PeriodicalExecuter.instances[taskName]=pe;
> return pe;
> }
>
> Just typing OTOH here, but so long as you always go through the factory
> method, that should keep things tidy.
>
> HTH
>
> Dave
>
> On Saturday 10 March 2007 16:47, Kjell Bublitz wrote:
> > Hi all
> >
> > I have to deal with multiple PeriodicalExecuters over several
> > Interfaces. Each has it own. Now this all works, but i when i go back
> > and forth between them i spawn another and another etc...
> >
> > I tried to push the instance of PE to a global array and on each
> > change in the interface invoke a stop() on them. This sounds okay, but
> > it is obviously not working 100% of the time.
> >
> > Any ideas how to manage this reliable?
> >
> > Is there a global object (maybe propertie of the Window object) that
> > contains all active timers so i could clear them up on the source in
> > case stop() fails?
>
> --
> ----------------------
> Author
> Ajax in Action http://manning.com/crane
> Ajax in Practice http://manning.com/crane2
> Prototype & Scriptaculous in Action http://manning.com/crane3
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---