operator_count
The count operator counts upstream emissions and emits the total once
upstream completes.
See Also
- IsEmptyOperator - Emit a single boolean indicating if the source emitted anything before it had completed.
- FilterOperator - Keep values that satisfy a predicate.
- ReduceOperator - Fold values and emit only the final accumulator on completion.
Example
cargo run -p rx_core --example operator_count_example
let _subscription = (1..=6)
.into_observable()
.filter(|value, _index| value % 2 == 0)
.count()
.subscribe(PrintObserver::new("count_operator"));
Output:
count_operator - next: 3
count_operator - completed
count_operator - unsubscribed