mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-06-24 05:35:10 +00:00
Close SSE connection nicely on navigating away from the page
This commit is contained in:
@@ -4,6 +4,14 @@ let restartSSEOnErrorTimeoutId;
|
||||
// Table row count, to alternate shading
|
||||
let rowCount = 0;
|
||||
|
||||
// Set up a listener to close the SSE connection nicely when we navigate away from the page, to prevent console errors
|
||||
// and keep things nice and tidy for the server.
|
||||
window.addEventListener('beforeunload', function() {
|
||||
if (evtSource != null) {
|
||||
evtSource.close();
|
||||
}
|
||||
});
|
||||
|
||||
// Load spots and populate the table.
|
||||
function loadSpots() {
|
||||
// If we have an ongoing SSE connection, stop it so it doesn't interfere with our reload
|
||||
|
||||
Reference in New Issue
Block a user