cross-tab-worker-databus 0.1.0 → 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.
- package/CHANGELOG.md +23 -0
- package/dist/centrifuge-session.d.ts +3 -1
- package/dist/centrifuge-session.d.ts.map +1 -1
- package/dist/centrifuge.js +13 -4
- package/dist/centrifuge.js.map +2 -2
- package/dist/centrifuge.shared.worker.js +31 -8
- package/dist/centrifuge.shared.worker.js.map +2 -2
- package/dist/centrifuge.worker.js +12 -3
- package/dist/centrifuge.worker.js.map +2 -2
- package/dist/{chunk-GABYBK7I.js → chunk-53INHVYO.js} +25 -5
- package/dist/chunk-53INHVYO.js.map +7 -0
- package/dist/core/cluster.d.ts.map +1 -1
- package/dist/core/storage-batch.d.ts +2 -0
- package/dist/core/storage-batch.d.ts.map +1 -1
- package/dist/core/trace.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/workers/port-reaper.d.ts +5 -2
- package/dist/workers/port-reaper.d.ts.map +1 -1
- package/docs/architecture.md +2 -0
- package/docs/configuration.md +2 -0
- package/docs/zh/architecture.md +2 -0
- package/docs/zh/configuration.md +2 -0
- package/package.json +1 -1
- package/dist/chunk-GABYBK7I.js.map +0 -7
|
@@ -5010,7 +5010,11 @@ var CentrifugeSession = class {
|
|
|
5010
5010
|
client.on("connected", () => this.post({ type: "STATUS", status: "connected" }));
|
|
5011
5011
|
client.on("disconnected", () => this.post({ type: "STATUS", status: "disconnected" }));
|
|
5012
5012
|
client.on("error", (context) => this.postError(context));
|
|
5013
|
-
client.on("publication", (context) =>
|
|
5013
|
+
client.on("publication", (context) => {
|
|
5014
|
+
const topic = context.channel || getPayloadTopic(context.data);
|
|
5015
|
+
if (!topic || this.subscriptions.has(topic)) return;
|
|
5016
|
+
this.postPublication(topic, context.data);
|
|
5017
|
+
});
|
|
5014
5018
|
client.connect();
|
|
5015
5019
|
}
|
|
5016
5020
|
/** Subscribe to a Centrifuge channel. Reuses an existing subscription if one exists. */
|
|
@@ -5029,12 +5033,17 @@ var CentrifugeSession = class {
|
|
|
5029
5033
|
subscription.on("unsubscribed", () => this.subscriptions.delete(topic));
|
|
5030
5034
|
subscription.subscribe();
|
|
5031
5035
|
}
|
|
5032
|
-
/** 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. */
|
|
5033
5039
|
unsubscribe(topic) {
|
|
5034
5040
|
const subscription = this.subscriptions.get(topic) ?? this.client?.getSubscription(topic);
|
|
5035
5041
|
if (!subscription) return;
|
|
5036
|
-
subscription.
|
|
5042
|
+
subscription.removeAllListeners("publication");
|
|
5043
|
+
subscription.removeAllListeners("error");
|
|
5044
|
+
subscription.removeAllListeners("unsubscribed");
|
|
5037
5045
|
this.subscriptions.delete(topic);
|
|
5046
|
+
subscription.unsubscribe();
|
|
5038
5047
|
}
|
|
5039
5048
|
/** Publish a message to the Centrifuge channel. */
|
|
5040
5049
|
publish(topic, data) {
|