I built a notification feature that will trigger after a particular event and add a new notification to an API endpoint. The way that I am reading the notification is by sending a get request to the API endpoint every 3 seconds and re-assigning the unread notifications number. This number then gets rendered in the UI.
What are the downsides of doing this? Is there a better way to do this without constantly hitting the API?
this.subscription = Observable.interval(3000).subscribe(() => {
//get request to notification endpoint
}