@matolink/next-offline-ts
Version:
<h1 align="center"> next-offline-ts </h1>
32 lines (31 loc) • 1.17 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.register = exports.unregister = void 0;
function unregister() {
if (typeof window != 'undefined' && 'serviceWorker' in navigator) {
navigator.serviceWorker.ready.then(function (registration) {
registration
.unregister()
.then(function (unRegistration) {
console.log('SW unRegistered: ', unRegistration);
})
.catch(function (unRegistrationError) {
console.error('SW unRegistration failed: ', unRegistrationError);
});
});
}
}
exports.unregister = unregister;
function register(swPath, options) {
if (typeof window != 'undefined' && 'serviceWorker' in navigator) {
navigator.serviceWorker
.register(swPath || '/service-worker.js', options)
.then(function (registration) {
console.log('SW registered: ', registration);
})
.catch(function (registrationError) {
console.log('SW registration failed: ', registrationError);
});
}
}
exports.register = register;