Search code examples
angularspring-bootspring-repositories

I want to access a data continuoulsy. Means on each change the API should give me updated data


For now, I am working on like button. So, database is storing person who liked. Upon liking it will try to add user's email to db and return updated liker(for unlike it will remove from db). so, I can print in angular using array.length to see how many person liked

But, now what I want is when another person like it. In my browser I also get updated like counter. For that what I can do is request the spring boot API in each second. But, that is not recommended I think. What can I do so I will get liker list from spring boot to angular continuously?


Solution

  • Socket.io might be what you're looking for. It's a real time library that performs the trick through a web socket. You can trigger events from server-side and make you client listen to them with a callback, and update your view consequently.

    https://socket.io/