Answer the question
In order to leave comments, you need to log in
RxJs: How to properly debounce?
Good time of the day!
I need the method (this.goToProc(proc)) to be called no more than half a second.
I try like this:
...
import {debounceTime} from 'rxjs/operators';
...
ngOnInit(): void {
this.dataService.proc.subscribe({
next: (proc) => {
this.dataService.proc.pipe(
debounceTime(500)
).subscribe(e => this.goToProc(proc));
}
});
}
...
import {debounce } from 'rxjs/operators';
import { timer } from 'rxjs';
...
ngOnInit(): void {
this.dataService.proc.subscribe({
next: (proc) => {
this.dataService.proc.pipe(
debounce(() => timer(500))
).subscribe(e => this.goToProc(proc));
}
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question