RxJS的影响可以从外部观察到

时间:2017-01-09 19:10:17

标签: javascript http asynchronous rxjs observable

我是RxJS的首发,只熟悉基础知识。 情况是: 我有一个observable应该按需异步加载一些数据。另一个函数应该创建该需求并要求第一个observable加载下一个数据。

像这样:

dataPiece$:Observable<DataPiece> = http.load(this.url + this.pieceUrl)

loadNextPiece(pieceUrl)
{
   this.pieceUrl = pieceUrl;
   //make the observable to automatically load new piece of data 
   //once pieceUrl is updated
}

1 个答案:

答案 0 :(得分:1)

您可以使用Subject创建包含pieceUrls的流。对于每个部分,都会发出请求并使用switchMap您可以将所有响应合并到一个新流中。

build