refactor(imports/callback): response varargs

Trying to have scrt compatible responses gets weird when using
msgpack.
This commit is contained in:
Linden
2022-12-13 08:26:43 +11:00
parent c141d011d1
commit 124a5f15ba
2 changed files with 12 additions and 10 deletions
+6 -5
View File
@@ -24,15 +24,16 @@ local function triggerClientCallback(_, event, playerId, cb, ...)
---@type promise | false
local promise = not cb and promise.new()
events[key] = function(response)
events[key] = function(response, ...)
response = { response, ... }
events[key] = nil
if promise then
return promise:resolve(response and { msgpack.unpack(response) } or {})
return promise:resolve(response)
end
if cb and response then
cb(msgpack.unpack(response))
if cb then
cb(table.unpack(response))
end
end
@@ -62,7 +63,7 @@ local function callbackResponse(success, result, ...)
return false
end
return msgpack.pack(result, ...)
return result, ...
end
local pcall = pcall