From the course: Angular: Progressive Web Apps

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Update UI on network status change

Update UI on network status change - Angular Tutorial

From the course: Angular: Progressive Web Apps

Update UI on network status change

- [Instructor] So now, we know that at any time, my PWA can go offline or we can directly open the PWA while offline. And it works at least the app Shell works so offline or online, we know that sometimes we can get into like a blind spot of connection and maybe the app started as online, but at one point it moved to an offline experience. So something that we can do is try to update the UI somehow to let the user know that we are offline or online. So we're going to update the UI on network status change. We can do that in any place, but I'm going to work with an app component that's the root component of my app. So at some point typically on ngOnInit, I want to know if the user is online or offline. And for that we are going to use an API available on the browsers and we will create a function for that, a method for that update network status UI. That will actually check if navigator.onLine. Be careful Capital L there…

Contents