Created
September 28, 2018 01:15
-
-
Save jonpitch/cea8705dc45bb74a6bb721781736ec64 to your computer and use it in GitHub Desktop.
new build notification - service worker registration - medium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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