View Single Post
02-07-12, 03:16 PM   #1
Animor
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Mar 2011
Posts: 136
Ace3 OnDisable() and RefreshConfig() usage

Hi,

I've read the info on Ace3 libs, but there are still things I'm not sure how to handle on my addon:

1. How do I use Myaddon:OnDisable() ?
I have a GUI with globalEn toggle button. Right now globalEn only disables internal functions in my code.
Should I run Myaddon: Disable() when the user uncheck this button? What else will it do besides calling Myaddon:OnDisable()? Is it a good practice to do so?

2. The doc guided to use:
Code:
function MyAddon:OnInitialize()
  self.db = LibStub("AceDB-3.0"):New("MyAddonDB", defaults)
  self.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig")
  self.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig")
  self.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig")
end

function MyAddon:RefreshConfig()
  -- would do some stuff here
end
I've looked in some other addons and saw that they pass variables into this functions, but every addon does it a bit differently. For example:
MyAddon:RefreshConfig(_, event, database)
or
MyAddon:RefreshConfig(event, database, newProfileKey)

What is the correct way to use RefreshConfig (which vars to pass)?
Only thing I have there now is the db upvalue (db = self.db.profile). What else should I put there?

Thanks!
  Reply With Quote