Partition

Definition

class broqer.op.Partition(size: int)[source]

Group size emits into one emit as tuple.

Parameters:size – emits to be collected before emit

Usage

Group size emits into one emit as tuple

Usage:

>>> from broqer import Subject, op
>>> s = Subject()
>>> partitioned_publisher = s | op.Partition(3)
>>> _d = partitioned_publisher | op.Sink(print, 'Partition:')
>>> s.emit(1)
>>> s.emit(2)
>>> s.emit(3)
Partition: (1, 2, 3)
>>> s.emit(4)
>>> s.emit((5, 6))
>>> partitioned_publisher.flush()
Partition: (4, (5, 6))