Skip to content

Instantly share code, notes, and snippets.

@bennypowers
Last active June 23, 2017 12:39
Show Gist options
  • Save bennypowers/2e1f2f015aa2e83d23dc9c24a607d39d to your computer and use it in GitHub Desktop.
Save bennypowers/2e1f2f015aa2e83d23dc9c24a607d39d to your computer and use it in GitHub Desktop.
New Version Available. Click to Reload
// Polymer Starter Kit App
// my-app, in `ready` callback
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js')
.then((registration) => {
registration.onupdatefound = (event) => {
let installingWorker = registration.installing;
installingWorker.onstatechange = (event) => {
switch (installingWorker.state) {
case 'redundant':
this._log.error('The installing service-worker was redundant');
break;
case 'installed':
this._log.debug(`Service worker ${installingWorker.state}`);
return this.$.swtoast.open();
}
};
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment