I have a control which is built from a FormBuilder. I want to put a debounceTime for each keyup but not when the user lost focus of the control.
this._control.valueChanges
.pipe(
takeUntil(this.ngUnsubscribe),
debounceTime(1000),
distinctUntilChanged()
)
.subscribe((value) => {
// Logic goes here
});
-------------------------------
onInputChange(event: any): void {
console.log(this.autoComplete.focus, "1"); // Return true
setTimeout(() => console.log(this.autoComplete.focus, "2")); // return false
}
So the first console log is true, and the one with the setTimeout is false
It make sense for the keyup to have a debounce time to 1000, so it can prevent multiple call to a backend service, but that does not make sense in case of a lostFocus event.
I may be missing something here but
How to implement different debounceTime for different event on the same control ?