Skip to content

Commit a5ddf59

Browse files
author
Pooya Parsa
committedNov 16, 2017
feat(workbox): expose registration as window.$sw
Also better error handeling when registration failed
1 parent 6679d73 commit a5ddf59

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

Diff for: ‎packages/workbox/templates/sw.plugin.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
window.onNuxtReady(() => {
22
if (!('serviceWorker' in navigator)) {
3-
console.warn('serviceWorker is not supported')
3+
console.warn('Service workers are not supported.')
44
return
55
}
66

77
navigator.serviceWorker.register('<%= options.swURL %>', {
88
scope: '<%= options.swScope %>'
9-
})
9+
}).then(function(registration) {
10+
window.$sw = registration
11+
}).catch(function(error) {
12+
console.error('Service worker registration failed:', error);
13+
});
1014
})

0 commit comments

Comments
 (0)
Please sign in to comment.