ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   LibStub Question (https://www.esoui.com/forums/showthread.php?t=2166)

circonian 08/23/14 01:52 PM

LibStub Question
 
I see different posts where people are doing, one or the other of, the following:
Lua Code:
  1. LibStub:GetLibrary("LibAddonMenu-2.0")
  2. LibStub("LibAddonMenu-2.0")

What is the difference, if any?

Garkin 08/23/14 01:55 PM

Quote:

Originally Posted by circonian (Post 11785)
I see different posts where people are doing, one or the other of, the following:
Lua Code:
  1. LibStub:GetLibrary("LibAddonMenu-2.0")
  2. LibStub("LibAddonMenu-2.0")

What is the difference, if any?

There is no difference. Direct call of LibStub table calls LibStub:GetLibrary method.

See this line in the library code:
Lua Code:
  1. setmetatable(LibStub, { __call = LibStub.GetLibrary })

A bit more about metatables:
http://lua-users.org/wiki/MetatableEvents
http://nova-fusion.com/2011/06/30/lu...bles-tutorial/

CrazyDutchGuy 08/23/14 01:56 PM

none

LibStub("LibAddonMenu-2.0") will result internally to a call to LibStub:GetLibrary

I prefer to be verbose in such things when coding so i just use LibStub:GetLibrary

circonian 08/23/14 01:58 PM

Ah, that was my guess, but I wasn't sure. Thanks.


All times are GMT -6. The time now is 07:22 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI