<button (click)="onSaveItems()">Save</button>
this.selectedItems = [
{'id': 1, name: 'A'},
{'id': 2, name: 'B'},
{'id': 3, name: 'C'},
{'id': 4, name: 'D'},
{'id': 5, name: 'E'}
]
this.apiService1.deleteAllItems()
this.apiService2.addItem(itemId)
this.apiService3.addItemLog(itemId)
this.apiService4.addFlag()
When a user clicks on the Save button, I want to:
- Call the apiService1 and delete all items
- If step 1 was successful, I want to call apiService2 to add selected item
- If step 2 was successful, I want to call apiService3 to add item log for that specific item
- Repeat steps 2. i 3. for each item from selectedItems
- If all item logs are added successfully i want to call apiService4
(Please note that I can not change APIs logic)
Is there a way to do this with Angular and RxJS?