Answer the question
In order to leave comments, you need to log in
How to listen to the backend from the client side?
Good evening!
There was a problem, in general, I did not find a sensible answer on these Internets.
And so straight to the point, for example, I want to write a notification system for the site, let's say the site has a cherished like button and two users (let's call user_1 and user_2). And so, user_2 liked the post user_1, id user_2 was saved in the database under the post user_1, then I need to somehow pull user_1 and show that he was like.
Considering how most sites work, is it possible in any way to send information to the client that he was liked without the client interacting with the backend? Or do I need to write a demon?
Then I don’t understand anything, thanks in advance for your help, I will be glad for your answers! :)
Answer the question
In order to leave comments, you need to log in
The easiest way is short polling - we regularly poll APIs for new data.
A little more complicated - Long polling - this is the same, but the timeout is longer (usually about 20s, the gold standard)
Let's complicate it further - websocket
Even more interesting - push notifications
On the server side, in any case, you need to generate some events or notifications and store them for each user so that the client can receive them. Both the table and queues (message broker) are suitable here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question