TestAddOn = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0")
Now if I have the above code, myfunction() will run 100 seconds after the event is scheduled, as expected. However, before myfunction() is executed (during the 100 second countdown) the following will return (false, nil) as the 2 return values:
Now, I could have done this instead:
self:ScheduleEvent(self.myfunction, 100, self)
which will also run that myfunction() 100 seconds later. However,
will throw an error saying that the input argument must be a string. Is this intended behavior? Because I want to use :IsEventScheduled() to check if an event is already scheduled to avoid double registering:
-- this chunk of code fails because :IsEventScheduled()
--always returns false
if not self:IsEventScheduled("mytest") then
Do I have to use my own local boolean flag to avoid double registering for an event, or use my own frame and own OnUpdate function to achieve this? At the current moment, if I run
that is, schedule "mytest" three times, myfunction() will run three times 100 seconds later. The later ScheduleEvent() calls do not overwrite the earlier ones, they are all scheduled.
If I look inside AceEvent-2.0 and look at the functions AceEvent:ScheduleEvent(event, delay, ...) and the corresponding local function ScheduleEvent(self, repeating, event, delay, ...), it is obvious that if event is a string and delay is a number, then "delayRegistry[t.id] = t" gets executed where t.id == t, since id == nil. As a result :IsEventScheduled("mytest") fails in the lookup since in the delayRegistry table, the key that was used was a table, not "mytest".
Likewise, it is impossible to :CancelScheduledEvent("mytest"). In fact, :CancelScheduledEvent() is checking for t to be a string twice.