I am using RxJs concatMap to control the saving of some data in my application.
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
);
Currently this works however it also executes even if say "this.OneData" is empty or null...how can I keep it from sending essentially a NoOpp request?