I have a form that creates an item in the backend, and optionally another resource depending if the user selects a checkbox. The second resource has to be created only after the first one is. I have come up with this code, but I don't think it's the right way to do it, especially the part where the checkbox hasn't been checked and I have to return a nonsense Observable. Any help?
this.myService.createArticle(article)
.flatMap(_ => {
if (this.checkbox) {
return this.mailer.createOtherResource(data);
} else {
return Observable.of('done');
}
});
I also tried returning an EmptyObservable, but it doesn't work.