View Single Post
05/18/14, 11:09 AM   #6
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
I wrote a short intro into what LibStub does (and what would happen without) over in the Addon forum at eso:
libStub:
http://www.esoui.com/downloads/info44-LibStub.html
You can easily have multiple instances and even version of the same library in your addon folder. Not only bring several addons them along, you might have a standalone copy. In this case wichever version is last executed would be the one used (as all addons access the same global variables for exposure, so it's "last come last served"). Unless the Library uses libStub. It's a library with the sole purpose of being a library version tool.
Using the libStub block other libraries .lua file will first check if a newer or the same version has already been loaded/executed. If that is the case, the .lua file is just skipped (via an early return).
If not (no or older version) the .lua file is executed. This makes certain that only the most recent version is in memory and that if a dozen addons bring the same version along only one of them is executed.
For optimal result also add the libraries to your "OptionalDependsOn". If the user has a standalone version installed that one is much more likely to be up to date. While it would still end up "on top" eventually, the lesser versions might still be executed costing unessesary time.
libStub uses two values to identify a library: The major and minor. It they have different major values, they are different libraries. If they have different minors, they are just different versions of the same library. You only change the major if something changed with the exposed functions (like names or wich functions are provided) or if otherwise backwards compatibility is not certain.
Since the 1.1 version lacked the LibStub block and ESOHEAD brought a 1.1 Version along, the (outdated) 1.1 would overwrite all the nice 1.11 isntalled (if it happened to run last).
The only certainty you have about excution order is that the order in your manifest is followed and that dependencies run before the addons that depends on them.
  Reply With Quote