View Single Post
06-28-16, 10:06 AM   #1
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Understanding CallbackHandler

The documentation for CallbackHandler-1.0 states that the way for mixing it in a library is like that:
lua Code:
  1. local lib = LibStub:NewLibrary("MyLibName", 1)
  2. lib.callbacks = lib.callbacks or LibStub("CallbackHandler-1.0"):New(lib)

The reasoning behind this is that the user could have multiple versions of the lib installed and the lib does not have control over the loading order. So lib.callbacks = lib.callbacks will retain attached callbacks from previously loaded versions.

If this is so, that means I have to always attach the callbacks table to the lib object, which in turn means everybody on the outside can fire my events instead of me. And if I give some event arguments back, then they could use that too to provide false data in my name.

lua Code:
  1. local libToHack = LibStub("MyLibName")
  2. libToHack.callbacks:Fire("MyEventName", "Got you")

And the user can't tell if I passed "Got you" or someone else.

Am I able to prevent this somehow?
  Reply With Quote