CombineLatest¶
Definition¶
-
class
broqer.op.
CombineLatest
(*publishers, map_: Callable[[...], Any] = None, emit_on=None)[source]¶ Combine the latest emit of multiple publishers and emit the combination
Parameters: - publishers – source publishers
- map – optional function to be called for evaluation of current state
- emit_on – publisher or list of publishers - only emitting result when emit comes from one of this list. If None, emit on any source publisher.
Usage¶
>>> from broqer import Value, Sink, op
>>> s1 = Value()
>>> s2 = Value()
>>> combination = op.CombineLatest(s1, s2)
>>> disposable = combination.subscribe(Sink(print))
CombineLatest is only emitting, when all values are collected:
>>> s1.emit(1)
>>> s2.emit(2)
(1, 2)
>>> s2.emit(3)
(1, 3)
Subscribing to a CombineLatest with all values available is emitting the values immediate on subscription:
>>> combination.subscribe(Sink(print, 'Second sink:'))
Second sink: (1, 3)
<...>