Should be quite a simple thing but I'm struggling to get my head around this. I just wish to prevent the observable continuing if the form is invalid. Any ideas?
this.subscription2 = this.myForm.valueChanges.pipe(
map(params => params['invalid']),
filter(invalid => !!invalid),
debounceTime(1000)).subscribe(x => {
//Logic here
});
CodePudding user response:
If the form is invalid, you don't listen to a property of it, but to the form itself.
this.subscription2 = this.myForm.valueChanges.pipe(
filter(invalid => this.myForm.valid),
debounceTime(1000)).subscribe(x => {
//Logic here
});