Will overwriting my observable variable kill current subscribers?
问题 I want to be able to cache an http call, but also force the cache to refresh. My service looks like this: @Injectable() export class UserService { private currentUser$: Observable<User>; constructor(private http: HttpClient) { } getCurrentUser(force = false): Observable<User> { if (!this.currentUser$ || force) { this.currentUser$ = this.http.get<User>(`${environment.API_URL}/profiles/me`) .pipe( shareReplay(CACHE_SIZE) ); } return this.currentUser$; } } If I call getCurrentUser(true) , the