Quantcast ESOUI - View Single Post - Let's get rid of LibStub!
View Single Post
04/28/19, 02:18 PM   #1
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,381
Let's get rid of LibStub!

I believe this can be done in 3 "easy" steps:

1) Update libraries to provide an alternative way of being accessed.
This step shouldn't introduce any major compatibility issues as we still keep everything as is and addons that have not been updated can use LibStub as a method to access the library as before. It's just to pave the way to phase out library access via LibStub in addons
All that should be necessary is to extend the code like this:
Lua Code:
  1. local MAJOR, MINOR = "LibSomething", 3
  2. local lib = LibStub:NewLibrary(MAJOR, MINOR)
  3. if not lib then
  4.     return
  5.     -- already loaded and no upgrade necessary
  6. end
  8. LibSomething = lib -- new way to access it without LibStub

In the manifest we also add the "AddOnVersion" and "IsLibrary" directive:
## AddOnVersion: 3
## IsLibrary: true
That's not strictly necessary until after LibStub has been removed from the lib, but it will ensure that only the newest standalone version is loaded (embedded versions will behave as before) and also move it to the new library section in the addon menu once Elsweyr is released.

2) Find all addons that use a library and change them (or request it) to access dependent libraries via the newly introduced global variable instead of LibStub, remove its files from the addon manifest (so it is no longer embedded) and change from OptionalDependsOn to DependsOn.
Lua Code:
  1. local LS = LibStub("LibSomething")
should become
Lua Code:
  1. lobal LS = LibSomething

3) Update libraries to no longer use LibStub. This will likely cause compatibility issues with any addons that have not been updated in step 2, but at some point we just need to pull the trigger, otherwise LibStub won't ever disappear completely.

Lua Code:
  1. local lib = {}
  2. LibSomething = lib

Let me know what you think. Did I miss anything? Who's on board?
I will start with step 1 in LAMr28 and will introduce the new global variable "LibAddonMenu".
Like what I do? Support me on Patreon!
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.

Last edited by sirinsidiator : 04/30/19 at 06:07 AM.
  Reply With Quote