pyziggy.broadcasters

Used by pyziggy.parameters to implement the observer pattern.

Classes

AnyBroadcaster()

Simple class for implementing the observer pattern.

Broadcaster()

Simple class for implementing the observer pattern.

ListenerCancellationToken(broadcaster, ...)

Instances of this class are returned by Broadcaster.add_listener() and AnyBroadcaster.add_listener().

class pyziggy.broadcasters.AnyBroadcaster

Bases: object

Simple 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: object

Simple class for implementing the observer pattern.

Used by pyziggy.parameters.ParameterBase to 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: object

Instances of this class are returned by Broadcaster.add_listener() and AnyBroadcaster.add_listener().

stop_listening() None

Unregisters the callback that was passed to either Broadcaster.add_listener() or AnyBroadcaster.add_listener().