Parellelize code

This commit is contained in:
RMidhunSuresh 2022-06-12 17:05:31 +05:30
parent b5fd3656a7
commit 53a8915ffc
1 changed files with 4 additions and 10 deletions

View File

@ -58,16 +58,10 @@ export class ThemeLoader {
async init(manifestLocations: string[], log?: ILogItem): Promise<void> {
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));
});
}