I am trying Angular2.
I noticed that the http service use Observable object instead of Promise (I don't like much that choice.. async/await are arriving).
In my service, I download a list of Plants from the webservice. Clicking on a plant I show the details using the routing.
But in this way when I go back, the plants are downloaded again (because the constructor is called again).
To avoid this I want to do something like:
public getPlants(): Observable<Plants[]>
{
if (this._plants != null)
return Observable.fromResult (this._plants); //This method does not exists
return this._http.get('../../res/heroes.json')...
}
Is there a way to do that?
How can I import the Observable class in my ts file?
Thanks!
Observable.just? (it is what it is called in other languages) - njzk2