File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ import {
100
100
isValidSubject ,
101
101
isValidSubjectWithoutWildcards ,
102
102
} from "@cocalc/nats/util" ;
103
+ import { reuseInFlight } from "@cocalc/util/reuse-in-flight" ;
104
+ import { once } from "@cocalc/util/async-utils" ;
103
105
104
106
export function connect ( address = "http://localhost:3000" , options ?) {
105
107
return new Client ( address , options ) ;
@@ -150,11 +152,19 @@ export class Client {
150
152
} ) ;
151
153
}
152
154
155
+ waitUntilConnected = reuseInFlight ( async ( ) => {
156
+ if ( this . conn . connected ) {
157
+ return ;
158
+ }
159
+ // @ts -ignore
160
+ await once ( this . conn , "connect" ) ;
161
+ } ) ;
162
+
153
163
// syncSubscriptions ensures that we're subscribed on server
154
164
// to what we think we're subscribed to.
155
165
private syncSubscriptions = async ( ) => {
156
166
const subs = await this . getSubscriptions ( ) ;
157
- console . log ( { subs} )
167
+ console . log ( { subs } ) ;
158
168
for ( const subject in this . queueGroups ) {
159
169
// subscribe on backend to all subscriptions we think we should have that
160
170
// the server does not have
You can’t perform that action at this time.
0 commit comments