This is why I proposed the UnSet Alt Function with a callback handler. The callback could be used for all addons to update their data when the callback is fired. :cool: This would keep all the data in "synch" without needing a ui relaod.
Interesting idea - only thing is that the data could be stored by multiple addons. Its best to use just one to load the alt data.
Absolutely true... but I don't see how LibAlts solves that either? (Maybe I'm missing something; entirely possible)
Libalts doesnt do anything besides provide an abstract data layer which decouples producers and consumers. An change in an alt would probably not be fully picked up until the next reload ui.
local mainName = GetMainName("SomeAlt")
local alts = { GetAltNames("SomeMain") }
Now you maintain your own SVs, and you can have multiple addons providing data, and the API is lolminimal.
An implementation would be something along the lines of:
local oldGetMainName = GetMainName or function() return end
function GetMainName(name)
if myAddon.db.chars[name] and myAddon.db.chars[name].main then
return myAddon.db.chars[name].main
else
return oldGetMainName(name)
end
end
Tadaa?
(Note "return" vs "return nil", which becomes important for alt names. "return nil" = 1 entry with nil in it. "return" = 0 values.)
Edit: Oh, and addons both providing and displaying main/alt data, e.g. Prat/Chatter, should of course call GetMainName() themselves, not only look in their own SVs.
Prat's already has an option to use the data from libalts
-- function for showing main names in the tooltip
function module:getMain(altname)
if self.db.profile.usealtlib then
local main = altregistry:GetMain(altname)
if main then
return self:formatCharName(main)
end
return false
end
-- check a main exists for the given alt name
if not self.Alts[altname] then return false end
return self.Alts[altname]
end
and publish its data
-- Load shared Alts data
for alt,main in pairs(self.db.realm.alts) do
altregistry:SetAlt(main,alt)
end
Now you maintain your own SVs, and you can have multiple addons providing data, and the API is lolminimal.
Thats how it works already - whats wrong with the way it is?
I also agree that the library should store the data rather than force addons to store it. Then there would be only one alts table for various addons to use, rather than, say, Prat storing the table, GuildGreet storing the table, some raid manager storing the table, a guild list organizer storing the table, etc. This defeats the purpose of a shared library, and they may as well use their own methods of creating/storing that data. Instead, the lib will store the table and the mods will access/write to it directly. One centralized location of the data for the mods to share.
Of course, this does require the user to install the library as standalone. Each mod that would use LibAlts would have to have a fallback in case a user did not have LibAlts installed. Having it installed would just be a bonus to the user, in that they would be able to share alt data across all addons they have installed that utilize it. Perhaps LibAlts could have its own frame to enter alt information as well - a centralized place to enter alt names into the table...
LibAlts-1.0 is about accessing the data. Zhinjio's library is about storing the data. They compliment each other.
With LibAlts-1.0 the goal was not to force existing addons to change how they store thier data internally. Just to allow others to access thier data without creating dependancies.
So (like sharedmedia, and libsharedmedia):
LibAlts-1.0 - Access shared alt information
AltsMains - Provide data for LibAlts-1.0
On the humorous side, theres some irony in me creating a minimal functionality library, and people saying it doesn't do enough. (Since I am not known for writing things with minimal functionality.)
I'd like to echo Pasta's concerns. Most end-users would never think to run two chat addons (as an example) at once in order to migrate the data, and it may not even work because errors will likely result from running two full-featured chat addons at the same time.
I do really like the idea of providing a centralized registry for alt data though.
Its not about storing the data, just exposing it for other addons to use.
A common API for accessing the data from any number of addons which may be collecting it. This lets you combine data from multiple sources. If you need a storage addon you can make one. Same concept as sharedmedia. It just provides a way for an addon to expose its internal data without creating a dependency for the addon using the data.
Unfortunately I think that makes this less useful than it could be. If I decide to switch from Chatter to Prat, I'd lose all my alt names anyways since they'd be using different saved variables.
You could say make a standalone addon for your guild which loads all the data from a static table included in the addon.
Once say Prat has loaded its data to the shared registry, it would use the registry for lookups, and only add to it if you add more mappings. If prat has no stored mappings, it could still use the ones another addon provides. Its better than nothing.
Interesting idea - only thing is that the data could be stored by multiple addons. Its best to use just one to load the alt data.
Libalts doesnt do anything besides provide an abstract data layer which decouples producers and consumers. An change in an alt would probably not be fully picked up until the next reload ui.
Prat's already has an option to use the data from libalts
and publish its data
Thats how it works already - whats wrong with the way it is?
LibAlts-1.0 is about accessing the data. Zhinjio's library is about storing the data. They compliment each other.
With LibAlts-1.0 the goal was not to force existing addons to change how they store thier data internally. Just to allow others to access thier data without creating dependancies.
So (like sharedmedia, and libsharedmedia):
LibAlts-1.0 - Access shared alt information
AltsMains - Provide data for LibAlts-1.0
On the humorous side, theres some irony in me creating a minimal functionality library, and people saying it doesn't do enough. (Since I am not known for writing things with minimal functionality.)
Its not about storing the data, just exposing it for other addons to use.
So, other addons dont need to do:
if Prat then
...
elseif Chatter then
...
end
You could say make a standalone addon for your guild which loads all the data from a static table included in the addon.
Once say Prat has loaded its data to the shared registry, it would use the registry for lookups, and only add to it if you add more mappings. If prat has no stored mappings, it could still use the ones another addon provides. Its better than nothing.
GetAlts(main) - Get a list of alts for a given name
GetMain(alt) - Get the main character associated with a given name
IsMain(name) - Is the given name a main character
IsAlt(name) - Is the given name an alternate character
The last 2 methods are more for convienience.
Internally storage would be a table of tables:
The library is just a registry, individual addons would need to provide the actual sv storage.