I have this code that grabs a cached value:
getConfigurations(): Observable<SiteConfiguration[]> {
return this.storageService.getSiteConfigurations().map(c => {
if(c) {
return c;
}
return this.httpClient.get<SiteConfiguration[]>(this.url + "/config").subscribe(c => c);
});
}
I cache the SiteConfiguration object, but need to go to the server to get it if it doesn't exist. But I can't return the second observable inside the first, as it would be returning an Observable<Observable<SiteConfiguration[]>>.
I'm sure this is a common scenario but my google-fu failed to find an answer.
.flatMap, or one of its siblings (concat, switch, ...)?