- Home
- Downloads
-
Addons & Mods
Featured
World of Warcraft
6,099 Addons
-
Popular Downloads
- Top World of Warcraft Addons
- Top Minecraft Server Mods
- Top Rift Addons
- Top Skyrim Mods
- Top World of Tanks Skins
- Top StarCraft II Maps
- Top Terraria Maps
- Top Runes of Magic Addons
- Top Warhammer Online Addons
- Top The Secret World Mods
- Top Age of Conan Addons
-
- Curse Client
- Premium
- News
- Giveaways
- Forums
- Store
CallbackHandler-1.0
- 0 Likes
- World of Warcraft
- 1,959 Monthly Downloads
- Supports: 4.0.3a
- 551,325 Total Downloads
- Updated 01/14/2011
- Created 09/29/2008
- 53 Favorites
- Project Site
- Comments
- Release Type: Release
- License: BSD License
- Newest File: 1.0.7
About CallbackHandler-1.0
CallbackHandler is a back-end utility library that makes it easy for a library to fire its events to interested parties. It removes the need for addons to be aware of e.g. AceEvent.
The one remaining use for AceEvent Messages is messages that do not have a fixed source - ones that multiple libraries or addons can fire.
Including CallbackHandler-1.0 into your project
Library
if using the WoWAce repositories
- setup an external pointing to svn://svn.wowace.com/wow/callbackhandler/mainline/trunk/CallbackHandler-1.0 in the .pkgmeta file
- disable nolib creation by adding enable-nolib-creation: no to the .pkgmeta file
- set up your <library>.toc file to load CallbackHandler-1.0.xml (in case you support stand alone loading of the lib)
- don't load CallbackHandler-1.0 via the xml file ment for embedded loading of your lib
- don't set CallbackHandler-1.0 as X-embeded or OptDep
otherwise
- get a copy of the current version
- copy CallbackHandler-1.0.lua into your library's folder
- set up your <library>.toc file to load CallbackHandler-1.0.lua (in case you support stand alone loading of the lib)
- don't load CallbackHandler-1.0 via the xml file ment for embedded loading of your lib
- don't set CallbackHandler-1.0 as X-embeded or OptDep
AddOn
if using the WoWAce repositories
- set up an external pointing to svn://svn.wowace.com/wow/callbackhandler/mainline/trunk/CallbackHandler-1.0 in the .pkgmeta file
- set up your <addon>.toc or embeds.xml file to load CallbackHandler-1.0.xml
- don't set CallbackHandler-1.0 as X-embeded or OptDep
otherwise
- get a copy of the current version
- copy CallbackHandler-1.0.lua into your addon's folder or a subfolder of it
- set up your <addon>.toc or embeds.xml file to load CallbackHandler-1.0.lua
- don't set CallbackHandler-1.0 as X-embeded or OptDep
Mixing in the CallbackHandler functions in your library
MyLib.callbacks = MyLib.callbacks or
LibStub("CallbackHandler-1.0"):New(MyLib)
This adds 3 methods to your library:
- MyLib.RegisterCallback(self, "eventName"[, method, [arg]])
- MyLib.UnregisterCallback(self, "eventname")
- MyLib.UnregisterAllCallbacks(self)
Make sure that the passed in self is your addon, and not the library itself, so the double-colon syntax will not work.
The "MyLib.callbacks" object is the callback registry itself, which you need to keep track of across library upgrades.
Firing events
Assuming your callback registry is "MyLib.callbacks", firing named events is as easy as:
MyLib.callbacks:Fire("EventName", arg1, arg2, ...)
All arguments supplied to :Fire() are passed to the functions listening to the event.
Advanced uses
Renaming the methods
You can specify your own names for the methods installed by CallbackHandler:
MyLib.callbacks= MyLib.callbacks or
LibStub("CallbackHandler-1.0"):New(MyLib,
"MyRegisterFunc", "MyUnregisterFunc", "MyUnregisterAllFunc" or false)
Giving false as the name for UnregisterAll means that you do not want to give users access to that API at all - it will not be installed.
Tracking events being used
In some cases, it makes sense to know which events are being requested by your users. Perhaps to enable/disable code needed to track them.
CallbackHandler will always call registry:OnUsed() and :OnUnused() when an event starts/stops being used:
function MyLib.callbacks:OnUsed(target, eventname)
-- "target" is == MyLib here
print("Someone just registered for "..eventname.."!")
end
function MyLib.callbacks:OnUnused(target, eventname)
print("Noone wants "..eventname.." any more")
end
"OnUsed" is only called if the event was previously unused. "OnUnused" is only called when the last user unregisters from an event. In other words, you won't see an "OnUnused" unless "OnUsed" has been called for an event. And you won't ever see two "OnUsed" in a row without "OnUnused" in between for an event.
Multiple event registries
As you may or may not know, CallbackHandler is the workhorse of [[AceEvent-3.0|AceEvent]]. It is used twice in AceEvent: once for in-game events, which cannot be fired by users, and once for "messages", which can be fired by users.
Providing multiple registries in AceEvent was as easy as:
AceEvent.events = AceEvent.events or
LibStub("CallbackHandler-1.0"):New(AceEvent,
"RegisterEvent", "UnregisterEvent", "UnregisterAllEvents")
AceEvent.messages = AceEvent.messages or
LibStub("CallbackHandler-1.0"):New(AceEvent,
"RegisterMessage", "UnregisterMessage", "UnregisterAllMessages")
AceEvent.SendMessage = AceEvent.messages.Fire
Of course, there is also some code in AceEvent to do the actual driving of in-game events (using OnUsed and OnUnused), but this is really the core of it.
------------------------------------------------------------------------
r17 | kaelten | 2011-01-14 15:20:16 +0000 (Fri, 14 Jan 2011) | 1 line
Changed paths:
A /tags/1.0.7 (from /trunk:16)
Tagging as 1.0.7
------------------------------------------------------------------------
r16 | kaelten | 2011-01-14 15:17:44 +0000 (Fri, 14 Jan 2011) | 1 line
Changed paths:
M /trunk/CallbackHandler-1.0.toc
Updating Toc #
------------------------------------------------------------------------
| File Name | Release Type | Game Version | Downloads | Date |
|---|---|---|---|---|
| 1.0.7 | Release | 4.0.3a | 374,344 | 01/14/2011 |
| 1.0.6 | Release | 3.3.5 | 159,005 | 08/08/2010 |
| 1.0.5 | Release | 3.2.0 | 5,239 | 09/17/2009 |
| 1.0.3.30100 | Release | 3.1.0 | 10,238 | 05/09/2009 |
| 1.0.3 | Release | 3.0.2 | 4,504 | 09/29/2008 |
Addon Packs Containing This...
-
Hönterr's Addon Pack
-
Clear Giga Interface 4.3
-
Akki's NoFrillz UI
-
Igdrazil's Addon Pack
-
Papamayo's Addon Pack
-
Tank Or Heal UI Cataclysm
-
Lilililili - Mage Pack
-
Erdras Raid/All around UI
-
Fury Warrior Vizual's addon pack. 15,9 Notebook
-
riahna's Addon Pack
-
Evi's nice Raid UI
-
Weilandoh1's Addon Pack
-
Reptile's Addon Pack
-
Xenum's Clean Raiding Addon Pack
-
Thengel 2011
-
Zyphero's All-Around Pack
-
Flamezz11's Addon Pack
-
Heala's new pack
-
celastus's Addon Pack
-
Rundas' Deathknight-Tank UI (RDT-UI)
-
JahUI [1920x1080]
-
Nibordi's Hunt Pack
-
koosmatrooss's Addon Pack
-
Paradar warrior PvE UI
-
Turaxx addon pack v 3.0
Top Downloads
-
- Deadly Boss Mods
- Combat, PvP, and Boss Encounters
- 1,039,394 Monthly Downloads
-
- Bagnon
- Bags & Inventory
- 476,960 Monthly Downloads
-
- Recount
- Combat
- 332,077 Monthly Downloads
-
- Auctioneer
- Mail, Tooltip, Bags & Inventory, Professions, and Auction & Economy
- 330,308 Monthly Downloads
-
- HealBot Continued
- Healer and Unit Frames
- 303,569 Monthly Downloads
Comments
Heatsink uses this addon.
Why do I have this addon? What is the purpose of this addon? What addon uses this? What addon makes me download this addon (And other LiBs) ??
Not sure if this helps you, but I found Archy addon (for archeology) has installed this one for me.