Once the user confirms, I want the process to begin and keep the modal busy until it's complete. However, the current code does not function in this manner. The isModalBusy condition only turns false when an HTTP error is returned from the service. In all other cases, it remains true.
run() {
let inputParams = JSON.stringify(this.paramsInput);
this.confirmation.warn(
'RunConfirmationMessage',
'AreYouSure',
{messageLocalizationParams: []}
).pipe(
// take(1) when i put take(1) here it works tho,
filter(status => status === Confirmation.Status.confirm),
switchMap(() => {
this.workOutput = {
success: true,
consoleOutput: "Executing now..."
}
this.activeTabId = 1;
this.isModalBusy = true;
return this.processService.doWork({work: this.work, workParams: inputParams});
}),
finalize(() => {
this.isModalBusy = false
}),
).subscribe({
next: (result) => this.workOutput = result,
error: (error: HttpErrorResponse) => this.workOutput = {success: false, errorMessage: error.message} as WorkOutput,
});
}
I obtained this code from the theme documentation I am using, and I am unsure about the purpose of mapSwitch in this context. Any clarification on why this is used and how to make it function as intended would be greatly appreciated.