operator_reduce
Fold values and emit only the final accumulator on completion.
See Also
- ScanOperator - Accumulate state and emit every intermediate result.
Example
cargo run -p rx_core --example operator_reduce_example
let _subscription = (0..=10)
.into_observable()
.reduce(|acc, next| acc + next, 0)
.subscribe(PrintObserver::new("reduce_operator"));
Output:
reduce_operator - next: 55
reduce_operator - completed
reduce_operator - unsubscribed