Using on(...) function in module 'events' gives an excption for handlers with no listeners. I cant work around it either because there is no function to check if the named event "test" in the sample below exists. Why is it that an exception is thrown if there are no event listeners???
import events
var e=initEventEmitter()
var arg:TEventArgs
e.emit("test",arg)
gives: Error: unhandled exception: invalid event: test [EInvalidEvent]
You can check if an event exist by using:
var exist = e.getEventhandler("test")
if exist > 0:
# it exist
else:
# doesn't exist
I'll see about getting the error disabled in future releases, however, you can go to events.nim and remove lines 97-98.