@cstar.help/js 0.6.0 → 0.6.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.
- package/dist/index.cjs +8 -4
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -292,7 +292,7 @@ var CStarRealtime = class {
|
|
|
292
292
|
this.maxRetries = options?.maxRetries ?? 10;
|
|
293
293
|
this.types = options?.types;
|
|
294
294
|
}
|
|
295
|
-
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). */
|
|
295
|
+
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). Returns an unsubscribe function. */
|
|
296
296
|
on(eventType, handler) {
|
|
297
297
|
let set = this.handlers.get(eventType);
|
|
298
298
|
if (!set) {
|
|
@@ -301,13 +301,17 @@ var CStarRealtime = class {
|
|
|
301
301
|
}
|
|
302
302
|
set.add(handler);
|
|
303
303
|
this.ensureConnected();
|
|
304
|
-
return
|
|
304
|
+
return () => {
|
|
305
|
+
set.delete(handler);
|
|
306
|
+
};
|
|
305
307
|
}
|
|
306
|
-
/** Subscribe to all events. */
|
|
308
|
+
/** Subscribe to all events. Returns an unsubscribe function. */
|
|
307
309
|
onAny(handler) {
|
|
308
310
|
this.anyHandlers.add(handler);
|
|
309
311
|
this.ensureConnected();
|
|
310
|
-
return
|
|
312
|
+
return () => {
|
|
313
|
+
this.anyHandlers.delete(handler);
|
|
314
|
+
};
|
|
311
315
|
}
|
|
312
316
|
/** Handle connection errors. */
|
|
313
317
|
onError(handler) {
|
package/dist/index.d.cts
CHANGED
|
@@ -94,10 +94,10 @@ declare class CStarRealtime {
|
|
|
94
94
|
private readonly maxRetries;
|
|
95
95
|
private readonly types;
|
|
96
96
|
constructor(httpClient: HttpClient, options?: RealtimeOptions);
|
|
97
|
-
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). */
|
|
98
|
-
on<T = unknown>(eventType: string, handler: EventHandler<T>):
|
|
99
|
-
/** Subscribe to all events. */
|
|
100
|
-
onAny<T = unknown>(handler: EventHandler<T>):
|
|
97
|
+
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). Returns an unsubscribe function. */
|
|
98
|
+
on<T = unknown>(eventType: string, handler: EventHandler<T>): () => void;
|
|
99
|
+
/** Subscribe to all events. Returns an unsubscribe function. */
|
|
100
|
+
onAny<T = unknown>(handler: EventHandler<T>): () => void;
|
|
101
101
|
/** Handle connection errors. */
|
|
102
102
|
onError(handler: ErrorHandler): this;
|
|
103
103
|
/** Handle connection state changes. */
|
package/dist/index.d.ts
CHANGED
|
@@ -94,10 +94,10 @@ declare class CStarRealtime {
|
|
|
94
94
|
private readonly maxRetries;
|
|
95
95
|
private readonly types;
|
|
96
96
|
constructor(httpClient: HttpClient, options?: RealtimeOptions);
|
|
97
|
-
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). */
|
|
98
|
-
on<T = unknown>(eventType: string, handler: EventHandler<T>):
|
|
99
|
-
/** Subscribe to all events. */
|
|
100
|
-
onAny<T = unknown>(handler: EventHandler<T>):
|
|
97
|
+
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). Returns an unsubscribe function. */
|
|
98
|
+
on<T = unknown>(eventType: string, handler: EventHandler<T>): () => void;
|
|
99
|
+
/** Subscribe to all events. Returns an unsubscribe function. */
|
|
100
|
+
onAny<T = unknown>(handler: EventHandler<T>): () => void;
|
|
101
101
|
/** Handle connection errors. */
|
|
102
102
|
onError(handler: ErrorHandler): this;
|
|
103
103
|
/** Handle connection state changes. */
|
package/dist/index.js
CHANGED
|
@@ -254,7 +254,7 @@ var CStarRealtime = class {
|
|
|
254
254
|
this.maxRetries = options?.maxRetries ?? 10;
|
|
255
255
|
this.types = options?.types;
|
|
256
256
|
}
|
|
257
|
-
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). */
|
|
257
|
+
/** Subscribe to a specific event type. Supports wildcards (e.g., 'ticket.*'). Returns an unsubscribe function. */
|
|
258
258
|
on(eventType, handler) {
|
|
259
259
|
let set = this.handlers.get(eventType);
|
|
260
260
|
if (!set) {
|
|
@@ -263,13 +263,17 @@ var CStarRealtime = class {
|
|
|
263
263
|
}
|
|
264
264
|
set.add(handler);
|
|
265
265
|
this.ensureConnected();
|
|
266
|
-
return
|
|
266
|
+
return () => {
|
|
267
|
+
set.delete(handler);
|
|
268
|
+
};
|
|
267
269
|
}
|
|
268
|
-
/** Subscribe to all events. */
|
|
270
|
+
/** Subscribe to all events. Returns an unsubscribe function. */
|
|
269
271
|
onAny(handler) {
|
|
270
272
|
this.anyHandlers.add(handler);
|
|
271
273
|
this.ensureConnected();
|
|
272
|
-
return
|
|
274
|
+
return () => {
|
|
275
|
+
this.anyHandlers.delete(handler);
|
|
276
|
+
};
|
|
273
277
|
}
|
|
274
278
|
/** Handle connection errors. */
|
|
275
279
|
onError(handler) {
|