local buckets = {}
local bucketfunc
function AceEvent:RegisterBucketEvent(event, delay, method)
AceEvent:argCheck(event, 2, "string")
AceEvent:argCheck(delay, 3, "number")
if AceEvent == self then
AceEvent:argCheck(method, 4, "function")
self = method
else
AceEvent:argCheck(method, 4, "string", "function", "nil")
if not method then
method = event
end
if type(method) == "string" and type(self[method]) ~= "function" then
AceEvent:error("Cannot register event %q to method %q, it does not exist", event, method)
end
end
if not buckets[event] then
buckets[event] = Compost and Compost:Acquire() or {}
end
if not buckets[event][self] then
buckets[event][self] = {}
buckets[event][self].current = {}
buckets[event][self].self = self
else
AceEvent:CancelScheduledEvent(buckets[event][self].id)
end
local bucket = buckets[event][self]
bucket.method = method
AceEvent:RegisterEvent(event, function(arg1)
bucket.current[arg1] = true
end)
if not bucketfunc then
bucketfunc = function(bucket)
local current = bucket.current
local method = bucket.method
local self = bucket.self
if next(current) then
if type(method) == "string" then
self[method](self, current)
elseif method then -- function
method(current)
end
for k in pairs(current) do
current[k] = nil
end
end
end
end
bucket.id = AceEvent:ScheduleRepeatingEvent(bucketfunc, delay, bucket)
end