Angular Signals - debounce in effect()

Discussão em 'Angular' iniciado por Layne Robinson, Novembro 25, 2024.

  1. I have a signal that is bound to an input field. I'm trying to define an effect() for the searchTerm, but because it's user input, I'd like to debounce that effect (i.e. rxjs) so that the search doesn't happen with each keystroke. I'm unclear on how to accomplish this and the documentation doesn't really cover the situation.

    <input [ngModel]="searchTerm()" (ngModelChange)="searchTerm.set($event)">


    effect(() => {
    if (this.searchTerm() !== '') { this.search(); }
    });

    Continue reading...

Compartilhe esta Página