-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-add the event system library so that events can be monitored (for testing purposes) #55
Comments
Parts of this are already covered by #376. The rest will follow later, once I've found a design that doesn't completely annoy me. |
As for event handlers: It would be conceivable that local etrace = require("etrace")
etrace.register("COFFEE_READY") -- Defines the event, but no handlers exist (optional)
etrace.enable()
local Programmer = {}
function Programmer:COFFEE_READY(event, payload)
print("Yay!")
end
etrace.register("COFFEE_READY", Programmer) -- NO error even though the event is known, because of the 2nd argument
etrace.create("COFFEE_READY") When executed, it should print |
Coming back to this, I don't like how the above design would complicate the interface and logic for
A global |
This is the global event registry from evo-luvi (see RFC), but it should be able to buffer events and payloads for testing purposes.
Using event emitters makes the code less decoupled and it's a bit of a pain to test whether a server has received some data, for example, which was a problem I encountered when writing tests for the TCP server before. I basically had to write a lot of boilerplate code, when I think it might be easier to just enable the event buffer, do the thing, and then fetch the events and compare to a list.
Goals:
CAPITALIZED_EVENT_NAME
handler unless otherwise specifiedCan mix in the most commonly-used APIs to enable more convenient "event emitter style" usage(obsolete?)The text was updated successfully, but these errors were encountered: