refactor(callback): types

This commit is contained in:
Linden
2022-08-08 17:16:57 +10:00
parent c3687d6874
commit 245af3df41
2 changed files with 10 additions and 8 deletions

View File

@@ -9,9 +9,9 @@ end)
---@param _ any
---@param event string
---@param playerId number
---@param cb function
---@param ... unknown
---@return unknown
---@param cb function|false
---@param ... any
---@return unknown?
local function triggerClientCallback(_, event, playerId, cb, ...)
local key
@@ -21,6 +21,7 @@ local function triggerClientCallback(_, event, playerId, cb, ...)
TriggerClientEvent(cbEvent:format(event), playerId, cache.resource, key, ...)
---@type promise | false
local promise = not cb and promise.new()
events[key] = function(response)
@@ -30,7 +31,7 @@ local function triggerClientCallback(_, event, playerId, cb, ...)
return promise:resolve(response)
end
cb(table.unpack(response))
return cb and cb(table.unpack(response))
end
if promise then