WoWInterface - View Single Post - How could this be written neater?
View Single Post
05-07-17, 08:07 PM   #6
A Scalebane Royal Guard
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 429
Mixin literally stands for "mix in", as in mixing in stuff from another table into your own table. It's a good way to preserve memory, because it utilises the same basic functions that are useful in many different cases. It's essentially an implementation of inheritance and object-oriented programming, albeit less bloated.

There's also a function called CreateFramePool, which returns a table that can be used to recycle objects that are displayed dynamically. A typical case for that is when you don't know how many objects you need. The downside is that it expects an XML template for the type of frame you want to create a pool for.

In the example I posted, I used a simpler solution, which is to only use the downscaled ObjectPoolMixin. This is the basis of a frame pool, but you supply the functions to create and reset your objects yourself. This is useful for when you're creating your objects in pure Lua.

Generally, you probably shouldn't go looking for mixins unless you have a distinct need for them. If you do insist, however, you can use this script to list all existing mixins in your chat:
Lua Code:
  1. /run for k in pairs(_G) do if k:match("Mixin") then print(k) end end
  Reply With Quote