Channel

A module used to invoke channels and get results

Channels can only have one consumer (callback), but multiple producers.

A channel is a wrapper for a BindableFunction . It's used to invoke an event and get return values from it. They can be used to communicate with another service without having to require it.

Defining Channels

We recommend defining channels in a single ModuleScript, usually parented to the parent of the singletons folder.

local Channel = require(Quebec.modules.Channel)

return {
    IsPlayerBanned = Channel.new((string, number), (boolean, boolean)),
}

You can then invoke it by calling :invoke(...args) on it, or set a callback using :set(cb) :

Channels.IsPlayerBanned:set(function (username: string, userId: number): boolean
    return false, false
end)

Good Practice

It is recommended that you set callbacks during the initialization phase:

local Service = Quebec.singleton({})

function Service.init(self: typeof(Service))
    Channels.IsPlayerBanned:set(function (username: string, userId: number)
        -- ...
    end)
end

return Service

Last updated