LibRockModuleCore-1.0
From WowAce Wiki
API Documentation
Note: This documentation is auto-generated. Please note that direct modifications may be overwritten on next autogenerate.
:CallMethodOnAllModules(enabledOnly , "methodName" , ...)
Arguments
- enabledOnly
- boolean - whether only enabled modules should be iterated through.
- "methodName"
- string - the name of the method.
- ...
- tuple - the list of arguments to call the method with.
Notes
Safely calls the given method on all modules if it exists on said modules. This will automatically subvert any errors that occur in the modules.
Example
core:CallMethodOnAllModules(false, "OnSomething") core:CallMethodOnAllModules(true, "OnSomethingElse", 1, 2, 3, 4)
:GetModule("name")
Arguments
- "name"
- string - the name of the module.
Notes
Return the module "name" if it exists. If the module doesnot exist, an error is thrown.
Returns
The module requested, if it exists.
Example
local bank = core:GetModule("Bank")
:HasModule(module)
Arguments
- module
- string or table - name of the module or reference to the module.
Returns
- boolean or table - Whether the module is available in the core, or if it is a reference, whether it is a module of the core. If this is called directly on LibRockModuleCore-1.0, it will return the core of the module.
Example
if core:HasModule("Bank") then
-- do banking
end
-- for references
if core:HasModule(module) then
-- do something
end
-- alternatively
if Rock("LibRockModuleCore-1.0"):HasModule(module) then
-- checks all modules, no matter the parent
end
local core = Rock("LibRockModuleCore-1.0"):HasModule(module)
:IsModuleActive(module [, notLoaded])
Arguments
- module
- string/table - name of the module or a reference to the module
- notLoaded
- - boolean - if set, this will check modules that are not loaded as well. (default: false)
Notes
Returns whether the module is in an active (enabled) state. If notLoaded is set, then "name" must be a string.
Returns
- boolean - Whether the module is in an active (enabled) state.
Example
assert(core:IsModuleActive("bank"))
boolean
:IterateModules([enabledOnly])
Arguments
- enabledOnly
- boolean - whether only enabled modules should be iterated through. Default: false
Returns
iterator - an iterator that traverses through and returns name, module
Example
for name, module in core:IterateModules(false) do -- do something end
:IterateModulesWithMethod(enabledOnly , "methodName")
Arguments
- enabledOnly
- boolean - whether only enabled modules should be iterated through.
- "methodName"
- string - name of the method to check for.
Returns
iterator - an iterator that traverses through and returns name, module
Example
for name, module in core:IterateModulesWithMethod(false, "Kersplode") do -- do something end
:NewModule("name" , ...)
Arguments
- "name"
- string - name of the module.
- ...
- tuple - list of mixins the module is to inherit from.
Notes
Create a new module, parented to self.
Example
local MyModule = core:NewModule('MyModule', "LibRockEvent-1.0", "LibRockTimer-1.0")
:SetModuleDefaultState(module , state)
Arguments
- module
- string or table - name of the module or the reference to the module.
- state
- boolean - new state. false means disabled by default, true means enabled by default (true is the default if this method is not called).
Notes
Sets the default active state of a module. This should be called before the ADDON_LOADED of the module.
Example
MyAddon:SetModuleDefaultState("Bank", false)
:SetModuleMixins(...)
Arguments
- ...
- tuple - list of mixins
Notes
- Sets the default mixins for a given module.
- This cannot be called after :NewModule() has been called.
- This should really only be called if you use the mixins in your prototype.
Example
core:SetModuleMixins("LibRockEvent-1.0", "LibRockTimer-1.0")
boolean
:ToggleModuleActive(module [, state])
Arguments
- module
- string/table - name of the module or a reference to the module
- state
- boolean - new state. (default not :IsModuleActive("name" or module))
Notes
- Toggles the active state of a module.
- If suspending, This will call :OnDisable() on the module if it is available. Also, it will iterate through the addon's mixins and call :OnEmbedDisable(module) if available. - this in turn will, through AceEvent and others, unregister events/hooks/etc. depending on the mixin. Also, it will call :OnModuleDisable(name, module) on the core if it is available.
- If resuming, This will call :OnEnable(first) on the module if it is available. Also, it will iterate through the addon's mixins and call :OnEmbedEnable(module) if available. - this in turn will, through AceEvent and others, unregister events/hooks/etc. depending on the mixin. Also, it will call :OnModuleEnable(name, module) on the core if it is available.
- If you call :ToggleModuleActive("name" or module, true) and it is already active, it silently returns, same if you pass false and it is inactive.
Returns
- boolean - Whether the module is now in an active (enabled) state.
Example
self:ToggleModuleActive('bank')

