Abdulaziz Alsubaie
Abdulaziz Alsubaie

Reputation: 720

convert Observable of Observables to simple Observable

I am using Rxjs and things looks good so far! I have this problem

how can I achieve this?

  // I have observable of observables!
    const bad$ = Rx.Observable.of([
      Rx.Observable.of(1),
      Rx.Observable.of(2),
      Rx.Observable.of(3),
      Rx.Observable.of(4),
      Rx.Observable.of(5)
    ])

    // I want to convert it to something like this
    const good$ = Rx.Observable.of([1, 2, 3, 4, 5])

Upvotes: 2

Views: 2236

Answers (1)

Denis Dmitrienko
Denis Dmitrienko

Reputation: 1751

As @martin already commented, the easy way to convert Observable of Observables to simple Observable with all emitted values is to use concatAll operator, i.e.:

const good$ = bad$.concatAll()

Upvotes: 2

Related Questions