Simplified event handling via callbacks
Lots of the UI and nearly all addons do event handling, and many in similar ways. How about providing a streamlined way to do the same thing?
This wouldn't change how events work, but could perhaps provide ways to optimize event processing and would certainly provide a more straightforward way to interact with the event system. Lua Code:
|
I use a similar approach in rLib
https://github.com/zorker/rothui/blo...b/core.lua#L39 Lua Code:
|
I've done the same using a table as a pseudo callback object that has metamethods that are used to further control callbacks. The callback object is passed as self to the function given as well as by the wrapper API itself.
It would be much better if there was C code that did this or something similar instead of having to create invisible frames to handle events. |
I've been using my own "EventManager" API for my UI:
https://mayronui.com/p/pkg-mayron-events I like using this because it has an auto destroy feature to remove event handlers once they have been used (if you set auto destroy to true), and a few other nice features such as "FindHandlerByPriority" or "FindHandlerByKey" |
My take on an event handler:
https://github.com/p3lim-wow/Inomena...ore/events.lua Code:
-- this will register and assign a method in the function creation itself, handled by metatables |
And I just use this (or similar)
Lua Code:
But still. Would be nice to have it built in and standard. |
I might as well post mine, I have many versions of this and I don't even know if this is the latest one. I keep recreating it for every addon I need it in. :p
Lua Code:
|
I always waffle between writing my own, and using AceEvent
|
I do create a Task system with several features like :
Lua Code:
Also several features for thread only Lua Code:
For a simple container refresh, the code would be like Lua Code:
It'd be useful to put all codes together in some conditions. |
All times are GMT -6. The time now is 09:18 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI