Signal
A simple publish/subscribe architecture implementation
Functions
subscribe
Signal:subscribe(callback: (...any) → ()--
The callback to be invoked
) → () → ()--
A function that disconnects the callback
Registers a callback to be invoked when the signal is fired.
once
Signal:once(callback: (...any) → ()--
The callback to be invoked
) → () → ()--
A function that disconnects the callback
Disconnects the callback after it is invoked once. This is a useful shorthand if you only need a callback to be fired once.
fire
Signal:fire(...: any) → ()
Invokes all currently subscribed callbacks. Note that, if a callback is
subscribed mid-fire, it will not be invoked during that firing.
Callbacks are invoked using
task.spawn,
so it's okay to yield inside a callback.