From 53a8915ffcba3a9be5d08c6c0149b0163725589e Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Sun, 12 Jun 2022 17:05:31 +0530 Subject: [PATCH] Parellelize code --- src/platform/web/ThemeLoader.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/platform/web/ThemeLoader.ts b/src/platform/web/ThemeLoader.ts index 1e8e2ebc..6a73c565 100644 --- a/src/platform/web/ThemeLoader.ts +++ b/src/platform/web/ThemeLoader.ts @@ -58,16 +58,10 @@ export class ThemeLoader { async init(manifestLocations: string[], log?: ILogItem): Promise { await this._platform.logger.wrapOrRun(log, "ThemeLoader.init", async (log) => { this._themeMapping = {}; - for (const manifestLocation of manifestLocations) { - const { body } = await this._platform - .request(manifestLocation, { - method: "GET", - format: "json", - cache: true, - }) - .response(); - this._populateThemeMap(body, log); - } + const results = await Promise.all( + manifestLocations.map( location => this._platform.request(location, { method: "GET", format: "json", cache: true, }).response()) + ); + results.forEach(({ body }) => this._populateThemeMap(body, log)); }); }