LibSimpleTimer-1.0

From WowAce Wiki
Jump to: navigation, search

Features

  • Schedule/Cancel one-time or repeating timer by id.
  • Able to schedule a timer without any callback. Why? Used with :IsTimerScheduled(id) for checks
  • Able to overwrite existing timer.
  • Fast OnUpdate utilizing a heap.
  • Embedable.

API Documentation

Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate.

:CancelTimer(name)

Arguments

name
name (variant) - The name of the timer to cancel.

Notes

  • Cancels the timer scheduled with name.


:Embed(target)

Arguments

target
target (table) - The table with which to export methods onto.

Notes

  • Embeds "ScheduleTimer", "ScheduleRepeatingTimer", "IsTimerScheduled", "CancelTimer"

Returns

The table provided, after embedding.


:IsTimerScheduled(name)

Arguments

name
name (variant) - The name of the timer to query.

Notes

  • Returns if the timer with the name specified is scheduled or not and also returns the time remaining for it to expire.

Returns

false - if the timer is not scheduled. true, seconds (number) - if the timer is scheduled. seconds is the number of seconds required for the timer to expire.


:ScheduleRepeatingTimer(name , func , delay , ...)

Arguments

name
name (variant) - The name of the timer to be scheduled. You can use this name to check if this timer's status and/or cancel it.
func
func (function) - A function to be called when the timer expires.
delay
delay (number) - The number of seconds it takes for this timer to expire.
...
... - Any additional arguments to pass to the callback.

Notes

  • Schedule a repeating timer that expires every delay seconds.
  • If you try to schedule a timer with the same name a second time, the old schedule will be overwritten.


:ScheduleTimer(name , func , delay , ...)

Arguments

name
name (variant) - The name of the timer to be scheduled. You can use this name to check if this timer's status and/or cancel it.
func
func (function or nil) - A function to be called when the timer expires, can be nil.
delay
delay (number) - The number of seconds it takes for this timer to expire.
...
... - Any additional arguments to pass to the callback.

Notes

  • Schedule a timer to expire in delay seconds at which point it will call the callback func. name is an identifier for this timer.
  • If you try to schedule a timer with the same name a second time, the old schedule will be overwritten.

Example

:ScheduleTimer("EncounterEnd", self.EncounterEnd, 10, self, 10)
:ScheduleTimer("EncounterEnd", nil, 10) -- why? used with :IsTimerScheduled("EncounterEnd")