Skip to content

Instantly share code, notes, and snippets.

@thepassle
Created October 28, 2019 14:27
Show Gist options
  • Save thepassle/3d07ebc3e1231405922cd560826b9b28 to your computer and use it in GitHub Desktop.
Save thepassle/3d07ebc3e1231405922cd560826b9b28 to your computer and use it in GitHub Desktop.
updating6
const reg = await navigator.serviceWorker.getRegistration();
reg.addEventListener('updatefound', () => {
const newWorker = reg.installing;
newWorker.addEventListener('statechange', () => {
if (newWorker.state === 'installed') {
// Update available! Show an install button
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment