Change socketio config dynamically

360 Views Asked by At

I am using ngx-socket-io for realtime notifications in angular app

My current requirement is to enable notifications or socketio requests to server only if enabled in settings DB

I was thinking to make this change by changing the socketio module config during runtime, i.e. when I get the settings from API call.

My current code in app.module:

if(environment.angularEnv == "local") {
  config = { url: 'http://localhost:8001', options: {} };
} else {
  config = { url: location.origin, options: {} };
}
imports: [
    BrowserModule,
    SocketIoModule.forRoot(config),
0

There are 0 best solutions below