Skip to content

Instantly share code, notes, and snippets.

@jonpitch
Created September 28, 2018 01:15
Show Gist options
  • Save jonpitch/cea8705dc45bb74a6bb721781736ec64 to your computer and use it in GitHub Desktop.
Save jonpitch/cea8705dc45bb74a6bb721781736ec64 to your computer and use it in GitHub Desktop.
new build notification - service worker registration - medium
import { addSuccessHandler } from 'ember-service-worker/service-worker-registration';
window.isUpdateAvailable =
'Promise' in window
? new Promise(function(resolve) {
addSuccessHandler(function(reg) {
reg.onupdatefound = function() {
const { installing } = reg;
installing.onstatechange = function() {
if (installing.state === 'activated') {
resolve(navigator.serviceWorker.controller !== null);
}
};
};
});
})
: {
then: function () {
return false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment