LibRockEvent-1.0
From WowAce Wiki
| Summary | |
|---|---|
| Lib: RockEvent-1.0 | |
| Event library | |
| TOC | 2.4 (20400) |
| Category | Libraries |
| Author | ckknight |
| Details | |
| Links | |
| Website | http://www.wowace.com |
| Betas | Ace SVN Zip |
| Changelog | FishEye |
[edit]
API Documentation
Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate. string or function number
[edit]
:AddEventListener("namespace" , eventName [, callback] [, bucketDelay] [, ...])
[edit]
Arguments
- "namespace"
- string - the namespace, could be "Blizzard" or the name of a library or addon. Optional, default: "Blizzard"
- eventName
- string or table - the name of the event or a table containing a set of events.
- callback
- string or function - the callback (method name or function) to call. Default: "eventName",
- bucketDelay
- number - if a number is provided, the bucketing delay. Default: nil
- ...
- tuple - a list of arguments to pass into the start of the callback.
[edit]
Notes
- adds a listener for an event specified by the "namespace"/"eventName" pair.
- to register for a Blizzard event, specify namespace as "Blizzard"
- Along with the normal arguments passed into the callback, the "namespace" and "eventName" are passed in.
- Bucketed events can be handled by setting the bucketDelay argument to a number, which is the amount of time to bucket events by. Bucket events will take the first argument passed in and store it in a set. If the set is non-empty by the time the specified delay is up, the callback will be called, passing along the set.
- It is recommended to only use the multiple event system when using buckets.
- If you wish to listen to events triggered by AceEvent-2.0, specify the namespace "AceEvent-2.0". e.g. "AceEvent-2.0", "SharedMedia_Registered".
[edit]
Example
MyAddon.PLAYER_LOGIN = function(self, namespace, event)
-- do something here.
end
MyAddon:AddEventListener("PLAYER_LOGIN") -- same as :AddEventListener("Blizzard", "PLAYER_LOGIN")
MyAddon.ADDON_LOADED = function(self, value, namespace, event)
assert(value == 50)
end
MyAddon:AddEventListener("ADDON_LOADED", nil, nil, 50)
-- buckets:
MyAddon.SomeEvent = function(self, namespace, event, data)
end
MyAddon:AddEventListener("MyAddon", "SomeEvent", nil, 1) -- bucketing by every second.
MyAddon:DispatchEvent("SomeEvent", "alpha")
-- half second later
MyAddon:DispatchEvent("SomeEvent", "bravo")
-- once the second has passed, MyAddon:SomeEvent("MyAddon", "SomeEvent", { ["alpha"] = true, ["bravo"] = true }) will be called.
-- multiple events:
MyAddon.Handler = function(self, namespace, event)
-- will receive SomeEvent and SomeOtherEvent
end
MyAddon:AddEventListener("SomeNamespace", { SomeEvent = true, SomeOtherEvent = true}, "Handler")
[edit]
:DispatchEvent("eventName" , ...)
[edit]
Arguments
- "eventName"
- string - the name of the event.
- ...
- tuple - list of arguments to pass.
[edit]
Notes
- dispatch an event, causing all addons which have registered for the event to have their callbacks called.
- events should be in the form of PascalCase. Only Blizzard's events should be in CONSTANT_CASE
- events are passed with the namespace as specified by object.name
[edit]
Example
MyAddon:DispatchEvent("Kersplosion") -- dispatches "MyAddon","Kersplosion"
[edit]
:DispatchNamespaceEvent("namespace" , "eventName" , ...)
[edit]
Arguments
- "namespace"
- string - the namespace.
- "eventName"
- string - the name of the event.
- ...
- tuple - list of arguments to pass.
[edit]
Notes
- dispatches an event with the specified namespace, causing all addons which have registered for the event to have their callbacks called.
- events should be in the form of PascalCase. Only Blizzard's events should be in CONSTANT_CASE
- events are passed with the namespace as specified by object.name
- this is for special cases only, e.g. debugging. It is highly recommended that :DispatchEvent is used instead.
[edit]
Example
Rock("LibRockEvent-1.0"):DispatchNamespaceEvent("MyAddon", "Kersplosion") -- dispatches "MyAddon","Kersplosion"
[edit]
:HasEventListener("namespace" , "eventName")
[edit]
Arguments
- "namespace"
- string - the namespace. Optional, default: "Blizzard"
- "eventName"
- string - the name of the event.
[edit]
Returns
boolean or function or string - false if not registered, otherwise the callback that the event is registered to. Note: if this is called on LibRockEvent-1.0 itself, it will only return true/false.
[edit]
Example
local has = MyAddon:HasEventListener("PLAYER_LOGIN") -- same as :HasEventListener("Blizzard", "PLAYER_LOGIN")
local has = MyAddon:HasEventListener("MyAddon", "Kersplosion")
[edit]
:IsFullyInitialized()
[edit]
Notes
- The event "LibEvent-1.0","FullyInitialized" will be dispatched when the UI has fully initialized.
- Fully initialized means that it is post-PLAYER_LOGIN and all chat channels have been properly joined, which has no corresponding Blizzard event.
[edit]
Returns
boolean - whether the UI has fully initialized
[edit]
Example
local init = Rock("LibRockEvent-1.0"):IsFullyInitialized()
string
[edit]
:RemoveAllEventListeners([namespace])
[edit]
Arguments
- namespace
- string - the namespace, could be "Blizzard" or the name of a library or addon. Default: all namespaces
[edit]
Notes
- remove all event listener for the specified namespace or for all namespaces.
[edit]
Example
MyAddon:RemoveAllEventListeners()
[edit]
:RemoveEventListener("namespace" , "eventName")
[edit]
Arguments
- "namespace"
- string - the namespace, could be "Blizzard" or the name of a library or addon. Optional, default: "Blizzard"
- "eventName"
- string - the name of the event.
[edit]
Notes
- remove the event listener for the specified "namespace"/"eventName" pair.
[edit]
Returns
boolean - whether the event actually was removed.
[edit]
Example
MyAddon:RemoveEventListener("PLAYER_LOGIN") -- same as :RemoveEventListener("Blizzard", "PLAYER_LOGIN")

