eventemitter

A port of the node.js EventEmitter functionality

Classes:

EventEmitter
implements the event emitter functionality
class simulations.utils.eventemitter.EventEmitter[source]

Bases: object

Handles event emitting and listening

Public Methods:

add_listener()
add a listener for an event
on()
alias for add_listener()
once()
adds a listener, but only executes it once, then it is removed
emit()
trigger the listeners for an event
remove_listener()
remove a listener from an event
remove_all_listeners()
remove all listeners from an event
listeners()
get a copy of the listeners on an event
set_max_listeners()
set the maximum number of listeners for an event before warnings are issued (default: 10, None for no limit)
add_listener(event, listener=None)[source]

Adds a listener to an event

Parameters:

event
the event to listen for
listener
the handler for the event (should be a function / callable)
emit(event, *args, **kwargs)[source]

Emit an event, triggering the handlers on it with certain arguments

Parameters:

event
the event to trigger
args
arguments to pass to the triggered listeners
kwargs
keyword arguments to pass to the triggered listeners
listeners(event)[source]

Gets a COPY of the list of listeners on an event

Parameters:

event
the event for which to lookup the listeners
max_errstr = '"\n WARNING: Possible EventEmitter memory leak:\n {0} listeners added for {1}. Use set_max_listeners to increase the limit.\n '
on(*args)[source]

Alias for add_listener

once(event, listener=None)[source]
Add a listener, but only execute it the first time the event
occurs, then remove it

Parameters:

event
the event to listen for
listener
the listener function / callable
remove_all_listeners(event)[source]

Clears all listeners from an event

Parameters:

event
the event to clear listeners from
remove_listener(event, listener=None)[source]

Remove a listener from an event

Parameters:

event
the event from which to remove it
listener
the handler to remove
set_max_listeners(max_listeners)[source]

Set the maximum number of listeners for each event.

Parameters:

max_listeners
the maximum number of listeners allowed (None for no limit)
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.