A
A
Adel Khalitov2020-08-04 19:59:47
Socket.io
Adel Khalitov, 2020-08-04 19:59:47

How to wait for a subscription to a websocket event?

There is a constructor

const socket = io();
socket.on('some event', cb);
getDataToSomeEvent();


What happens is that getDataToSomeEvent makes a request to the server, some events occur there, and then emit('some event'..., but some of the data comes before the subscription is made socket.on('some event', cb )

How can one achieve serial execution of the getDataToSomeEvent request, after 100% sure subscription to the "some event" event?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Shumov, 2020-08-04
@adelkhalitov

No way. This is an event model of interaction. It has no concept of order.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question