From 824145449a6cdbf42f6d164c5dae72f777254519 Mon Sep 17 00:00:00 2001 From: ICheered Date: Sat, 5 Aug 2023 14:56:24 +0200 Subject: [PATCH] Mode modulepromise outside Camera class --- src/camera.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/camera.js b/src/camera.js index 537ff3c..90500a7 100644 --- a/src/camera.js +++ b/src/camera.js @@ -34,6 +34,8 @@ export function rethrowIfCritical(err) { const INTERFACE_CLASS = 6; // PTP const INTERFACE_SUBCLASS = 1; // MTP +let ModulePromise = null; + /** * This class provides methods for interacting with the camera. */ @@ -43,7 +45,6 @@ class Camera { this.queue = Promise.resolve(); this.Module = null; this.context = null; - this.ModulePromise = null; } /** @@ -67,10 +68,10 @@ class Camera { * @returns {Promise} */ async connect() { - if (!this.ModulePromise) { - this.ModulePromise = initModule() + if (!ModulePromise) { + ModulePromise = initModule() } - this.Module = await this.ModulePromise; + this.Module = await ModulePromise; this.context = await new this.Module.Context(); }