LuaEvent
LuaEvent is a Lua implementation of an events system similar to the game’s native event system.
For events triggered from Lua, it is slightly faster.
The main benefit to using a LuaEvent is that the event is an object rather than belonging to a global registry.
They are intended to belong to modules, classes or even objects.
local LuaEvent = require("Starlit/LuaEvent")
-
class starlit.LuaEvent<T>
Object oriented reimplementation of events. Performs slightly faster and fixes some bugs as well as providing some utilities
-
staticmethod new():
starlit.LuaEvent Creates a new event and registers it in the event list
-
addListener(self, listener: fun(...:
T...)):nil Adds a new listener to be executed last
- Parameters:
listener (fun(...:
T...)) – The listener
-
addListenerFront(self, listener: fun(...:
T...)):nil Adds a new listener to be executed first
- Parameters:
listener (fun(...:
T...)) – The listener
-
addListenerBefore(
self,
target: fun(...:T...),
listener: fun(...:T...)
):nil Adds a new listener to be executed before the target. Does nothing if the target is not a registered listener
-
addListenerAfter(
self,
target: fun(...:T...),
listener: fun(...:T...)
):nil Adds a new listener to be executed after the target. Does nothing if the target is not a registered listener
-
removeListener(self, target: fun(...:
T...)):nil Removes all instances of a listener from execution.
-
removeAllListeners(self):
nil Removes all event listeners
-
trigger(self, ...:
T...):nil Triggers all event listener functions with the arguments passed
-
staticmethod new():