How to properly use CreateFramePool() ?
I've been seeing a lot of Blizzard code using CreateFramePool() and I'm wondering if it's worth using this myself as opposed to creating my own stack-like data structure. However, maybe it does something more than this but I can't find any documentation on it.
This is the content found inside a returned frame pool object:
My question is this: Is there any documentation on how to use this?
I'm assuming that you can disable/enable frames from the pool using:
Not sure what OnLoad does. Does it run when a frame becomes active?
This is entirely implemented in Lua so you can just read the source code.
This is perfect. I wasn't sure what the main object was called. Thank you!
I'll start running some tests and figure out how it all fits together :)
Once I understood what this frame pool did, I created a very simple version I use in Decliner for generating OnUpdate responses to some filters. This way, I don't need several dedicated OnUpdate frames, just a dynamic pool that uses the first unused frame or creates a new one that adds to the pool when finished. Blizzard's way is definitely more sophisticated and made for different scenarios, but if you just need a disposable OnUpdate frame with one piece of data included in the frame, you could try what I did.
An example of usage is the following response to blocked guild invites:
This calls a frame directly from the pool table, while getting the index from f.pool's return and putting the current SFX setting into the "t" key of the frame. Then I turn off SFX. Once the OnUpdate fires a frame later, reset SFX and release the frame using its index stored in the "i" key.
This completely blocks the "level up" sound when someone invites you to a guild.
I'm sure there's a cleaner way to do what I did, but it works for me.
@Kanegasi I've made a few things like this myself for a timer bars tracking addon except it executes the update function for each frame in the pool iteratively and probably not as intricate as your interesting design. Thanks for the example, I like it. Gives me a new approach to consider.
It's mostly good for when you want to fill a list of objects, was messing around with this one and texturepools.
|All times are GMT -6. The time now is 03:28 PM.|
vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI