1 - Improving CallbackHandler
Nevcairiel and Mikk:
I'm developing a library which I would like to use CallbackHandler for tracing custom events. Although it's possible to implement it with the current version, I realized that it could be much easier to use if the need to set the callbacks registry as a variable were removed. I mean, it is only needed for "Fire", "OnUsed" and "OnUnused", and I think that there are better alternatives than the current one.
I would like to share my ideas, so, if you're interested, just let me know.
Best regards,
Jaliborc
- 4 comments
- 4 comments
Facts
- Last updated on
- 03 Aug 2009
- Reported on
- 01 Feb 2009
- Status
- Replied - Someone has replied after waiting for more information.
- Type
- Enhancement - A change which is intended to better the project in some way
- Priority
- Medium - Normal priority.
- #4
mikk Mon, 03 Aug 2009 02:02:04Dohh, I lost mail tracking for this and never saw your response.
No, I don't like your proposed changes.
The OnUsed/OnUnused are currently called unprotected, which makes them fast. If you want, you can always fire callbacks yourself in your own registry.
Always installing "Fire" in the destination object makes no sense - it makes it reachable by public sources, which in 99% of cases is not desirable.
- #3
Jaliborc Mon, 09 Feb 2009 20:03:05So, which is your opinion?
- #2
Jaliborc Sun, 01 Feb 2009 10:10:55To "get rid" of the registry, we only need to find alternatives for the "Fire", "OnUsed" and "OnUnused".
Used/Unused
Currently, Used and Unused are treated as functions indexed into the registry. I think that they could be treated as callbacks:
Registering callbacks from the MyObject ("MyCallBack" and "OtherCallBack") repository would fire the "OnUsed" callback. Unregistering them would fire "Unused". Of course, registering or unregistering "OnUsed" wouldn't fire itself, neither would "Unused".
Fire
Why was "Fire" placed in the registry? I could never understand. Probably because CallbackHandler was primary designed for AceEvent. Anyway, I think that "Fire" should be treated as "RegisterCallback", "UnregisterCallback" and "UnregisterAllCallbacks":
In the case of AceEvent, blocking the "FireEvent" could be done easily:
if you don't like the idea, making a new callback could also return the fire callback (but I think this option makes less sense)
Updating Embeds
Unlike all AceEvent libraries, CallbackHandler doesn't update embeds. I think that this could be solved by indexing the "Register", "Unregister", "UnregisterAll" and "Fire" into the library itself, and then indexing into the embeds functions that would simply call the first ones.
So, instead of (line 117):
We would first set a Register function
And then, when creating new registries:
As the "real" functions are indexed into the library itself, CallbackHandler will only need to index them again to update all embeds.
I hope I've been useful!
Jaliborc
- #1
mikk Sun, 01 Feb 2009 07:28:38We're listening - do explain away.