RxJS 1 array item into sequence of single items - operator

前端 未结 5 612
一向
一向 2021-01-11 10:40

Given such observable

Rx.Observable.of([1,2,3,4,5])

which emits a single item (that is an array), what is the operator

5条回答
  •  旧巷少年郎
    2021-01-11 11:10

    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
    

提交回复
热议问题