How can i stop The second request before announcing the previous results ? in Angular Cli
For example Quotes
This is my quotes.component.ts :
import { Component, OnInit } from '@angular/core';
import { Response } from '@angular/http';
import {Quote} from "../quote.interface";
import {QuoteService} from "../quote.service";
@Component({
selector: 'app-quotes',
templateUrl: './quotes.component.html',
styleUrls: ['./quotes.component.css']
})
export class QuotesComponent implements OnInit {
quotes:Quote[];
loading = false;
busy = false;
constructor(private quoteService:QuoteService) {
}
ngOnInit() {
}
onGetQuotes() {
if (this.busy == false) {
this.loading = true;
this.busy = true;
this.quoteService.getQuotes()
.subscribe(
(quotes:Quote[]) => this.quotes = quotes,
(error:Response) =>console.log(error),
this.loading = false,
this.busy = false
);
}else{
alert('continuous request')
}
}
}
As you see i set "busy = false;" and set an "if" to
run the code if busy == false But when I send another request, twice or more ... the server accepts all requests
How can i stop The second request before announcing the previous results ?