Best way to “flatten” an array inside an RxJS Observable
My backend frequently returns data as an array inside an RxJS 5 Observable (I'm using Angular 2). I often find myself wanting to process the array items individually with RxJS operators and I do so with the following code ( JSBin ): const dataFromBackend = Rx.Observable.of([ { name: 'item1', active: true }, { name: 'item2', active: false }, { name: 'item3', active: true } ]); dataFromBackend // At this point, the obs emits a SINGLE array of items .do(items => console.log(items)) // I flatten the array so that the obs emits each item INDIVIDUALLY .mergeMap(val => val) // At this point, the obs