我正在使用 RxJs concatMap 来控制我的应用程序中某些数据的保存。
this.myService.saveData(this.updatedData)
.pipe(
tap(data1Res => this.onData1Success(data1Res)),
concatMap(() => this.myService.saveOne(this.OneData)),
tap(data2Res => this.onData2Success(data2Res)),
concatMap(() => this.myService.saveTwo(this.TwoData)),
tap(data3Res => this.onData3Success(data3Res)),
concatMap(() => this.myService.saveThree(this.ThreeData)),
tap(data4Res => this.onData4Success(data4Res)),
concatMap(() => this.myService.saveFour(this.FourData)),
)
.subscribe(
res => this.onSaveSuccess(), // Reload values
err => console.log('error while saving', err) // Save to file or db
);
目前这有效,但是即使说“this.OneData”为空或为空,它也会执行......我怎样才能让它基本上不发送 NoOpp 请求?