How to add a delay for Angular 2 HTTP calls
<p>I am using Angular 2 with TypeScript to implement a web application that uses HTTP calls to a REST Server. </p>

<p>The problem is that some GET calls are faster than others and I have to add some delay before them. How can I remove this delays and handle this issue properly?</p>

<p>For example, after I delete one Manufacturer (in the code below), I have to go back to the view where I can see all the Manufacturers (there I implement the GET call inside the ngOnInit()).</p>

<pre><code>import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router, ActivatedRoute }   from '@angular/router';
import { DataService } from '../../../data/data.service';
import { CallManufacturerServices } from '../calls/calls.service';
import { ManufacturerClass } from '../class/manufacturer.class';

@Component({
    templateUrl: './app/inventory/manufacturer/view/view.component.html',
    styleUrls: ['./app/inventory/manufacturer/view/view.component.css'],
    providers: [CallManufacturerServices]
})

export class ViewComponent implements OnInit, OnDestroy {
    private sub: any;
    private ServerData: ManufacturerClass = {
        ManufacturerId: 0,
        ManufacturerName: 'N/D',
        ManufacturerWebSite: 'N/D'
    };

    constructor(
        private route: ActivatedRoute,
        private router: Router,
        private data: DataService,
        private calls: CallManufacturerServices) {
    }

    ngOnInit() {
        this.sub = this.route.params.subscribe(params =&gt; {
            let id = +params['id'];
            this.getSingleManufacturer(id);
        });
    }

    ngOnDestroy() {
        this.sub.unsubscribe();
    }

    private getSingleManufacturer(id: number) {
        this.calls.GetSingleManufacturer(id).subscribe(
            (data) =&gt; {
                this.ServerData = data.json();
            },
            error =&gt; console.log(error),
            () =&gt; console.log('getSingleManufacturer complete!')
       );
    }

    private deleteManufacturer(_manufacturer: ManufacturerClass) {
        this.calls.DeleteManufacturer(_manufacturer.ManufacturerId).subscribe(
            error =&gt; console.log(error),
            () =&gt; console.log('deleteManufacturer complete!')
        );
        /* this type of delay doesn't work */
        setTimeout(() =&gt; {}, 2000); // insert there the delay
        /* when I go to Manufacturer the Get call will start */
        this.goToManufacturer();
    }

    private goToManufacturer() {
        this.router.navigate(['/inventory/manufacturer']);
    }

    private goToEdit(manufacturer: ManufacturerClass) {
         this.router.navigate(['/inventory/manufacturer/edit', manufacturer.ManufacturerId]);
    }
}
</code></pre>