ConcatMap Operator

Rocket.concat_mapFunction
concat_map(::Type{R}, mappingFn::F = identity) where { R, F <: Function }

Creates a concat_map operator, which returns an Observable that emits the result of applying the projection function to each item emitted by the source Observable and taking values from each projected inner Observable sequentially. Essentialy it projects each source value to an Observable which is merged in the output Observable, in a serialized fashion waiting for each one to complete before merging the next.

Arguments

  • ::Type{R}: the type of data of output Observables after projection with mappingFn
  • mappingFn::F: projection function with (data) -> Observable{R} signature

Producing

Stream of type <: Subscribable{R}

Examples

using Rocket

source = from([ 0, 0 ]) |> concat_map(Int, d -> from([ 1, 2, 3 ], scheduler = AsyncScheduler(0)))
subscribe!(source, logger())
;

# output

[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Data: 3
[LogActor] Data: 1
[LogActor] Data: 2
[LogActor] Data: 3
[LogActor] Completed

See also: AbstractOperator, RightTypedOperator, ProxyObservable, logger

source

Description

Returns an Observable that emits items based on applying a function that you supply to each item emitted by the source Observable, where that function returns an (so-called "inner") Observable. Each new inner Observable is concatenated with the previous inner Observable.

Warning

If source values arrive endlessly and faster than their corresponding inner Observables can complete, it will result in memory issues as inner Observables amass in an unbounded buffer waiting for their turn to be subscribed to.

Note

concat_map is equivalent to merge_map with concurrency parameter set to 1.

See also

Operators, merge_map