Cache

Definition

class broqer.op.Cache(init: Any = <class 'broqer.types.NONE'>)[source]

Caching the emitted values (make a stateless publisher stateful)

The Cache publisher is emitting a value on subscription.

Parameters:init – initialization for state

Usage

>>> from broqer import Subject, op
>>> s = Subject()
>>> cached_publisher = s | op.Cache(0)
>>> _disposable = cached_publisher | op.Sink(print, sep=' - ')
0
>>> s.emit(3)
3