Lore archive · Warcraft Wiki, 2023 dump
Struct FunctionContainer
Last wiki revision 2023-03-18
FunctionContainer objects wrap a single Lua function to be executed later as a callback from native APIs.
Function containers are exposed to the scripting environment as handles with a set of predefined methods to control execution of the callback. It is permitted to store additional user-defined fields on function containers, so long as they do not conflict with any of the predefined methods.
- FunctionContainer:Cancel - Cancels the callback, preventing the stored function from being called.
- FunctionContainer:Invoke(...) - Invokes the callback if not cancelled, passing the supplied arguments. Does not return any values.
- FunctionContainer:IsCancelled - Checks if the stored callback has been cancelled.
- Function containers objects can be supplied in-place of function arguments to some APIs such as.
- Function containers can only store Lua functions.
- It is not possible to create a function container that directly calls a native API function, nor any function that has been.
- It is also not possible to create a function container that will call a non-function value, including objects with a metamethod.
- It is not possible to use standard Lua functions such as next or pairs to iterate over any stored fields on function container objects.
- Attempting to replace any predefined methods will raise an "Attempted to assign to read-only key" error.
- The stored function within the container cannot be retrieved.
Source
https://warcraft.wiki.gg/wiki/Struct_FunctionContainer · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.