You could use source.flatMap(function(a_list){ return Rx.Observable.zip(a_list.map(f))}))
for example.
source :: Observable List A
a_list :: List A
f :: A -> Observable B
a_list.map(f) :: List Observable B
Rx.Observable.zip :: List Observable B -> Observable List B
flatMap :: Observable List A -> (List A -> Observable List B) -> Observable List B
Rx.Observable.combineLatest
should work the same instead of zip
. flatMap
could be replaced by Rx.Observable.flatMapLatest
if it existed in the first place (only exists at instance level), but could be replaced by Rx.Observable.concatMap
if you want to have some order respected.
So you can match the required signature but is that the logic you want? Zip
will complete whenever one of the observables in List Observable B
will complete. combineLatest
will repeat previously emitted values for all observables in List Observable B
except one. Do any one of these work for your use case? You could also engineer a version with zip
which completes when all observables in the list complete : cf. RXJS: alternately combine elements of streams (remove the last line .concatMap(function (list) { return fromArray(list); })
).
Cf. http://www.introtorx.com/content/v1.0.10621.0/12_CombiningSequences.html for operators combining sequences.