mirror of
https://github.com/vector-im/element-web.git
synced 2026-04-20 21:12:18 +02:00
Iterate
This commit is contained in:
parent
3a5baec699
commit
2edfce5e7a
@ -24,11 +24,13 @@ export class ModuleIncompatibleError extends Error {
|
||||
* @public
|
||||
*/
|
||||
export class ModuleLoader {
|
||||
private modules: Module[] = [];
|
||||
private started = false;
|
||||
|
||||
public constructor(private api: Api) {}
|
||||
|
||||
#modules: Module[] = [];
|
||||
public async load(moduleExport: ModuleExport): Promise<void> {
|
||||
if (this.#started) {
|
||||
if (this.started) {
|
||||
throw new Error("PluginEngine.start() has already been called");
|
||||
}
|
||||
|
||||
@ -39,16 +41,15 @@ export class ModuleLoader {
|
||||
throw new ModuleIncompatibleError(moduleExport.default.moduleApiVersion);
|
||||
}
|
||||
const { default: Module } = moduleExport;
|
||||
this.#modules.push(new Module(this.api));
|
||||
this.modules.push(new Module(this.api));
|
||||
}
|
||||
|
||||
#started = false;
|
||||
public async start(): Promise<void> {
|
||||
if (this.#started) {
|
||||
if (this.started) {
|
||||
throw new Error("PluginEngine.start() has already been called");
|
||||
}
|
||||
this.#started = true;
|
||||
this.started = true;
|
||||
|
||||
await Promise.all(this.#modules.map((plugin) => plugin.load()));
|
||||
await Promise.all(this.modules.map((plugin) => plugin.load()));
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user