Parellelize code

This commit is contained in:
RMidhunSuresh 2022-06-12 17:05:31 +05:30
parent b5fd3656a7
commit 53a8915ffc

View file

@ -58,16 +58,10 @@ export class ThemeLoader {
async init(manifestLocations: string[], log?: ILogItem): Promise<void> { async init(manifestLocations: string[], log?: ILogItem): Promise<void> {
await this._platform.logger.wrapOrRun(log, "ThemeLoader.init", async (log) => { await this._platform.logger.wrapOrRun(log, "ThemeLoader.init", async (log) => {
this._themeMapping = {}; this._themeMapping = {};
for (const manifestLocation of manifestLocations) { const results = await Promise.all(
const { body } = await this._platform manifestLocations.map( location => this._platform.request(location, { method: "GET", format: "json", cache: true, }).response())
.request(manifestLocation, { );
method: "GET", results.forEach(({ body }) => this._populateThemeMap(body, log));
format: "json",
cache: true,
})
.response();
this._populateThemeMap(body, log);
}
}); });
} }