I'm really struggling to grasp this concept. I have a container that is monitoring a dialog, which can emit various actions. Depending on the emitted action, I need to execute additional logic. I want to achieve this without using nested subscriptions or if statements. How can I accomplish this? Here's what I've attempted:
this.commonProducts$
.pipe(
take(1),
map(commonProducts => (this.dialogRef = this.dialog.open(AddProductDialogComponent, { data: commonProducts }))),
switchMap(() => {
return this.dialogRef.actions.pull(DialogProductAddActions.frequency).pipe(
map(newProduct => {
// perform some actions
})
);
}),
switchMap(() => {
return this.dialogRef.actions.pull(DialogProductAddActions.schedule).pipe(
map(newProduct => {
// perform other action
})
);
})
)
.subscribe(() => this.dialogRef.close());
However, only the first switchmap is effective.