operator_scan
Accumulate state and emit every intermediate result.
See Also
- ReduceOperator - Fold values and emit only the final accumulator on completion.
Example
cargo run -p rx_core --example operator_scan_example
let _subscription = (0..=10)
.into_observable()
.scan(|acc, next| acc + next, 0)
.subscribe(PrintObserver::new("scan_operator"));
Output:
scan_operator - next: 0
scan_operator - next: 1
scan_operator - next: 3
scan_operator - next: 6
scan_operator - next: 10
scan_operator - next: 15
scan_operator - next: 21
scan_operator - next: 28
scan_operator - next: 36
scan_operator - next: 45
scan_operator - next: 55
scan_operator - completed