I just ran into the following issue
function doMagic(foo: boolean) {
return iif(
() => foo,
this.dialog.open(MyComponent).afterClosed(),
of(true)
).pipe( .... );
}
So, if foo === true
I want to open the dialog, if false, I don't and true
is emitted.
Now, the problem with this code is, that no matter what foo
is, the dialog will always open. Should I replace iif
with an if/else, something like this
function doMagic(foo: boolean) {
let stream = of(true);
if (foo) {
stream = this.dialog.....
}
stream.pipe(...);
}
or is there a way I can fix my initial code, such that, for example, the open
function behaves more as a stream.