-
Notifications
You must be signed in to change notification settings - Fork 848
Use navigator.onLine for modern browser #135
Comments
These properties work well when determining if the client has an active internet connection, but are not so good for determining if the user can actually talk to your server. For example, if the user has an active network connection but our servers are offline for some reason, we would want the client-side application to behave as if it's offline. This can only really be accomplished by poking the server to see if you can successfully communicate with it. |
Yeah, you are totally right. Sorry. I misused "Offline" to check if the client is offline. 😀 |
While this only checks one aspect of the connection, adding it to the control flow would improve the UX. For example, if your strategy consists of simply disabling editing, listening for this event would preemptively prevent edit attempts. You could also improve the accuracy of the status indicator, alerting the user to a local connection issue and reducing the number of pointless "connecting" attempts. |
Your event handler should probably include a time delay, rechecking |
It appears as if the code already uses this (but using event handlers instead of check in the global variable), but the implementation is problematic I now disagree with preventing reconnection attempts based on the status of the global, there are probably edge cases where the offline event would not be reliable. |
At any rate, please close this ticket. |
Hello,
I really like the "Offline" library but it would be great if it would make use of the
navigator.onLine
property for modern browser, because there is no need for them to do XML HTTP Requests all the time.The
navigator.onLine
property works good in all modern browsers except Firefox, so it's definetly worth to be checked (compatibility). There are also callbacks forwindow.ononline
andwindow.onoffline
. 😃The text was updated successfully, but these errors were encountered: