@telestack/db-sdk 1.0.9 → 1.1.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.js +18 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -525,9 +525,26 @@ export class Query {
|
|
|
525
525
|
let sub = centrifuge.getSubscription(channel);
|
|
526
526
|
if (!sub) {
|
|
527
527
|
sub = centrifuge.newSubscription(channel);
|
|
528
|
+
}
|
|
529
|
+
if (sub.state !== 'subscribed') {
|
|
528
530
|
sub.subscribe();
|
|
531
|
+
// Wait for subscription to be ready
|
|
532
|
+
await new Promise((resolve) => {
|
|
533
|
+
const onSubscribed = () => {
|
|
534
|
+
sub?.off('subscribed', onSubscribed);
|
|
535
|
+
resolve();
|
|
536
|
+
};
|
|
537
|
+
sub?.on('subscribed', onSubscribed);
|
|
538
|
+
// timeout after 2s to prevent hanging
|
|
539
|
+
setTimeout(resolve, 2000);
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
try {
|
|
543
|
+
await sub.publish({ type: 'SIGNAL', data, userId: this.client.config.userId });
|
|
544
|
+
}
|
|
545
|
+
catch (e) {
|
|
546
|
+
console.warn("Telestack: Signal failed", e);
|
|
529
547
|
}
|
|
530
|
-
await sub.publish({ type: 'SIGNAL', data, userId: this.client.config.userId });
|
|
531
548
|
}
|
|
532
549
|
/** Listen for transient signals on this collection */
|
|
533
550
|
onSignal(callback) {
|