Accumulated Operator
Rocket.accumulated — Function
accumulated(; copy::Bool = true)Creates an accumulated operator, which returns an Observable that emits the current item with all of the previous items emitted by the source Observable in one single ordered array.
Arguments
copy::Bool = true: controls whether each emitted array is an independent copy of the internal accumulator (see the note below). Defaults totrue.
Producing
Stream of type <: Subscribable{Vector{L}} where L refers to the type of the source stream
Examples
using Rocket
source = from([ 1, 2, 3 ])
subscribe!(source |> accumulated(), logger())
;
# output
[LogActor] Data: [1]
[LogActor] Data: [1, 2]
[LogActor] Data: [1, 2, 3]
[LogActor] Completed
using Rocket
source = of(1)
subscribe!(source |> accumulated(), logger())
;
# output
[LogActor] Data: [1]
[LogActor] CompletedWith the default copy = true every emission is an independent snapshot, so a downstream actor may safely retain the emitted arrays. With copy = false the operator forwards its live internal accumulator by reference on every emission — this avoids per-emission allocation (useful in hot paths) but means the returned array must not be mutated or retained: it keeps growing in place, so any previously-emitted array observed later will reflect the latest accumulated state rather than the snapshot at emission time.
See also: AbstractOperator, InferableOperator, ProxyObservable, logger
Description
Combines all values emitted by the source, using an accumulator function that joins a new source value with all past emitted values into a single array. This is similar to scan with a vcat accumulation function.