Vicky Dichiera
Jon Rojí
@Jnroji
@VickyDichiera
Mayor velocidad de carga
Accesible sin conexión
Notificaciones
Multiplataforma
Shell
Instalable
Adaptable Design
Cacheable
Offline
Push Notifications
NOT A FRAMEWORK!
NOT A LIBRARY!
Ejemplo gráfico de las pwa serruchandole el piso a las app nativas
📦
PWA Canarias
dynamic imports
tagged templates
Custom Elements
Native JS
PWA Canarias
PWA Canarias
On stage 4!
PWA Canarias
💖 lit-html 💖
PWA Canarias
<my-comp></my-comp>
<div></div>
📦
<my-comp></my-comp>
{
"start_url": "/index.html",
"scope": ".",
"display": "standalone",
"orientation": "portrait-primary",
"theme_color": "#3f51b5",
"dir": "ltr",
"lang": "es-AR"
}
Debe tener un archivo manifest.json
Debe tener un service worker
desde donde se maneje el evento fetch
Debe ser servido en HTTPs (o en localhost)
No estar previamente instalada
install
activate fetch sync push notificationclick notificationclose
lifecycle
network
push
CACHE
INDEXEDDB
📁
{ ... }
caches.open('cache_name_v1') cache.add()
cache.put()
cache.match()
cache.delete()
Cache Only
self.addEventListener('fetch', (event) => {
event.respondWith(caches.match(event.request));
});
Network Only
self.addEventListener('fetch', (event) => {
event.respondWith(fetch(event.request));
});
Cache first, network fallback
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request).then((response) => {
if (response) {
return response;
} else {
return fetch(event.request);
}
})
)
});
Network first, cache fallback
self.addEventListener('fetch', (event) => {
event.respondWith(
fetch(event.request)
.then((response) => {
return caches.open(CURRENT_CACHES['dynamic'])
.then((cache) => {
cache.put(event.request, response.clone());
return response;
})
})
.catch((err) => {
return caches.match(event.request).then((cacheResponse) => {
if (cacheResponse) {
return cacheResponse;
}
})
})
)
});
Devtools
Nuestra PWA certificada!
@Jnroji
@VickyDichiera