Rxjs and Observables - the perfect candidate for this type of task! Here is an example of how this can be achieved:
Template:
<input type="text" [value]="item.task_name"(keyup)="term$.next($event.target.value)">
component:
import ......
import {Subject} from 'rxjs/Subject';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/switchMap';
@Component{(
...
)}
export class YourComponent {
term$ = new Subject<string>();
constructor() {
this.term$
.debounceTime(1000)
.distinctUntilChanged()
.switchMap(term => );
}
}
subject- This is a type of object that acts as observable and observant, that is, you can subscribe to it and emit values from it (with next())!
debounceTime ,
distinctUntilChanges
switchMap ,