After initial registration, trigger a fetch event for the page in the service worker.

This commit is contained in:
Dan 2017-12-20 23:14:51 -08:00
parent fad1d327f4
commit aba3b8d8b4
1 changed files with 4 additions and 1 deletions

View File

@ -9,11 +9,14 @@ function App() {
create()
function create() {
// TODO: After initial registration, trigger a fetch event for the page in the service worker.
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/fetcher.js')
.then((registration) => {
console.log('Registered the service worker successfully')
// Now that a service worker is registered to intercept URLs, reload the page so
// this page's URL gets loaded from IPFS by the service worker.
window.location.reload(false)
})
.catch((err) => {
console.log('Failed to register:', err)