orrery.observable.Observable#
- class Observable[source]#
Bases:
object
Base class for objects which can send notifications to observers.
Maintains a dictionary of event types to ObserverList objects
Methods
Add an observer to receive notifications for the specified event
Trigger a callback on all observers for this event
Remove existing observer for the specified event
- class ObserverList[source]#
Bases:
object
Class for managing observers and sending notifications for events
Makes special use of WeakKeyDictionary and WeakMethod so that the Observable won’t prevent observers from being destroyed, and if an observer is destroyed it will automatically be removed from the observers
- class CallbackArgs(callback, kwargs)#
Bases:
tuple
Create new instance of CallbackArgs(callback, kwargs)
- __add__(value, /)#
Return self+value.
- __mul__(value, /)#
Return self*value.
- callback#
Alias for field number 0
- count(value, /)#
Return number of occurrences of value.
- index(value, start=0, stop=9223372036854775807, /)#
Return first index of value.
Raises ValueError if the value is not present.
- kwargs#
Alias for field number 1
- add_observer(event, callback, **kwargs)[source]#
Add an observer to receive notifications for the specified event
- Parameters:
event – describes a unique event generated by this object
callback – bound method which will receive the callbacks
kwargs – additional arguments to be passed to the callbacks - these are added to the arguments passed in through the call to notify()
- Returns:
An id which can be used to remove the callback if necessary