Convert Timer interval to be milliseconds
Reported by Joe Gornick | March 12th, 2009 @ 05:27 PM
Compared to every other timer in other languages, timer always accepts milliseconds and not seconds.
I say we convert the interval property to accept milliseconds.
Comments and changes to this ticket
-
John-David Dalton July 3rd, 2009 @ 05:48 PM
- Milestone cleared.
-
Kit Goncharov July 4th, 2009 @ 11:23 PM
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
Timer
class (and then there's the additional issue of which units to support). Another alternative might be amultiple
option (so, for seconds, settimeout
to 5 andmultiple
to 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 July 5th, 2009 @ 09:14 AM
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 July 5th, 2009 @ 09:20 AM
I dig the
multiple
option adds very little to overhead and allows for some customizations like:// boom Prototype compat.
Fuse.Timer.defaultOptions.multiple = 1000;also currently we use
defaultOptions
inFuse.Ajax.Base.defaultOptions
would justoptions
seem fitting sense it is on the constructor ? (Fuse.Ajax.Base.options
orFuse.Timer.options
-
John-David Dalton July 5th, 2009 @ 09:22 AM
- Assigned user changed from Joe Gornick to Kit Goncharov
-
Kit Goncharov July 8th, 2009 @ 12:33 PM
- 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
options
hash will look something like this:new Fuse.Timer({ onTimeout: function(){ ... }, onException: function(exception){ ... }, timeout: 15, multiple: 1000 });
-
John-David Dalton July 8th, 2009 @ 12:40 PM
Careful with that delete :D
I dig the exception handling, its should be a new ticket item though.
-
Kit Goncharov July 8th, 2009 @ 01:11 PM
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 July 8th, 2009 @ 01:11 PM
- Tag set to patched
-
John-David Dalton July 9th, 2009 @ 01:55 PM
Ok I have been milling over these changes.
I would think that because of it being a timer that some arguments should not be optionalFuse.Timer(callback, interval, options);
options
can hold themultiplier
andonException
properties -
John-David Dalton July 10th, 2009 @ 12:52 PM
- 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.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
JavaScript frameworks share similar features and functionality such as DOM manipulation, event registration, and CSS selector engines. FuseJS attempts to incorporate the strengths of these frameworks into one stable, efficient, and optimized core JavaScript framework.