Package muntjac :: Package event :: Module event_router :: Class EventRouter
[hide private]
[frames] | no frames]

Class EventRouter

source code

                            object --+    
                                     |    
method_event_source.IMethodEventSource --+
                                         |
                                        EventRouter

EventRouter class implementing the inheritable event listening model. For more information on the event model see the muntjac.event package documentation.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
addListener(self, eventType, obj, method, arguments=None, eventArgIdx=None)
Registers a new event listener with the specified activation method to listen events generated by this component.
source code
 
removeListener(self, eventType, target, method=None)
Removes all registered listeners matching the given parameters.
source code
 
removeAllListeners(self)
Removes all listeners from event router.
source code
 
fireEvent(self, event)
Sends an event to all registered listeners.
source code
 
hasListeners(self, eventType)
Checks if the given Event type is listened by a listener registered to this router.
source code
 
getListeners(self, eventType)
Returns all listeners that match or extend the given event type.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

addListener(self, eventType, obj, method, arguments=None, eventArgIdx=None)

source code 

Registers a new event listener with the specified activation method to listen events generated by this component. If the activation method does not have any arguments the event object will not be passed to it when it's called.

For more information on the inheritable event mechanism see the muntjac.event package documentation.

Parameters:
  • eventType - the type of the listened event. Events of this type or its subclasses activate the listener.
  • obj - the object instance who owns the activation method.
  • method - the activation method or the name of the activation method.
Raises:
  • ValueError - unless method has a match in object
Overrides: method_event_source.IMethodEventSource.addListener
(inherited documentation)

removeListener(self, eventType, target, method=None)

source code 

Removes all registered listeners matching the given parameters. Since this method receives the event type and the listener object as parameters, it will unregister all object's methods that are registered to listen to events of type eventType generated by this component.

For more information on the inheritable event mechanism see the muntjac.event package documentation.

Parameters:
  • eventType - the exact event type the object listens to.
  • obj - the target object that has registered to listen to events of type eventType with one or more methods.
  • method - the method owned by the target that's registered to listen to events of type eventType. Or the name of the method owned by target that's registered to listen to events of type eventType.
Overrides: method_event_source.IMethodEventSource.removeListener
(inherited documentation)

fireEvent(self, event)

source code 

Sends an event to all registered listeners. The listeners will decide if the activation method should be called or not.

Parameters:
  • event - the Event to be sent to all listeners.

hasListeners(self, eventType)

source code 

Checks if the given Event type is listened by a listener registered to this router.

Parameters:
  • eventType - the event type to be checked
Returns:
true if a listener is registered for the given event type

getListeners(self, eventType)

source code 

Returns all listeners that match or extend the given event type.

Parameters:
  • eventType - The type of event to return listeners for.
Returns:
A collection with all registered listeners. Empty if no listeners are found.