Przeglądaj źródła

Get async methods to get the this context

master
Adwaith Rao 6 lat temu
rodzic
commit
c3bed09bde
2 zmienionych plików z 6 dodań i 3 usunięć
  1. +1
    -1
      src/app/services/mall.service.ts
  2. +5
    -2
      src/app/services/outlet.service.ts

+ 1
- 1
src/app/services/mall.service.ts Wyświetl plik

@@ -17,7 +17,7 @@ export class MallService {
this.fetchMalls();
}

private async getDenormalizedMall(mall: Mall) {
private getDenormalizedMall = async (mall: Mall) => {
const offers = await Promise.all(mall.offers.map(offer_id => this.offerService.getOfferByID(offer_id)));
const outlets = await Promise.all(mall.outlets.map(outlet_id => this.outletService.getOutletByID(outlet_id)));



+ 5
- 2
src/app/services/outlet.service.ts Wyświetl plik

@@ -17,8 +17,10 @@ export class OutletService {
this.fetchOutlets();
}

private async getDenormalizedOutlet(outlet: Outlet) {
const offers = await Promise.all(outlet.offers.map(offer_id => this.offerService.getOfferByID(offer_id)));
private getDenormalizedOutlet = async (outlet: Outlet) => {
const offers = await Promise.all(outlet.offers.map(offer_id => {
return this.offerService.getOfferByID(offer_id);
}));
const menu_items = await Promise.all(outlet.menu_items.map(menu_item_id => this.menuItemService.getMenuItemByID(menu_item_id)));

return {
@@ -33,6 +35,7 @@ export class OutletService {
}

public async getOutletByID(id: string) {
await this.fetchOutlets();
return this.outlets.find((outlet) => outlet.id === id);
}
}

Ładowanie…
Anuluj
Zapisz