mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(init): callback hook when updating cache
This commit is contained in:
11
init.lua
11
init.lua
@@ -80,6 +80,11 @@ end
|
||||
|
||||
lib = setmetatable({
|
||||
exports = {},
|
||||
onCache = setmetatable({}, {
|
||||
__call = function(self, key, cb)
|
||||
self[key] = cb
|
||||
end
|
||||
})
|
||||
}, {
|
||||
__index = call,
|
||||
__call = call,
|
||||
@@ -181,9 +186,11 @@ end)
|
||||
|
||||
AddEventHandler('lualib:updateCache', function(data)
|
||||
for key, value in pairs(data) do
|
||||
if cache[key] ~= nil then
|
||||
cache[key] = value
|
||||
if lib.onCache[key] then
|
||||
lib.onCache[key](value, cache[key])
|
||||
end
|
||||
|
||||
cache[key] = value
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user