Callbacks

The utils.callback module in the utility library was created to provide a standalone location for creating callbacks that can be used.

This removes the need for coding multiple callbacks depending on framework choice.

Functions

cb()

Used to trigger a registered callback.

Callbacks must be registered first on the server, refer to the server side callbacks function reference for more information on registering callbacks.

Function

local function callback(name, data, cb)
    local cb_id = math.random(1, 1000000)
    callbacks[cb_id] = cb
    TriggerServerEvent('boii_utils:sv:trigger_callback', name, data, cb_id)
end

exports('callback_cb', callback)
utils.callback.cb = callback

Example

--- Trigger a registered callback.
utils.callback.cb('event_name', {}, function(response) ... end)

Last updated