| |
Prototype: Core |
You might also want to look at the already existing
Any implementation of a Function#repeat API should take this in
On Jun 24, 2:55 pm, "joe t." <thooke...@gmail.com> wrote:
> var interval = repetitiousPollFn.repeat(0.5);
> then later
> i could also see potential for more "scheduling" options
> i find it an interesting idea though. :)
> On Jun 23, 11:25 am, Rick Waldron <waldron.r...@gmail.com> wrote:
> > I detest the way setInterval() looks, so I came up with this... have been
> > Object.extend(Function.prototype, {
> > });
> > // usage:
> > }
> > repetiousPollFn.repeat(.5);
> > Will, of course, repeat repetiousPollFn() every half second.
> > Almost identical to .delay(), except that it returns setInterval instead of
> > Rick
PeriodicalExecuter.
account.
> requirement that "repetitionsPollFn.repeat()" get assigned to a
> variable so it can be cleared later:
> // interval is the setInterval ID
> window.clearInterval(interval);
> (repeatUntilTime, repeatXTimes, etc) built into your #repeat idea, but
> don't really have the time to flesh them out.
> -joe t.
> > using it my personal JS for some time.
> > repeat: function() {
> > var __method = this, args = $A(arguments), interval = args.shift() *
> > 1000;
> > return window.setInterval(function() {
> > return __method.apply(__method, args);
> > }, interval );
> > }
> > var _pollInt = 0;
> > function repetiousPollFn() {
> > console.log(_pollInt++);
> > setTimeout. One thing I intend to add is support for clearInterval, however
> > I figured I'd at least bring it up here first. I've never
> > proposed/contributed here before (i'm a lurker of the list :D ) - any
> > guidance is appreciated.