Subscribers

Subscriber

class broqer.Subscriber[source]

A Subscriber is listening to changes of a publisher. As soon as the publisher is emitting a value .emit(value) will be called.

Sink

class broqer.op.Sink(function: Optional[Callable[..., None]] = None, *args, unpack=False, **kwargs)[source]

Apply function(*args, value, **kwargs) to each emitted value. It’s also possible to omit function - in this case it’s acting as dummy subscriber

Parameters:
  • function – function to be called when source publisher emits
  • *args – variable arguments to be used for calling function
  • unpack – value from emits will be unpacked (*value)
  • **kwargs – keyword arguments to be used for calling function

OnEmitFuture

class broqer.op.OnEmitFuture(timeout=None, loop=None)[source]

Build a future able to await for. :param publisher: source publisher :param timeout: timeout in seconds :param loop: asyncio loop to be used

Trace

class broqer.op.Trace(function: Optional[Callable[..., None]] = None, *args, unpack=False, label=None, **kwargs)[source]

Trace is a subscriber used for debugging purpose. On subscription it will use the prepend flag to be the first callback called when the publisher of interest is emitting. :param callback: optional function to call :param *args: arguments used additionally when calling callback :param unpack: value from emits will be unpacked (*value) :param label: string to be used on output :param **kwargs: keyword arguments used when calling callback

TopicMapper

class broqer.hub.utils.TopicMapper(mapping: MutableMapping)[source]

Subscriber using topics on hub to write a dictionary on emits

Parameters:mapping – dictionary with topic:value mapping