I'm a beginner working through basic examples with RxJS and Angular. I am using:
rxjs 5.5.6 angular 5.2.0
I'm getting the following error:
error TS2339: Property 'do' does not exist on type 'number[]'.
from the following code that converts back and forth between an array and a series of items. I am attempting to insert mergeAll in place of mergeMap, which compiles and works as expected in converting the array. I would expect an Observable returned from mergeAll according to the docs without having to cast, especially since mergeMap is based on mergeAll.
this.notWorking().subscribe();
notWorking(): Observable<any> {
return Observable.from([[1, 2, 3, 4]])
.do(obj => console.log(obj))
// .mergeMap(val => val)
.mergeAll()
.do(obj => console.log(obj))
.toArray()
.do(obj => console.log(obj))
}
In the documentation from ReactiveX RxJS, it shows only a return value of Observable for mergeAll. Am I looking at the right documentation? Am I not understanding something fundamental about RxJS?
public mergeAll(concurrent: number): Observable
Converts a higher-order Observable into a first-order Observable which concurrently delivers all values that are emitted on the inner Observables.
Reactive RxJS mergeAll documentation
If the case is that it is returning an iterable and this is intended, what is the best practice to chain observable operators? Do I have to cast between each chain or create an Observable? This doesn't make sense to me, I hope I'm just doing something wrong.