Created
May 24, 2013 20:06
-
-
Save rwaldron/5646160 to your computer and use it in GitHub Desktop.
Something more scalable and organized then tacking junk onto the global object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[Global]].Timer = {}; | |
Timer.Frame = function(handler) { | |
// ... does what rAF(handler) would do | |
}; | |
Timer.Frame.prototype.cancel = function() { | |
// kills this Timer.Frame instance | |
}; | |
Timer.Frame.prototype.pause = function() { | |
// prevents handler from being invoked in the | |
// next turn | |
}; | |
Timer.Frame.prototype.resume = function() { | |
// if pause() was previously called, | |
// schedule the handler to be invoked | |
// in the next turn | |
}; | |
Timer.Immediate = function(handler) { | |
// at the end of this turn invoke the handler | |
}; | |
Timer.Timeout = function(ms, handler) { | |
// at the end of this turn, | |
// wait "ms" and invoke the handler | |
}; | |
Timer.Timeout.prototype.cancel = function() { | |
// cancel the invocation of this Timer.Timeout | |
// instance's handler if it has not yet been | |
// invoked. | |
}; | |
Timer.Interval = function(ms, handler) { | |
// at the end of this turn, | |
// wait "ms" and invoke the handler | |
}; | |
Timer.Interval.prototype.cancel = function() { | |
// cancel the invocation of this Timer.Timeout | |
// instance's handler if it has not yet been | |
// invoked. | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment