How to fetch and display real-time user notifications in angular?

1.8k Views Asked by At

I am working with django-notification and I am trying to fetch and display the notifications on my angular app. So how should I fetch the data from the backend to make it real-time? Should I periodically fetch data using something like setTimeout? or is there a better way to do this in angular?

2

There are 2 best solutions below

0
Aditya Vashishtha On BEST ANSWER

you should have two departments ready to achieve this :-

  1. you should have web socket server api implemeted which will send the notification to the subscriber in application.
  2. you can use WebSocketSubject rxjs special kind of subject which will let you consume the web socket API,you can read more about this subject to following link.

    https://rxjs-dev.firebaseapp.com/api/webSocket/WebSocketSubject

2
Abdalhadi Obaid On

I would like to suggest to read about firebase or nodejs socket, Bellow link could help https://firebase.google.com/docs/database/web/read-and-write