@stemy/ngx-utils 19.4.3 → 19.4.4
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.
|
@@ -2353,12 +2353,13 @@ class SocketClient {
|
|
|
2353
2353
|
this.open = false;
|
|
2354
2354
|
this.status.next(false);
|
|
2355
2355
|
});
|
|
2356
|
-
|
|
2356
|
+
for (const [event, subject] of this.channels.entries()) {
|
|
2357
|
+
ws.off(event);
|
|
2357
2358
|
ws.on(event, (data) => {
|
|
2358
2359
|
this.handleResponse(event, data);
|
|
2359
|
-
|
|
2360
|
+
subject.next(data);
|
|
2360
2361
|
});
|
|
2361
|
-
}
|
|
2362
|
+
}
|
|
2362
2363
|
resolve(ws);
|
|
2363
2364
|
}, reject);
|
|
2364
2365
|
});
|
|
@@ -2370,16 +2371,17 @@ class SocketClient {
|
|
|
2370
2371
|
this.ws = null;
|
|
2371
2372
|
}
|
|
2372
2373
|
subscribe(event, cb) {
|
|
2373
|
-
if (!this.channels
|
|
2374
|
-
this.channels
|
|
2374
|
+
if (!this.channels.has(event)) {
|
|
2375
|
+
this.channels.set(event, new Subject());
|
|
2375
2376
|
this.ws?.then(ws => {
|
|
2377
|
+
ws.off(event);
|
|
2376
2378
|
ws.on(event, (data) => {
|
|
2377
2379
|
this.handleResponse(event, data);
|
|
2378
|
-
this.channels
|
|
2380
|
+
this.channels.get(event).next(data);
|
|
2379
2381
|
});
|
|
2380
2382
|
});
|
|
2381
2383
|
}
|
|
2382
|
-
return this.channels
|
|
2384
|
+
return this.channels.get(event).subscribe(cb);
|
|
2383
2385
|
}
|
|
2384
2386
|
emit(event, content) {
|
|
2385
2387
|
this.ws.then(ws => ws.emit(event, content));
|