1

I know when I use the keyup event it means new http request. Is theres a way that it only request once? because I am thinking If I type my name "edizon" the http request will be :

e
ed
edi
ediz
edizo
edzion

<input type="text" (keyup)="func()">

can I optimize it and request once only? I am curious about speed.

edizonv
  • 449
  • 3
  • 9
  • 19
  • 1
    You can't just request once since you don't have a mechanism to tell if a particular keyup is the LAST one. But you can defer it and only send once request in a while. Check it out here https://stackoverflow.com/questions/41935424/how-to-achieve-a-debounce-service-on-input-keyup-event-in-angular2-with-rxjs – Harry Ninh Sep 29 '17 at 01:05
  • I have a question, everytime I type it have a request right, the first request must finish first before it display the complete word I type? I think I use async – edizonv Sep 29 '17 at 01:20
  • Possible duplicate of [How to achieve a debounce service on input keyup event in angular2 with rxjs](https://stackoverflow.com/questions/41935424/how-to-achieve-a-debounce-service-on-input-keyup-event-in-angular2-with-rxjs) – afnpires Sep 29 '17 at 08:16

0 Answers0