> How to stop it? arguments? Stopping it is as easy as:
pe = foo.repeat(); pe.stop(); Passing arguments would require some simple currying: Function.prototype.repeat = function(interval) { var fn = this; if (arguments.length > 1) { // not testsed but you get the idea fn = fn.curry.apply(fn, Array.prototype.slice.call(arguments, 1)); } return new PeriodicalExecuter(fn, interval); } > This may come to you twice, but this is slightly updated: > > http://jsbin.com/opimu > > This repeat() method def is 775Bytes, accepts arguments like delay/defer, > uses setTimeout (returns initial setTimeout index) and has a stopping > mechanism. What's the point in returning setTimeout index? That will set expectations which can't be met: developers will expect to be able to stop the functions calls by clearing it. Are you sure your proposal fixes all of the small issues PE fixes? For example, does it guarantee that the function will continue being called if it happens to once throw an error. Does it avoid calling the function again if a previous function is still executing, etc.? I understand your eagerness to move away from a model you dislike, but that shouldn't make you throw away all of the work that's been put into previous solutions. FWIW, I just noticed a patch wasn't applied to PE in current trunk (it's missing a throw statement). Best, Tobie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---