pyziggy.broadcasters¶
Used by pyziggy.parameters to implement the observer pattern.
Classes
Simple class for implementing the observer pattern. |
|
Simple class for implementing the observer pattern. |
|
|
Instances of this class are returned by |
- class pyziggy.broadcasters.AnyBroadcaster¶
Bases:
objectSimple class for implementing the observer pattern. The callback parameter type is less restricted than it is for
Broadcaster.- add_listener(callback: Any, order: int = 100) ListenerCancellationToken¶
Registers a callback with the broadcaster.
- Parameters:
callback – A function that will receive the callback.
order – Order affects where the listener will be inserted relative to others. The minimum value of -1 means the listener will be inserted in front of all others. The default value is 100. There is no maximum.
- Returns:
A token that can be used to unregister the callback.
- class pyziggy.broadcasters.Broadcaster¶
Bases:
objectSimple class for implementing the observer pattern.
Used by
pyziggy.parameters.ParameterBaseto allow adding callbacks to device parameters.- add_listener(callback: Callable[[], Any], order: int = 100) ListenerCancellationToken¶
Registers a callback with the broadcaster.
- Parameters:
callback – A function that will receive the callback.
order – Order affects where the listener will be inserted relative to others. The minimum value of -1 means the listener will be inserted in front of all others. The default value is 100. There is no maximum.
- Returns:
A token that can be used to unregister the callback.
- class pyziggy.broadcasters.ListenerCancellationToken(broadcaster, listener_id: int)¶
Bases:
objectInstances of this class are returned by
Broadcaster.add_listener()andAnyBroadcaster.add_listener().- stop_listening() None¶
Unregisters the callback that was passed to either
Broadcaster.add_listener()orAnyBroadcaster.add_listener().