RxJS 1 array item into sequence of single items - operator

I can't think of an existing operator to do that, but you can make one up :

arrayEmitting$.concatMap(arrayValues => Rx.Observable.merge(arrayValues.map(Rx.Observable.of)))

or the simpler

arrayEmitting$.concatMap(Rx.Observable.of)

or the shortest

arrayEmitting$.concatMap(x => x)

That is untested so let me know if that worked for you, and that uses Rxjs v4 API (specially the last one). This basically :

  • process each incoming array of values as one unit (meaning that the next incoming array will not interlap with the previous one - that is why I use concatMap)
  • the incoming array is transformed into an array of observables, which are merged : this ensures the emission of values separately and in sequence

You can also use the flatMap operator (https://stackoverflow.com/a/32241743/3338239):

Observable.of([1, 2, 3, 4])
  .flatMap(x => x)
  .subscribe(x => console.log(x));
// output:
// 1
// 2
// 3
// 4

You can use from now to convert an array into a sequence.

https://www.learnrxjs.io/operators/creation/from.html

from([4,5,6])