Quantcast ESOUI - View Single Post - Let's get rid of LibStub!
View Single Post
05/01/19, 05:34 AM   #17
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,305
@Drakanwulf That looks pretty good. I use the following snippet for my own "new-style" libs:

Lua Code:
  1. local LIB_IDENTIFIER = "LibDebugLogger"
  2.  
  3. assert(not _G[LIB_IDENTIFIER], LIB_IDENTIFIER .. " is already loaded")
  4.  
  5. local lib = {}
  6. _G[LIB_IDENTIFIER] = lib

You can probably drop the second assert, since that should never ever be possible to happen, and if it does happen, you have other problems.

@Kyoma the assert is mostly in case other developers decide to start making a new addon with that name, so they get a warning right away.
__________________
Like what I do? Support me on Patreon!
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote