@stemy/ngx-utils 19.4.2 → 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
- Object.keys(this.channels).map(event => {
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
- this.channels[event].next(data);
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[event]) {
2374
- this.channels[event] = new Subject();
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[event].next(data);
2380
+ this.channels.get(event).next(data);
2379
2381
  });
2380
2382
  });
2381
2383
  }
2382
- return this.channels[event].subscribe(cb);
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));
@@ -3177,8 +3179,10 @@ class ApiService extends BaseHttpService {
3177
3179
  return "api";
3178
3180
  }
3179
3181
  url(url) {
3180
- const baseUrl = this.expressRequestUrl(`/api/${url}`);
3181
- if (url == "api-docs" || url == "socket") {
3182
+ const config = this.configs.config;
3183
+ const baseUrl = this.expressRequestUrl(`${config.apiUrl}${url}`);
3184
+ const socket = this.injector.get(SOCKET_IO_PATH);
3185
+ if (url == "api-docs" || url == socket) {
3182
3186
  return baseUrl.replace("/api/", "/");
3183
3187
  }
3184
3188
  return baseUrl;
@@ -7555,7 +7559,7 @@ class NgxUtilsModule {
7555
7559
  },
7556
7560
  {
7557
7561
  provide: SOCKET_IO_PATH,
7558
- useValue: (!config ? null : config.socketPath) ?? "/socket",
7562
+ useValue: (!config ? null : config.socketPath) ?? "socket.io",
7559
7563
  },
7560
7564
  {
7561
7565
  provide: APP_INITIALIZER,