I
I
Igor Rakov2021-02-11 12:21:26
Angular
Igor Rakov, 2021-02-11 12:21:26

How to do "reactive" update of Angular/Socket user list?

Example, comrades. A question. I am making a component that displays current users on the site. I store the list of users in sockets (the user connects and then is added to an array). On the client (angular) I display the list through the usual socket.on (on the server I pass the array through socket.emit). When a user connects, the first user does not show that the second one has joined, while the second one shows that both the first and himself have joined. Etc. If someone exits, then nothing will be displayed in the list. The dissconnect socket event is there and the user is removed from the array when they leave. How to make it so that on the client this list is updated in real time and reacts to changes? Might need to use something from Rxjs, but I don't know. I hope I explained clearly. I would be very grateful for help

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