register-service-worker
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -49,3 +49,8 @@ // Register a service worker to serve assets from local cache. | ||
emit('registered', registration) | ||
if (registration.waiting) { | ||
emit('updated', registration) | ||
return | ||
} | ||
registration.onupdatefound = function () { | ||
emit('updatefound') | ||
var installingWorker = registration.installing | ||
@@ -52,0 +57,0 @@ installingWorker.onstatechange = function () { |
{ | ||
"name": "register-service-worker", | ||
"sideEffects": false, | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "Script for registering service worker, with hooks", | ||
@@ -9,3 +9,4 @@ "main": "index.js", | ||
"build": "node scripts/build.js", | ||
"prepare": "npm run build" | ||
"prepare": "npm run build", | ||
"prepublishOnly": "conventional-changelog -p angular -r 2 -i CHANGELOG.md -s" | ||
}, | ||
@@ -26,4 +27,5 @@ "repository": { | ||
"devDependencies": { | ||
"buble": "^0.18.0" | ||
"buble": "^0.18.0", | ||
"conventional-changelog-cli": "^2.0.1" | ||
} | ||
} |
@@ -22,2 +22,5 @@ # register-service-worker | ||
}, | ||
updatefound (registration) { | ||
console.log('New content is downloading.') | ||
}, | ||
updated (registration) { | ||
@@ -35,2 +38,2 @@ console.log('New content is available; please refresh.') | ||
The `cached` and `updated` events passes a [ServiceWorkerRegistration](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration) instance in their arguments. | ||
The `cached`, `updatefound` and `updated` events passes a [ServiceWorkerRegistration](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerRegistration) instance in their arguments. |
@@ -46,3 +46,8 @@ // Register a service worker to serve assets from local cache. | ||
emit('registered', registration) | ||
if (registration.waiting) { | ||
emit('updated', registration) | ||
return | ||
} | ||
registration.onupdatefound = () => { | ||
emit('updatefound') | ||
const installingWorker = registration.installing | ||
@@ -49,0 +54,0 @@ installingWorker.onstatechange = () => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46914
8
224
38
2