An event emitter, in the style of Node.JS.
thor.events.EventEmitter.on ( event, listener )
Add the callable listenter to the list of listeners that will be called when event is emitted.
thor.events.EventEmitter.once ( event, listener )
Call listener exactly once, the next time that event is emitted.
thor.events.EventEmitter.removeListener ( event, listener )
Remove the callable listener from the list of those that will be called when event is emitted.
thor.events.EventEmitter.removeListeners ( event, ... )
Remove all listeners for event. Additional _event_s can be passed as following arguments.
thor.events.EventEmitter.listeners ( event )
Return the list of callables listening for event.
thor.events.EventEmitter.emit ( event, arg, ... )
Emit event with one or more _arg_s.
thor.events.EventEmitter.sink ( sink )
Given an object sink, call its method (if present) that corresponds to an events name if and only if there are no listeners for that event.
Decorator thor.events.on ( EventEmitter, event )
A decorator to nominate functions as event listeners. Its first argument is the EventEmitter to attach to, and the second argument is the event to listen for.
@on(my_event_emitter, 'blow_up') def push_red_button(thing): thing.red_button.push()
If the event is omitted, the name of the function is used to determine the event. For example, this is equivalent to the code above:
@on(my_event_emitter) def blow_up(thing): thing.red_button.push()