Browse Source

Get async methods to get the this context

master
Adwaith Rao 6 years ago
parent
commit
c3bed09bde
2 changed files with 6 additions and 3 deletions
  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 View File

@@ -17,7 +17,7 @@ export class MallService {
this.fetchMalls(); 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 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))); const outlets = await Promise.all(mall.outlets.map(outlet_id => this.outletService.getOutletByID(outlet_id)));




+ 5
- 2
src/app/services/outlet.service.ts View File

@@ -17,8 +17,10 @@ export class OutletService {
this.fetchOutlets(); 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))); const menu_items = await Promise.all(outlet.menu_items.map(menu_item_id => this.menuItemService.getMenuItemByID(menu_item_id)));


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


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

Loading…
Cancel
Save