The SpellMixin interface was added to get spell data without the risk of it returning empty data.[1]
- Source: FrameXML\ObjectAPI\Spell.lua
API[]
- Spell:CreateFromSpellID(spellID) : spell - Creates an object from a spell ID.
Methods[]
- SpellMixin:SetSpellID(spellID)
- SpellMixin:GetSpellID() : spellID
- SpellMixin:Clear()
- SpellMixin:IsSpellEmpty() : boolean
- SpellMixin:IsSpellDataCached() : boolean
- SpellMixin:GetSpellName() : name
- SpellMixin:GetSpellTexture() : texture
- SpellMixin:GetSpellSubtext() : subtext
- SpellMixin:GetSpellDescription() : description
- SpellMixin:ContinueOnSpellLoad(callbackFunction)
- SpellMixin:ContinueWithCancelOnSpellLoad(callbackFunction) : cancelFunc
ContinueOnSpellLoad[]
Some spell data - such as subtext and description - are load on demand. You can use SpellMixin:ContinueOnSpellLoad() to asynchronously query the data.
local spell = Spell:CreateFromSpellID(139)
spell:ContinueOnSpellLoad(function()
local name = spell:GetSpellName()
local desc = spell:GetSpellDescription()
print(name, desc) -- "Renew", "Fill the target with faith in the light, healing for 295 over 15 sec."
end)
Warning: Certain spells might not return information when using
:ContinueOnSpellLoad
. For example spellID 10444 will return info for GetSpellInfo and C_Spell.RequestLoadSpellData but SPELL_DATA_LOAD_RESULT will have success:false
, possibly because of an error with other data like the spell description.
This will make :ContinueOnSpellLoad
never fire the callback. One workaround is to use :ContinueWithCancelOnSpellLoad
with a timeout or directly listen to SPELL_DATA_LOAD_RESULT
.
Patch changes[]
Patch 8.0.1 (2018-07-17): Added.
See also[]
External links[]
GitHub FrameXML, Gethe
Globe "wut?" Tool, Townlong-Yak
References[]
- ^ Ythisens 2018-04-24. Spell System API Changes.