reverb-ws-client 1.0.4 → 1.0.5

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/dist/index.d.mts CHANGED
@@ -34,6 +34,7 @@ declare class Channel {
34
34
  subscribe(): Promise<void>;
35
35
  listen(event: string, callback: EventCallback): this;
36
36
  stopListening(event: string, callback?: EventCallback): this;
37
+ unsubscribe(): void;
37
38
  handleEvent(event: string, data: unknown): void;
38
39
  getName(): string;
39
40
  }
package/dist/index.d.ts CHANGED
@@ -34,6 +34,7 @@ declare class Channel {
34
34
  subscribe(): Promise<void>;
35
35
  listen(event: string, callback: EventCallback): this;
36
36
  stopListening(event: string, callback?: EventCallback): this;
37
+ unsubscribe(): void;
37
38
  handleEvent(event: string, data: unknown): void;
38
39
  getName(): string;
39
40
  }
package/dist/index.js CHANGED
@@ -102,6 +102,16 @@ var Channel = class {
102
102
  }
103
103
  return this;
104
104
  }
105
+ unsubscribe() {
106
+ this.client.send({
107
+ event: "pusher:unsubscribe",
108
+ data: {
109
+ channel: this.name
110
+ }
111
+ });
112
+ this.listeners.clear();
113
+ this.subscribed = false;
114
+ }
105
115
  handleEvent(event, data) {
106
116
  const callbacks = this.listeners.get(event);
107
117
  if (!callbacks) return;
package/dist/index.mjs CHANGED
@@ -76,6 +76,16 @@ var Channel = class {
76
76
  }
77
77
  return this;
78
78
  }
79
+ unsubscribe() {
80
+ this.client.send({
81
+ event: "pusher:unsubscribe",
82
+ data: {
83
+ channel: this.name
84
+ }
85
+ });
86
+ this.listeners.clear();
87
+ this.subscribed = false;
88
+ }
79
89
  handleEvent(event, data) {
80
90
  const callbacks = this.listeners.get(event);
81
91
  if (!callbacks) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reverb-ws-client",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A lightweight Laravel Reverb client for React Native using the Pusher protocol.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",