Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Debouncing a search term when using the new Angular Resource API?

With RxJS we could debounce keystrokes like this prior to performing an http request.

this.query$.pipe(
    debounceTime(500),
    distinctUntilChanged(),

Does the new Angular Resource API have a way to debounce an input field prior to updating request parameters?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

ATM (19.0) there is no debouncing support with resource/rxResource, you’ll have to build this in userland.

resource is primarly a primitive that we can build upon. The whole fetch data story isn’t complete yet.

What you could do is :

inputStr = toSignal(this.query$.pipe(
    debounceTime(500),
    distinctUntilChanged())
); 

resource({
  request: this.inputStr;
  loader: (param) => { ... }
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading