Linked Questions
15 questions linked to/from caching results with angular2 http service
354 votes
23 answers
119k views
What is the correct way to share the result of an Angular Http network call in RxJs 5?
By using Http, we call a method that does a network call and returns an http observable: getCustomer() { return this.http.get('/someUrl').map(res => res.json()); } If we take this observable ...
0 votes
1 answer
4k views
How do you avoid making multiple HTTP calls for the same information in Angular2 RxJS? [duplicate]
I am building a simple web application which uses one endpoint ( let's say www.domain.com/card/cardname ) which returns an object as such: { name: 'john', type: 'male', text: 'funny guy' } I ...
43 votes
2 answers
35k views
How to get last value from a Subject?
I have two Angular2 components which need to share data via a service: @Injectable() export class SearchService { private searchResultSource = new Subject<string>() searchResult$ = this....
4 votes
3 answers
8k views
Angular 2 - How would you subscribe multiple variables?
Using Angular 2, I receive JSON data from a service. Something like this: { "customerName": "foo", "customerAddress": "123 Somewhere", "products": [ { "...
5 votes
3 answers
6k views
Angular 2 cache http request using the power of observables
I've found a number of approaches to cache reactive observables and, more specifically, the results of http requests. However, I am not fully satisfied with the proposed solutions because of the ...
3 votes
2 answers
5k views
Stop component reload after navbar is clicked
I have a Navigation bar in Angular 2. It works like below. <nav class="navbar navbar-toggleable-md navbar-light bg-faded"> <button class="navbar-toggler navbar-toggler-right" type="button"...
4 votes
2 answers
2k views
How to reuse service calls in Angular 2
I have two components using the same service. On FirstComponent, I get some data from a service: getLiveData() { Observable.interval(1000) .mergeMap(() => this.service.getData()) ....
1 vote
2 answers
2k views
Angular2, use a service inside another service
Starting from THIS awesome response, I want to use many DataService instances inside another global service (SystemService) that store and serve many "cacheable" datas. I have imported the DataService ...
2 votes
1 answer
1k views
Share data to children routes
Even though it seems like a common situation I haven't found a decent solution of how do I share a data from the parent to children routes. Routes: { path: ':id', component: DetailComponent, ...
0 votes
2 answers
1k views
Angular 2 transfer ajax call response to another component
I just started playing with angular 2 and i've ran into a small problem, that i ve searched for in various forms and also angulars documentation. I've managed to make a service that makes a call and ...
1 vote
1 answer
479 views
angular2 cache server response
I need to cache server response in my service. I checked this question caching results with angular2 http service, here I have found 2 ways of doing that 1) Observable.share() - but as it said in the ...
1 vote
1 answer
879 views
Caching http get response for performance reasons with Rxjs
The potential 'duplicate' questions do not answer my question - I potentially think my use of Observables is different than the examples and as I point out, I attempted using share() unsuccessfully. ...
2 votes
0 answers
718 views
Rxjs Observable + Angular Guard to check if user is logged in
Setup: I have a LoggedInGuard (injected with AuthService). In AuthService's constructor I've subscribed to http.get to set this.loggedIn = true based on the response from server. Question: When user ...
0 votes
1 answer
415 views
return data from either cache or HTTP - Is there an easier way? [duplicate]
(In an Angular 2 app): If the data is already in memory, just return it, otherwise do a HTTP GET. It sounds like it should be simple. Is there any easier way than the following? [LOGIC] If the data ...
3 votes
2 answers
93 views
How to prevent requests duplication?
I got one controller CounterpartyCtrl that is used by two views. The first view contains a selector which requires all the records from collection. So I fetch all the objects and put them into $scope....