Is there a way to reset an Observable object? I'm not sure if "reinitialize" is the right term, but essentially what I want is to update the data without creating a new Observable object or new subscriptions.
- I want existing subscriptions to seamlessly continue working
@Injectable({
providedIn: 'root',
})
export class MyService {
private url = 'http://mydummydomain.com/api/entries';
private data$: Observable<any>;
constructor(private http: HttpClient) {
this.data$ = this.http.get(this.url).pipe(
shareReplay(1)
);
}
getData(): Observable<any> {
return this.data$;
}
reloadData() {
// TODO:
// Refresh data from the url
// This should be a function without any input parameters or return value
}
}
Appreciate any help on this matter.