Signal
A module used to invoke signals and connect to them
A signal is essentially a wrapper for a BindableEvent
. You can fire and connect to signals. These can be used to circumvent problems with circular dependencies by just firing the signal.
Defining Signals
We recommend defining signals in a single ModuleScript that will be required by a Quebec instance. Usually, this ModuleScript should be parented to the parent of the singletons folder. However, that is not a requirement.
local Signal = require(PathToQuebec.modules.Signal)
return {
BanUser = Signal.new("BanUser") :: Signal.Signal<(string, number)>,
UnbanUser = Signal.new("UnbanUser") :: Signal.Signal<(string)>,
}
Now you can connect to these signals using Signals.BanUser:connect(cb)
and fire them using Signals.BanUser:fire(...args)
Good Practice
It is recommended that you connect to signals during the init
phase:
local Service = Quebec.singleton({})
function Service.init(self: typeof(Service))
Signals.UnbanUser:connect(function (username: string)
-- ...
end)
end
return Service
The connect method is not performance intense so it is fine to use during initialization.
Last updated