RxJs: Incrementally push stream of data to BehaviorSubject<[]>

后端 未结 2 894
無奈伤痛
無奈伤痛 2021-01-04 01:04

Basically I\'m trying to inflate BehaviorSubject<[]> with array of data which will be loaded in chunks.

BehaviorSubject<[]> wil

2条回答
  •  滥情空心
    2021-01-04 01:34

    Instead of using concat, you can instead use the spread operator:

    data = new BehaviorSubject([]);
    
    addData(foo: any): void {
      this.data.next([...this.data.getValue(), ...foo])
    }
    

    I've found this to be a bit more readable than a straight concat

提交回复
热议问题