feat(init): callback hook when updating cache

This commit is contained in:
Linden
2022-03-01 13:42:39 +00:00
parent 58faab6217
commit a37a897b10

View File

@@ -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)