How to unsubscribe from an Observable returned by forkJoin?
<p>In my Angular2-typescript app, I'm using forkJoin to return an Observable only once all the parallel HTTP calls were made.</p>

<p><strong>Issue</strong>: the subscription callback keeps being executed indefinitely</p>

<p>Here is my code:</p>

<p><strong>http.service</strong></p>

<pre><code>import {Http} from "@angular/http";

constructor (private _http: HTTP) {}

makeGetRequest(....) {
    return this._http.get(URL)
           .map (res =&gt; res.json)
           .toPromise();
</code></pre>

<p><strong>my.service</strong></p>

<pre><code>import {Observable} from "rxjs/Observable";
import {HttpService} from "http.service"

constructor (private _httpService: HttpService) {}

myMethod(): Observable&lt;any[]&gt; {
 return Observable.forkJoin(
            this._httpService.makeGetRequest(
                URL1
            ),
            this._httpService.makeGetRequest(
                URL2
            )
        )
}
</code></pre>

<p><strong>my.component</strong></p>

<pre><code>import MyService from "my.service";
import Subscription from "rxjs";

constructor (private _service: MyService) {}

mySub: Subscription;

ngOnInit() {
    this.mySub = this._service.myMethod.subscribe(data =&gt; {
         data.forEach(console.log(data));
         this.mySub.unsubscribe();
     }
}
</code></pre>

<p>What I tried (same issue):</p>

<ul>
<li>return an Observable in Http.service rather than a Promise</li>
<li>in my.component use .first().subscribe() instead of just subscribe()</li>
<li>put this.mySub.unsubscribe(); at the end of ngOnInit rather than inside the subscribe callback (also with setTimeout(() => ....))</li>
</ul>