Skip to content
Starlon edited this page Nov 30, 2011 · 4 revisions

Functions

<tr>
<td class="name" nowrap><a href="#LibTimer:Del">LibTimer:Del</a>&nbsp;()</td>
<td class="summary">Delete a LibTimer object </td>
</tr>

<tr>
<td class="name" nowrap><a href="#LibTimer:New">LibTimer:New</a>&nbsp;(name, duration, repeating, callback, data, errorLevel)</td>
<td class="summary">Create a new LibTimer object </td>
</tr>

<tr>
<td class="name" nowrap><a href="#LibTimer:Start">LibTimer:Start</a>&nbsp;(duration, data, func)</td>
<td class="summary">Start a timer.</td>
</tr>

<tr>
<td class="name" nowrap><a href="#LibTimer:Stop">LibTimer:Stop</a>&nbsp;()</td>
<td class="summary">Stop a timer </td>
</tr>

<tr>
<td class="name" nowrap><a href="#LibTimer:TimeElapsed">LibTimer:TimeElapsed</a>&nbsp;()</td>
<td class="summary">Return how old the timer is since it was started.</td>
</tr>


Functions

AceTimer:CancelAllTimers ()
Cancels all timers registered to the current addon object ('self')
AceTimer:CancelTimer (handle, silent)
Cancels a timer with the given handle, registered by the same addon object as used for `:ScheduleTimer` Both one-shot and repeating timers can be canceled with this function, as long as the `handle` is valid and the timer has not fired yet or was canceled before.

Parameters

<li>
  handle: The handle of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer`
</li>

<li>
  silent: If true, no error is raised if the timer handle is invalid (expired or already canceled)
</li>

Return value:

True if the timer was successfully cancelled.
AceTimer:ScheduleRepeatingTimer (callback, delay, arg)
Schedule a repeating timer. The timer will fire every `delay` seconds, until canceled.

Parameters

<li>
  callback: Callback function for the timer pulse (funcref or method name).
</li>

<li>
  delay: Delay for the timer, in seconds.
</li>

<li>
  arg: An optional argument to be passed to the callback function. @usage MyAddon = LibStub("AceAddon-3.0"):NewAddon("TimerTest", "AceTimer-3.0")  function MyAddon:OnEnable() self.timerCount = 0 self.testTimer = self:ScheduleRepeatingTimer("TimerFeedback", 5) end  function MyAddon:TimerFeedback() self.timerCount = self.timerCount + 1 print(("%d seconds passed"):format(5 * self.timerCount)) -- run 30 seconds in total if self.timerCount == 6 then self:CancelTimer(self.testTimer) end end
</li>
AceTimer:ScheduleTimer (callback, delay, arg)
Schedule a new one-shot timer. The timer will fire once in `delay` seconds, unless canceled before.

Parameters

<li>
  callback: Callback function for the timer pulse (funcref or method name).
</li>

<li>
  delay: Delay for the timer, in seconds.
</li>

<li>
  arg: An optional argument to be passed to the callback function. @usage MyAddon = LibStub("AceAddon-3.0"):NewAddon("TimerTest", "AceTimer-3.0")  function MyAddon:OnEnable() self:ScheduleTimer("TimerFeedback", 5) end  function MyAddon:TimerFeedback() print("5 seconds passed") end
</li>
AceTimer:TimeLeft (handle)
Returns the time left for a timer with the given handle, registered by the current addon object ('self'). This function will raise a warning when the handle is invalid, but not stop execution.

Parameters

<li>
  handle: The handle of the timer, as returned by `:ScheduleTimer` or `:ScheduleRepeatingTimer`
</li>

Return value:

The time left on the timer, or false if the handle is invalid.
LibTimer:Del ()
Delete a LibTimer object

Usage:

object:Del()

Return value:

Nothing
LibTimer:New (name, duration, repeating, callback, data, errorLevel)
Create a new LibTimer object

Parameters

<li>
  name: A name for this timer object
</li>

<li>
  duration: The timer's duration in milliseconds.
</li>

<li>
  repeating: Whether to repeat the timer or not
</li>

<li>
  callback: Function to call when the timer has expired
</li>

<li>
  data: Data to pass to the callback
</li>

<li>
  errorLevel: Error verbosity level
</li>

Usage:

LibScriptableTimer:New(name, duration, repeating, callback, data, errorLevel, durationLimit)

Return value:

A new LibScriptableTimer object
LibTimer:Start (duration, data, func)
Start a timer.

Parameters

<li>
  duration: The duration in milliseconds. This is optional. The timer's initialized duration will be replaced by this value.
</li>

<li>
  data: Replace the timer's data that will be sent through the callback with this value.
</li>

<li>
  func: Replace the timer's callback function
</li>

Usage:

object:Start([duration], [data])
LibTimer:Stop ()
Stop a timer

Usage:

object:Stop()

Return value:

True if the timer was stopped
LibTimer:TimeElapsed ()
Return how old the timer is since it was started.

Usage:

object:TimeElapsed()

Return value:

The remaining duration

Clone this wiki locally