Answer the question
In order to leave comments, you need to log in
How to use socket.io only to receive data?
I'm using Angular 8 and Node.js and I need to get the data displayed on the client in real time. But at the same time, I will not send any data from the client to the server, i.e. i am using get request.
At the moment, to achieve this, I did this:
interval;
ngOnInit() {
this.interval = setInterval(() => {
this.load();
}, 1000);
}
ngOnDestroy() {
clearInterval(this.interval);
if (this.ngUnsubscribe !== undefined) {
this.ngUnsubscribe.unsubscribe();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question