From e7774b8708a3cc1fb8e7d9aacfd867c696a7dd28 Mon Sep 17 00:00:00 2001 From: jparez Date: Tue, 10 Sep 2024 13:22:19 +0200 Subject: [PATCH] replace way of check if plugin charged --- src/DeviceRendererFactory.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/DeviceRendererFactory.js b/src/DeviceRendererFactory.js index b092014..8f31674 100644 --- a/src/DeviceRendererFactory.js +++ b/src/DeviceRendererFactory.js @@ -151,7 +151,7 @@ module.exports = class DeviceRendererFactory { this.instances.push(instance); - this.addPlugins(instance); + this.loadPlugins(instance); instance.onWebRTCReady(); return instance.apiManager.getExposedApiFunctions(); @@ -195,7 +195,7 @@ module.exports = class DeviceRendererFactory { * @param {DeviceRenderer} instance The DeviceRenderer instance reference to link into each plugin. * @param {Object} options Various configuration options. */ - addPlugins(instance) { + loadPlugins(instance) { /* * Load instance dedicated plugins */ @@ -209,7 +209,7 @@ module.exports = class DeviceRendererFactory { } } - const dependenciesLoaded = []; + const dependenciesLoaded = new Map(); pluginInitMap.forEach((plugin) => { const args = plugin.params || []; @@ -217,11 +217,12 @@ module.exports = class DeviceRendererFactory { // load dependencies if (plugin.dependencies) { plugin.dependencies.forEach((Dep) => { - if (dependenciesLoaded.indexOf(Dep.name) !== -1) { + if (dependenciesLoaded.has(Dep)) { return; } + new Dep(instance); - dependenciesLoaded.push(Dep.name); + dependenciesLoaded.set(Dep, true); }); } // eslint-disable-next-line no-unused-expressions