I'm writing a TSU which updates allstates when a system event happens, and I want to do the same update again after a certain time.
I can't use a callback function of the timer since it can't "return true" like TSU function does to tell WA to update allstates. I also can't fire the same event again since it's a system event which I can't fire by myself afaik.
Now I have to fire a custom event for this task. I wonder if there's a better way to do this?
Contexts:
- I am making a WA for feral druid bloodtalons (BT), which show me which spells I can cast to count towards BT.
- I use TSU to show the spell icons
The key part in my code:
function(allstates, event, ...)
-- skipped
local this = aura_env
if event == "UNIT_SPELLCAST_SUCCEEDED" then
local unitTarget, _, spellID = ...
if unitTarget == "player" and this.spellIDs[spellID] then
this.spellCastTimes[spellID] = GetTime()
-- Updates again when timer ends
C_Timer.After(this.BLOODTALONS_TIME_WINDOW, function()
WeakAuras.ScanEvents("JOEGNIS_BTSTC_REFRESH")
end)
changed = this.updateIcons(allstates)
end
elseif ...
end