Reputation: 297
How would I utilize debounce to only trigger once the user has stopped typing? I have currently keyup
triggering this function:
userTyping() {
let searchTerm = this.form.get('query');
searchTerm.valueChanges
.debounceTime(1000)
.subscribe(() => this.searchForUser());
}
I basically don't want multiple queries to be started as you type say james
in the search, only once the user stops typing for a certain time do I want it to fire.
Upvotes: 1
Views: 107
Reputation: 579
ngOnInit() {
this.userTyping()
}
userTyping() {
let searchTerm = this.form.get('query');
searchTerm.valueChanges.pipe().debounceTime(1000)
.subscribe(() => this.searchForUser());
}
Upvotes: 1