pysap.base.observable
pysap.base.observable#
- class Observable(signals)[source]#
Bases:
object
Base class for observable classes.
This class defines a simple interface to add or remove observers on an object.
- add_observer(signal, observer)[source]#
Add an observer to the object. Raise an exception if the signal is not allowed.
- Parameters
signal (str) – a valid signal.
observer (callable) – a function that will be called when the signal is emitted.
- remove_observer(signal, observer)[source]#
Remove an observer from the object. Raise an eception if the signal is not allowed.
- Parameters
signal (str) – a valid signal.
observer (callable) – an obervation function to be removed.
- property allowed_signals#
Events allowed for the current object.
- _is_allowed_signal(signal)[source]#
Check if a signal is valid. Raise an exception if the signal is not allowed.
- Parameters
signal (str) – a signal.