I'm trying to perform 3 async actions (observables), one inside the other. 1. The first observable is the response of a modal dialog eventEmiter - the rest of the flow is depended on its response (let say that the modal return boolean emiter concerning to: "Do you want to delete the item"). 2. The second observable is the update (delete) action 3. The third is fetching back the new data after the deletion.
I'm using rxjs- and try to figure out how to do it without subscribe in a subscribe. See my code:
subscriptions : Subscription[] = [];
openDeleteDialog(data : any)
{
const modalRef : NgbModalRef = this.modalService.open(ConfirmationDialogComponent); //Modal dialoge reference
this.subscriptions.push(modalRef.componentInstance.passResult.subscribe(
(result =>//This is the response from the modal dialog
{
if (result)
{
let updateApi : UpdateApi = new UpdateApi(data);
this.srv.updateData(updateApi).pipe( //This is the update operation
tap(() =>
{
this.srv.getData(); //This is the fetch data operation
}
)
).subscribe();
}
}
)
));
}