I think this taxonomy of future-related functions might be helpful in clearing up what is going on. What I would do here is something along these lines:
export interface Store {
description: string;
name: string;
}
export interface StoreMap {
[id: string]: Store;
}
interface WireStore extends Store {
id: string[];
}
interface WireStores {
stores: WireStore[];
}
interface WireStoreResponse {
data: WireStores;
message: string;
status: string;
}
stores(): Observable<StoreMap> {
return this._http.get<WireStoreResponse>(this.url).pipe(
map(wsr => {
let rv: StoreMap = {};
wsr.data.stores.forEach(ws => {
rv[ws.id[0]] = {description: ws.description, name: ws.name};
});
return rv;
}));
}
The subscription happens outside the provider, and in there everything about the StoreMap should be as you expect.