LibBuilder-1.0

Addons
718 Downloads Game Version: 4.0.3a

Warning: This project is experimental. Its files will not synchronize across the CurseForge network.

LibBuilder is a tool for building multiple-file libraries. It manages a "workspace" for libraries equivalent to the addon table that gets passed as an argument to every file in a standalone addon.

Although you could have a functional setup without using LibBuilder by setting a "loading" flag in the table LibStub passes your library if it should load, the main advantage of LibBuilder is that it automatically checks if you forgot to "close" the library (with LibBuilder you call CloseLib; with the alternate setup you'd clear the "loading" flag).

To create a new workspace, get a reference to LibBuilder from LibStub and call its :NewLib() method, providing your library's major and minor version. At the beginning of each file in your library, call the :GetLib() method to get the major version, minor version, and workspace. After completing your library, make sure to call :CloseLib() so that LibBuilder knows where your library ends and the next one begins (if another library uses LibBuilder).

Note that LibBuilder does not provide a built-in feature to tell if your library should load (ie. if it's already loaded as an embed from another addon); I suggest storing a "canLoad" field in your workspace and having each file check that before running.

Comments

Posts Quoted: