mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +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({
|
lib = setmetatable({
|
||||||
exports = {},
|
exports = {},
|
||||||
|
onCache = setmetatable({}, {
|
||||||
|
__call = function(self, key, cb)
|
||||||
|
self[key] = cb
|
||||||
|
end
|
||||||
|
})
|
||||||
}, {
|
}, {
|
||||||
__index = call,
|
__index = call,
|
||||||
__call = call,
|
__call = call,
|
||||||
@@ -181,9 +186,11 @@ end)
|
|||||||
|
|
||||||
AddEventHandler('lualib:updateCache', function(data)
|
AddEventHandler('lualib:updateCache', function(data)
|
||||||
for key, value in pairs(data) do
|
for key, value in pairs(data) do
|
||||||
if cache[key] ~= nil then
|
if lib.onCache[key] then
|
||||||
cache[key] = value
|
lib.onCache[key](value, cache[key])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cache[key] = value
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user