AceTimer-3.0
From WowAce Wiki
Contents |
[edit]
API
[edit]
:ScheduleTimer(callback, delay, arg)
- callback (function or string)
- direct function ref or method name in our object for the callback
- delay (number)
- delay for the timer (must be integer)
- arg (variant)
- any argument to be passed to the callback function
Returns a handle to the timer, to be used for canceling it
[edit]
:ScheduleRepeatingTimer(callback, delay, arg)
- callback (function or string)
- direct function ref or method name in our object for the callback
- delay (number)
- delay for the timer (must be integer)
- arg (variant)
- any argument to be passed to the callback function
Returns a handle to the timer, to be used for canceling it
[edit]
:CancelTimer(handle)
- handle (string)
- handle returned from ScheduleTimer or ScheduleRepeatingTimer
- silent (boolean)
- If set to true, do not error if the timer does not exist or is already canceled. Defaults to false
Cancels a timer with the given handle, registered by the same 'self' as given in ScheduleTimer. Returns true if successful
[edit]
:CancelAllTimers()
Cancels all timers registered to a given 'self'
[edit]
What about on-next-update events?
Putting this into AceTimer would be highly inefficient for a number of reasons. We recommend doing something like the following:
local OnNextUpdateFrame = CreateFrame("Frame")
OnNextUpdateFrame:Hide()
OnNextUpdateFrame:SetScript("OnUpdate", function(self)
self:Hide()
... your code here ...
end)
And then when you want it to happen, just do:
OnNextUpdateFrame:Show()
Frame objects take next to no memory. There is also no extra pcall()s needed to wrap possible errors in your code. If it errors, it errors. There is no additional harm done, as long as the first command is to hide the frame.

