Can the Subscribe
method be called twice?
I am attempting to create an API factory that stores data in the factory and allows different components to use that data for each AJAX call.
The factory:
export class api {
result = [];
constructor (protected http: Http) { }
getData ()
{
return this.http.get('./friends.json').map((res: Response) => res.json()).subscribe(res => this.result = res);
}
}
A test component calling the subscribe
method again:
export class TestPage {
showListResult;
constructor (protected api: api) {
this.api.getData().subscribe(res => this.showListResult = res)
}
}