Skip to content

CallbackRegistry

Inherits: Class

Methods

Add

lua
function CallbackRegistry:Add(func, key)

Adds a callback into the registry.

Parameters:

NameTypeDescription
funcF
keystringThe key (required if and only if the registry was created via NewWithKeys())

Call

lua
function CallbackRegistry:Call(key, ...)
  -> any

Calls a specific registered callback by its key and passes through its returns. NOTE: This registry must have been created via NewWithKeys() and without an execution time label.

Parameters:

NameTypeDescription
keystringThe key
...params<F>Arguments to pass to the callback

Returns:

TypeDescription
any

CallAll

lua
function CallbackRegistry:CallAll(...)

Calls all registered callbacks.

Parameters:

NameTypeDescription
...params<F>Arguments to pass to the callbacks

HasCallback

lua
function CallbackRegistry:HasCallback(funcOrKey)

Checks if a callback is already within the registry.

Parameters:

NameTypeDescription
funcOrKeyF | stringThe callback function for registries created via NewList() or the key if created via NewWithkeys()

IsEmpty

lua
function CallbackRegistry:IsEmpty()
  -> boolean

Returns whether or not the registry is empty.

Returns:

TypeDescription
boolean

Remove

lua
function CallbackRegistry:Remove(funcOrKey)

Removes a callback from the registry.

Parameters:

NameTypeDescription
funcOrKeyF | stringThe callback function for registries created via NewList() or the key if created via NewWithkeys()

Wipe

lua
function CallbackRegistry:Wipe()

Removes all callbacks from the registry.

_DoCallback

lua
function CallbackRegistry:_DoCallback(key, func, ...)

Parameters:

NameTypeDescription
key``
func``
...``

__init

lua
function CallbackRegistry:__init(hasKeys, executionTimeLabel)

Parameters:

NameTypeDescription
hasKeys``
executionTimeLabel``

Functions

NewList

lua
function CallbackRegistry.NewList(executionTimeLabel)
  -> CallbackRegistry

Creates a new callback registry which maintains a list of callbacks.

Parameters:

NameTypeDescription
executionTimeLabelstring

Returns:

TypeDescription
CallbackRegistry

NewWithKeys

lua
function CallbackRegistry.NewWithKeys(executionTimeLabel)
  -> CallbackRegistry

Creates a new callback registry which maintains a keyed table of callbacks.

Parameters:

NameTypeDescription
executionTimeLabelstring

Returns:

TypeDescription
CallbackRegistry