Φ wowmods - MagicLib-2.5 @ ?
[ addon updates | search | RSS | Google: subscribed link (?); Gadget | Twitter ]
[ login | register ] [ contact ]
search addons:

 • details
addon: MagicLib-2.5
listed author: Lonny   [list all addons]
latest version: 2.5
date last updated: Tue, 18 May 2010 18:06:30 +0100
date added: Tue, 18 May 2010 18:50:04 +0100
 
wowinterface.com: http://www.wowinterface.com/downloads/info15987-2.5.html

 • about + changelog
Change Log:






2.5 (18-05-10)

+ Removed the config support completely, it was a mistake on my part to include it the first place. :p








2.1 (01-04-10)

+ Fixed minor bugs.

+ Trying to register ADDON_LOADED, PLAYER_LOGIN, or PLAYER_LOGOUT will result a specific message about the equivalent built-in event you should use instead.

+ The name of the method 'ToColorString' changed to 'ToRGBString'.








2.0.2 (11-03-10)

+ Reverted the change I made last push, you can now unregister the built-in events! conclusion never code at nights, or rush it, and be dumb.








2.0.1 (11-03-10)

+ Fixed minor documentation errors.

+ The built-in events can no longer be unregistered.








2.0 (10-03-10)

+ Added built-in events. (OnLoad, OnEnabled, OnDisabled)

+ It's no longer needed to provide a name to create an instance of the library as the addon name is always used now.

+ When a new instance of the library is created, a new 'Core' module is created by default.

+ Fixed some documentation errors.








1.2.5 (23-02-10)

+ Fixed a bug in the scheduling system.

+ Made some minor improvements to the scheduling system.

+ The error messages were modified to make them more readable.

+ Made a minor update to the documentation.








1.2 (20-02-10)

+ Fixed some args check.

+ Fixed some documentation errors.

+ Added a method to register multiple events with a single handler.

+ Added a method to unregister multiple events.

+ The name of the event is now being passed to all event handlers as a second argument!






...



Description:






A simple library that provides a common interface and functionality for addons.



This is a very lightweight library, it promote event-driven programming, and semi object-oriented support of modules.



Detailed documentation can be found inside the library file.



Modules functionality



Events management - Easy events registration, and custom events handling.

Tasks scheduling - Efficient scheduled callbacks system.

Chat message handlers - Provides better print methods.



Library Registration

New() - Creates a new instance of the library.



Returns.

core - (table) The core module which is defined for each instance of magic.

addon - (table) The addon's global namespace/scope. (This is the same table defined by Blizzard for addons, this also provides an access point to the modules API.)

magic - (table) A predefined fresh table. (A good candidate for defining API methods and expose it through a global variable, this also provides an access point to the modules API.)



Usage.

local core, addon, magic = LibStub("MagicLib-2.1"):New()



Here is a small test addon.



Core.lua



local core, addon, magic = LibStub("MagicLib-2.1"):New()



-- Do some stuff on ADDON_LOADED. (Built-in event.)

core:RegisterEvent("OnLoad", function(self, event)

self:PrintC(event)

SLASH_TESTADDON1 = "/testaddon"

SlashCmdList = function(input)

-- Trigger custom event.

self:TriggerEvent("SlashCommand", input)

end

end)



-- Do some stuff on PLAYER_LOGIN. (Built-in event.)

core:RegisterEvent("OnEnabled", function(self, event)

self:PrintC(event)

end)



-- Do some stuff on PLAYER_LOGOUT. (Built-in event.)

core:RegisterEvent("OnDisabled", function(self, event)

end)



-- Do some stuff on PLAYER_ENTERING_WORLD. (Blizzard event.)

core:RegisterEvent("PLAYER_ENTERING_WORLD...

 
Hint: see addon details for related searches in Google: use the Google Subscribed Links service.