J
J
jajoy2020-07-24 11:35:01
Angular
jajoy, 2020-07-24 11:35:01

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();
    }
}


How can this be done with socket.io? Tried to follow this example but didn't work.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question