Change Log:
1.0.1 (17-02-10)
+ Fixed the 'ToColorString(...)' function to return the correct results.
+ Fixed a bug that made custom events shared across all addons.
Description:
A simple library that provides a common interface and functionality for addons.
This is a very lightweight library.
Usage
local magic = LibStub("MagicLib-1.0"):New("name")
local module = magic:NewModule("moduleName")
You can use your own table, as follow.
local myTable = { }
local magic = LibStub("MagicLib-1.0"):New("name", myTable)
local module = myTable:NewModule("moduleName")
Modules Interface
NewModule(name) - Create a new module.
Arguments.
name - (string) The name of the module.
inherit - (string, table) A module name, or an actual module for this module to derive from.
config - (table) A configuration table we may want to associate to this module.
Returns.
module - (table) A module.
config - (table) The configuration table the module is associated with.
GetModule(name) - Gets the given module.
Arguments.
name - (string) The name of the module.
Returns.
module - (table) A module.
config - (table) The configuration table the module is associated with.
NewInstance(name, ...) - Create an instance of a module.
Arguments.
name - (string) The name of the module.
args - (table) The constructor args you may need to pass.
Returns.
instance - (table) An instance of the given module.
config - (table) The configuration table the module is associated with.
Usage.
local magic = LibStub("MagicLib-1.0"):New("name")
-- Defines a type, essentially a class.
local t = magic:NewModule("typeName")
function t:ctor(param1, ...)
end
-- Creates an instance of the class.
local objName = magic:NewInstance("typeName", arg1, ...)
IterateModules() - Traverse through all modules.
Modules Functionality
GetName() - Gets the name of the module.
Returns.
name - (string) The name of the module.
GetOwner() - Gets the module's owner name.... |
|