Skip to content

Commit e7d92fd

Browse files
authored
Cleaner "Offer a page reload for users" recipe
Since Workbox v6 a new method, messageSkipWaiting(), has been added to the workbox-window module to simplify the process of telling the "waiting" service worker to activate. And all "external" events in workbox-window have been removed in place of "normal" events with an isExternal property set to true. Thanks to both of the above changes, the "Offer a page reload for users" recipe can be simplified.
1 parent cb1b327 commit e7d92fd

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

examples/lifecycle/pages/index.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default () => {
3737
})
3838

3939
// Send a message to the waiting service worker, instructing it to activate.
40-
wb.messageSW({ type: 'SKIP_WAITING' })
40+
wb.messageSkipWaiting()
4141
} else {
4242
console.log(
4343
'User rejected to reload the web app, keep using old version. New version will be automatically load when user open the app next time.'
@@ -46,7 +46,6 @@ export default () => {
4646
}
4747

4848
wb.addEventListener('waiting', promptNewVersionAvailable)
49-
wb.addEventListener('externalwaiting', promptNewVersionAvailable)
5049

5150
// ISSUE - this is not working as expected, why?
5251
// I could only make message event listenser work when I manually add this listenser into sw.js file

0 commit comments

Comments
 (0)