I use concatMap to do two API calls consecutively, but the second one should only be run if a checkbox is checked. So this is my code:
this.myService.createArticle(article)
.pipe(
filter(() => this.checkbox),
concatMap(() => return this.mailer.createOtherResource(data)),
}).subscribe(
(x) => { console.log('OK', x); },
error => console.error('FALLA', error),
() => console.log('Finally I have really reached the END')
);
The thing is that, if the check box is not checked, even if the first observable does not return an error, the OK function is never run, only the 'finally' one, and I need it to inform the user that the resource was created. What can I do?
I tried with takeWhile instead pipe, and same result.