I am caching HTTP results in an Angular application. From what I know, both of the following codes work, but I need to know if they do exactly the same thing, or am I missing something important?
publishLast
getPosts() {
if( !this.posts$ ) {
this.posts$ = this.http.get('api').publishLast().refCount();
return this.posts$;
}
return this.posts$;
}
publishReplay
getPosts() {
if( !this.posts$ ) {
this.posts$ = this.http.get('api').publishReplay(1).refCount();
return this.posts$;
}
return this.posts$;
}
source
share