I detest the way setInterval() looks, so I came up with this... have been
using it my personal JS for some time.

Object.extend(Function.prototype, {
  repeat: function() {
    var __method = this, args = $A(arguments), interval = args.shift() *
1000;
    return window.setInterval(function() {
      return __method.apply(__method, args);
    }, interval );
  }
});

// usage:
var _pollInt = 0;
function repetiousPollFn() {
 console.log(_pollInt++);
}

repetiousPollFn.repeat(.5);

Will, of course, repeat repetiousPollFn() every half second.


Almost identical to .delay(), except that it returns setInterval instead of
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.

Rick

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to