could you please tell me how to add the delay before hitting HTTP request to the server . I will give you the example .I saw a website there is button
on click of +
it increases the counter value and -
it decrease the value
.If you check the network request they are not hitting service
on each button click or each increment value (if the user clicks +
button many times say 5
times). They hit the service only one
time when the user stops increment/decrement it's value for few second. I think they are using something like debouncing
concept.
can we also implement this in angular 4 .I try to implement debouncing and so that it will not fire request on each click .
here is my code https://stackblitz.com/edit/angular-zf6ysz?file=src%2Fapp%2Fapp.component.ts
increaseCounter(){
this.counter = this.counter +1;
this.requestHttp(this.counter);
}
requestHttp(val){
var url ="http://api.mathjs.org/v4/?expr="+val+"*"+val;
console.log(url);
this.http.get(url).subscribe((res)=>{
console.log(res ,"eee")
})
example, where I saw it, is implemented debouncing
https://www.swiggy.com