Skip to content

Commit fce8540

Browse files
committed
Changes to reload app when service worker changes
1 parent d842fb2 commit fce8540

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

.jshintrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"logDebug",
99
"navigator",
1010
"self",
11-
"toolbox"
11+
"toolbox",
12+
"window"
1213
],
14+
"esnext": true,
1315
"node": true
1416
}

lib/delete-old-caches.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ self.addEventListener('activate', function(event) {
1212
return caches.delete(cacheName);
1313
})
1414
);
15-
})
15+
}).then(() => self.clients.claim())
1616
);
1717
});

lib/registration.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ if ('serviceWorker' in navigator) {
33
.catch(function(error) {
44
console.error('Error registering service worker:'+error);
55
});
6+
navigator.serviceWorker.addEventListener('controllerchange', function() {
7+
window.location.reload();
8+
});
69
} else {
710
console.log('service worker not supported');
811
}

0 commit comments

Comments
 (0)