One way to approach this is by updating the intervalValue
through a button click event. This value is dynamic and changes frequently.
intervalValue: number;
intervalValue: Observable<number>; // I also attempted using this method, but the interval requires a number input
ngOnInit() {
interval(intervalValue)
.pipe(
debounceTime(150),
distinctUntilChanged(),
tap(() => {
...
}),
startWith({}),
switchMap(() => {
...
}),
map(data => {
...
return data.content;
}),
catchError(() => {
...
})
).subscribe(data => this.data = data);
}
The issue arises when the intervalValue
changes while the interval
remains at its initial value. Is it possible to synchronize the interval with the changing intervalValue
?