Detect “Back to Online” Status in Angular

Nil Seri
2 min readApr 29, 2022

Detect When the Browser is Back Online and Multicast Events

Photo by Samantha Borges on Unsplash

In my previous posts, I had mentioned about SSE implementation to send/receive user events in an e-mail service.

Now, the requirement is that when the user goes offline (away from her/his desk), she/he does not get notified of new e-mail, calendar invites unless she/he refreshes the page or a new event is received. “event-source-polyfill” retries connection and gets connected as soon as the user gets online. Technically, there is no problem. The user gets events when she/he is connected to SSE. The events are not delivered if it is disconnected.

For a smooth user experience, we can add ‘online’ event listener so that when the user is online again, we can act like an event is received and multicasted to its observers via “Subject”.

This only triggers when you are back to online status from offline. So, there will not be any unwanted triggers.

You can read more about it here:

Happy Coding!

--

--

Nil Seri

I would love to change the world, but they won’t give me the source code | coding 👩🏻‍💻 | coffee ☕️ | jazz 🎷 | anime 🐲 | books 📚 | drawing 🎨