Convert Timer interval to be milliseconds
-
John-David Dalton
- Milestone cleared.
-
Kit Goncharov
That, or change the constructor to accept an options hash instead of just two arguments:
new Fuse.Timer({ callback: function(){ //... }, timeout: 5000, //`timeout` seems more concise than `interval`... unit: 'millisecond' });The disadvantage to this is that it creates more overhead, and also requires a lot more abstraction in the actual
Timerclass (and then there's the additional issue of which units to support). Another alternative might be amultipleoption (so, for seconds, settimeoutto 5 andmultipleto 1000), but that also seems slightly redundant and unnecessary.I think using seconds for the timeout unit seems more intuitive, but, if it's inconsistent with other languages, then it's probably a good idea to switch it to milliseconds after all. Just playing around with various ideas... :)
-
John-David Dalton
Something else to think about is
// ActionScript 3 Timer Class var myIndetifier:Timer = new Timer(delay, repeat-count); myIdentifier.addEventListener(TimerEvent.TIMER, timerListener); function timerListener (e:TimerEvent):void{ //commands } myIdentifier.start();Maybe later with an object event system something like this may be doable.
Also they use the worddelay, others usecountDown, and others still usetime intervals -
John-David Dalton
I dig the
multipleoption adds very little to overhead and allows for some customizations like:// boom Prototype compat.Fuse.Timer.defaultOptions.multiple = 1000;also currently we use
defaultOptionsinFuse.Ajax.Base.defaultOptionswould justoptionsseem fitting sense it is on the constructor ? (Fuse.Ajax.Base.optionsorFuse.Timer.options -
John-David Dalton
- Assigned user changed from Joe Gornick to Kit Goncharov
-
Kit Goncharov
- Tag cleared.
Sorry, I accidentally deleted my fork of Fuse on GitHub. I'll refork it and re-push the patch again... :(
What do you think about extending the timer capabilities to exception handling? So the
optionshash will look something like this:new Fuse.Timer({ onTimeout: function(){ ... }, onException: function(exception){ ... }, timeout: 15, multiple: 1000 }); -
John-David Dalton
Careful with that delete :D
I dig the exception handling, its should be a new ticket item though.
-
Kit Goncharov
The commit URL containing the Timer updates is:
https://github.com/kitsg/fusejs/commit/4d5c3634b69420dfad3f51271820...
In that commit, I accidentally left an erroneous entry in
timer_test.js, so this commit fixes that:https://github.com/kitsg/fusejs/commit/00be5a50c8c0d2ac267a07d038a0...
-
Kit Goncharov
- Tag set to patched
-
Kit Goncharov
@JDD: OK, #35 Add exception handling to Fuse.Timer covers exception handling.
-
John-David Dalton
Ok I have been milling over these changes.
I would think that because of it being a timer that some arguments should not be optional
andFuse.Timer(callback, interval, options);optionscan hold themultiplierandonExceptionproperties -
John-David Dalton
- State changed from open to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.