Documentation for pulsar 0.9.2. For development docs, go here.
Events are classes implementing the AbstractEvent
interface
The EventHandler
class is for creating objects with events.
These events can occur once only during the life of an EventHandler
or can occur several times. Check the
event dispatching tutorial for an overview.
pulsar.async.events.
Event
(loop=None, name=None)[source]¶The default implementation of AbstractEvent
.
pulsar.async.events.
OneTime
(loop=None, name=None)[source]¶An AbstractEvent
which can be fired once only.
This event handler is a subclass of Future
.
Implemented mainly for the one time events of the EventHandler
.
pulsar.async.events.
EventHandler
(loop=None, one_time_events=None, many_times_events=None)[source]¶A Mixin for handling events on async objects.
It handles OneTime
events and Event
that occur
several times.
ONE_TIME_EVENTS
= ()¶Event names which occur once only.
MANY_TIMES_EVENTS
= ()¶Event names which occur several times.
events
¶The dictionary of all events.
bind_event
(name, callback)[source]¶Register a callback
with event
.
The callback must be a callable accepting one positional parameter
and at least the exc
optional parameter:
def callback(arg, ext=None):
...
o.bind_event('start', callback)
the instance firing the event or the first positional argument
passed to the fire_event()
method.
Parameters: |
|
---|---|
Returns: | nothing. |
bind_events
(**events)[source]¶Register all known events found in events
key-valued parameters.
The events callbacks can be specified as a single callable or as list/tuple of callabacks or (callback, erroback) tuples.
fire_event
(name, *args, **kwargs)[source]¶Dispatches arg
or self
to event name
listeners.
name
is a one-time event, it makes sure that it was
not fired before.Parameters: |
|
---|---|
Returns: | the |
silence_event
(name)[source]¶Silence event name
.
This causes the event not to fire at the fire_event()
method
is invoked with the event name
.
copy_many_times_events
(other)[source]¶Copy many times events from other
.
All many times events of other
are copied to this handler
provided the events handlers already exist.