I created a service SocketService, basically it initializes the socket to let the app listen on the port. This service also interacts with some components.
/
Move the logic in your SocketService constructor to a method instead and then call that in your main component's constructor or ngOnInit
SocketService
export class SocketService{
init(){
// Startup logic here
}
}
App
import {SocketService} from './socket.service';
...
class App {
constructor (private _socketService: SocketService) {
_socketService.init();
}
}
bootstrap(App, [SocketService]);