cross-tab-worker-databus 0.1.1 → 0.1.2

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.
@@ -5033,12 +5033,17 @@ var CentrifugeSession = class {
5033
5033
  subscription.on("unsubscribed", () => this.subscriptions.delete(topic));
5034
5034
  subscription.subscribe();
5035
5035
  }
5036
- /** Unsubscribe from a Centrifuge channel and clean up the local reference. */
5036
+ /** Unsubscribe from a Centrifuge channel and clean up the local reference.
5037
+ * Listeners are removed before unsubscribing so a late `unsubscribed` event
5038
+ * cannot delete a subscription that a subsequent `subscribe()` re-added. */
5037
5039
  unsubscribe(topic) {
5038
5040
  const subscription = this.subscriptions.get(topic) ?? this.client?.getSubscription(topic);
5039
5041
  if (!subscription) return;
5040
- subscription.unsubscribe();
5042
+ subscription.removeAllListeners("publication");
5043
+ subscription.removeAllListeners("error");
5044
+ subscription.removeAllListeners("unsubscribed");
5041
5045
  this.subscriptions.delete(topic);
5046
+ subscription.unsubscribe();
5042
5047
  }
5043
5048
  /** Publish a message to the Centrifuge channel. */
5044
5049
  publish(topic, data) {