Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: deprecating qb callback handling in favor of ox_lib callbacks #59

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,15 @@ end)
-- Callback Events --

-- Client Callback
---@deprecated call a function instead
RegisterNetEvent('QBCore:Client:TriggerClientCallback', function(name, ...)
QBCore.Functions.TriggerClientCallback(name, function(...)
TriggerServerEvent('QBCore:Server:TriggerClientCallback', name, ...)
end, ...)
end)

-- Server Callback
---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Client/ instead
RegisterNetEvent('QBCore:Client:TriggerCallback', function(name, ...)
if QBCore.ServerCallbacks[name] then
QBCore.ServerCallbacks[name](...)
Expand Down
3 changes: 3 additions & 0 deletions client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,19 @@ end
-- Callback Functions --

-- Client Callback
---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Client/ instead
function QBCore.Functions.CreateClientCallback(name, cb)
QBCore.ClientCallbacks[name] = cb
end

---@deprecated call a function instead
function QBCore.Functions.TriggerClientCallback(name, cb, ...)
if not QBCore.ClientCallbacks[name] then return end
QBCore.ClientCallbacks[name](cb, ...)
end

-- Server Callback
---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Client/ instead
function QBCore.Functions.TriggerCallback(name, cb, ...)
QBCore.ServerCallbacks[name] = cb
TriggerServerEvent('QBCore:Server:TriggerCallback', name, ...)
Expand Down
5 changes: 5 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ QBCore = {}
QBCore.PlayerData = {}
QBCore.Config = QBConfig
QBCore.Shared = QBShared

---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Client/ instead
QBCore.ClientCallbacks = {}

---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Client/ instead
QBCore.ServerCallbacks = {}

IsLoggedIn = false

exports('GetCoreObject', function()
Expand Down
2 changes: 2 additions & 0 deletions server/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ end)
-- Callback Events --

-- Client Callback
---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Server instead
RegisterNetEvent('QBCore:Server:TriggerClientCallback', function(name, ...)
if QBCore.ClientCallbacks[name] then
QBCore.ClientCallbacks[name](...)
Expand All @@ -166,6 +167,7 @@ RegisterNetEvent('QBCore:Server:TriggerClientCallback', function(name, ...)
end)

-- Server Callback
---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Server instead
RegisterNetEvent('QBCore:Server:TriggerCallback', function(name, ...)
local src = source
QBCore.Functions.TriggerCallback(name, src, function(...)
Expand Down
3 changes: 3 additions & 0 deletions server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,19 @@ end
-- Callback Functions --

-- Client Callback
---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Server instead
function QBCore.Functions.TriggerClientCallback(name, source, cb, ...)
QBCore.ClientCallbacks[name] = cb
TriggerClientEvent('QBCore:Client:TriggerClientCallback', source, name, ...)
end

-- Server Callback
---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Server instead
function QBCore.Functions.CreateCallback(name, cb)
QBCore.ServerCallbacks[name] = cb
end

---@deprecated call a function instead
function QBCore.Functions.TriggerCallback(name, source, cb, ...)
if not QBCore.ServerCallbacks[name] then return end
QBCore.ServerCallbacks[name](source, cb, ...)
Expand Down
4 changes: 4 additions & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
QBCore = {}
QBCore.Config = QBConfig
QBCore.Shared = QBShared

---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Server instead
QBCore.ClientCallbacks = {}

---@deprecated use https://overextended.github.io/docs/ox_lib/Callback/Lua/Server instead
QBCore.ServerCallbacks = {}

exports('GetCoreObject', function()
Expand Down
Loading