I'm trying to figure out how to implement a straightforward condional operation into an observable.
this.deactivate$
.pipe(
filter((canDeactivate) => !canDeactivate),
switchMap(() => Observable.of(window.confirm("message")))
);
What I want to get is that:
if (canDeactivate) {
return canDeactivate;
}
else {
return window.confirm("message");
}
The problem on first above code is that when I'm filtering emitted value, the rest of operators are not performed and stream stops to populate emitted value.
Any ideas?