fix: catch undefined registrationHooks callbacks
This commit is contained in:
parent
dbcc8e4541
commit
f5f4203c6e
2 changed files with 7 additions and 7 deletions
|
@ -28,7 +28,6 @@ export default defineConfig({
|
|||
waiting: () => console.log('>>> waiting...'),
|
||||
active: () => console.log('>>> active...'),
|
||||
error: (error) => console.error('>>> error', error),
|
||||
unsupported: () => console.log('>>> service worker unsupported'),
|
||||
afterRegistration: async () => {
|
||||
const sw = await navigator.serviceWorker.getRegistration();
|
||||
console.log('>>> registrered', sw)
|
||||
|
|
13
index.js
13
index.js
|
@ -1,3 +1,4 @@
|
|||
// @ts-check
|
||||
/**
|
||||
* @license MIT <https://opensource.org/licenses/MIT>
|
||||
* @author Ayo Ayco <https://ayo.ayco.io>
|
||||
|
@ -50,12 +51,12 @@ export default function serviceWorker(options) {
|
|||
} = options || {};
|
||||
|
||||
const {
|
||||
installing: installingFn,
|
||||
waiting: waitingFn,
|
||||
active: activeFn,
|
||||
error: errorFn,
|
||||
unsupported: unsupportedFn,
|
||||
afterRegistration: afterRegistrationFn,
|
||||
installing: installingFn = () => {},
|
||||
waiting: waitingFn = () => {},
|
||||
active: activeFn = () => {},
|
||||
error: errorFn = () => {},
|
||||
unsupported: unsupportedFn = () => {},
|
||||
afterRegistration: afterRegistrationFn = () => {},
|
||||
} = registrationHooks;
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue