@neurosity/sdk 7.0.0 → 7.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -31163,19 +31163,21 @@ var Neurosity = (function (exports) {
31163
31163
  : `metrics/${metric}/${labels[0]}`;
31164
31164
  offData(child, "value", listener);
31165
31165
  },
31166
- disconnect() {
31167
- remove(clientRef);
31166
+ async disconnect() {
31168
31167
  listenersToRemove.forEach((removeListener) => {
31169
31168
  removeListener();
31170
31169
  });
31171
- subscriptionManager
31172
- .toList()
31173
- .filter((subscription) => subscription.clientId === clientId)
31174
- .forEach((subscription) => {
31175
- const childPath = `subscriptions/${subscription.id}`;
31176
- const subscriptionRef = child(deviceRef, childPath);
31177
- remove(subscriptionRef);
31178
- });
31170
+ return await Promise.all([
31171
+ remove(clientRef),
31172
+ ...subscriptionManager
31173
+ .toList()
31174
+ .filter((subscription) => subscription.clientId === clientId)
31175
+ .map((subscription) => {
31176
+ const childPath = `subscriptions/${subscription.id}`;
31177
+ const subscriptionRef = child(deviceRef, childPath);
31178
+ return remove(subscriptionRef);
31179
+ })
31180
+ ]);
31179
31181
  }
31180
31182
  };
31181
31183
  };
@@ -31258,8 +31260,8 @@ var Neurosity = (function (exports) {
31258
31260
  }
31259
31261
  return token;
31260
31262
  }
31261
- disconnect() {
31262
- this.deviceStore.disconnect();
31263
+ async disconnect() {
31264
+ await this.deviceStore.disconnect();
31263
31265
  }
31264
31266
  }
31265
31267
  FirebaseDevice.serverType = "firebase";
@@ -31542,9 +31544,14 @@ var Neurosity = (function (exports) {
31542
31544
  this.firebaseUser.onUserClaimsChange().subscribe((userClaims) => {
31543
31545
  this.userClaims = userClaims;
31544
31546
  });
31545
- this.onDeviceChange().subscribe((device) => {
31547
+ this.onDeviceChange().subscribe(async (device) => {
31546
31548
  if (this.firebaseDevice) {
31547
- this.firebaseDevice.disconnect();
31549
+ try {
31550
+ await this.firebaseDevice.disconnect();
31551
+ }
31552
+ catch (error) {
31553
+ console.error("Error disconnecting from device", error);
31554
+ }
31548
31555
  }
31549
31556
  if (!device) {
31550
31557
  return;
@@ -31596,6 +31603,14 @@ var Neurosity = (function (exports) {
31596
31603
  return await this.firebaseDevice.dispatchAction(action);
31597
31604
  }
31598
31605
  async disconnect() {
31606
+ if (this.firebaseDevice) {
31607
+ try {
31608
+ await this.firebaseDevice.disconnect();
31609
+ }
31610
+ catch (error) {
31611
+ console.error("Error disconnecting from device", error);
31612
+ }
31613
+ }
31599
31614
  return this.firebaseApp.disconnect();
31600
31615
  }
31601
31616
  async getInfo() {
@@ -31618,7 +31633,12 @@ var Neurosity = (function (exports) {
31618
31633
  }
31619
31634
  async logout() {
31620
31635
  if (this.firebaseDevice) {
31621
- this.firebaseDevice.disconnect();
31636
+ try {
31637
+ await this.firebaseDevice.disconnect();
31638
+ }
31639
+ catch (error) {
31640
+ console.error("Error disconnecting from device", error);
31641
+ }
31622
31642
  }
31623
31643
  return await this.firebaseUser.logout();
31624
31644
  }