I'm using Angular 10 and trying to collect window:keyup events for a certain amount of time using RXJS - but unfortunately not very successful at all. Basically I want to input data and if no key is pressed for a certain amount of time, the request should be submitted.
fromEvent(window, 'keyup').pipe(
map((ev: KeyboardEvent) => ev.key),
scan((acc, value) => acc + value),
debounceTime(500)
).subscribe(key => {
console.log(key);
});
That's how my basic approach looks like, which is basically doing what I want, but I'm unable to delete the scan result within the subscription result.
Is there a better way to achieve my desired behavior?