Skip to content

Commit

Permalink
Merge pull request #3 from paddybalinia/feat/manifest
Browse files Browse the repository at this point in the history
feat: se agrega el serviceWorker
  • Loading branch information
paddybalinia authored Aug 8, 2023
2 parents fea9d75 + c171daf commit 0616030
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ <h2 class="splash__title">
En construcción. Vuelve pronto.
</h2>
</div>
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js')
.then(registration => {
console.log('Service Worker registrado con éxito:', registration);
})
.catch(error => {
console.log('Error al registrar el Service Worker:', error);
});
}
</script>
</body>

</html>
18 changes: 18 additions & 0 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Escucha el evento 'install'
self.addEventListener("install", (event) => {
// Realiza tareas de instalación, como la creación de cachés
console.log("Service Worker instalado");
});

// Escucha el evento 'activate'
self.addEventListener("activate", (event) => {
// Realiza tareas de activación, como limpiar cachés antiguas
console.log("Service Worker activado");
});

// Escucha el evento 'fetch'
self.addEventListener("fetch", (event) => {
// Intercepta solicitudes de red y realiza acciones
console.log("Interceptando solicitud:", event.request.url);
event.respondWith(fetch(event.request));
});

0 comments on commit 0616030

Please sign in to comment.