Andrzej Mazur • @end3r • Enclave Games
Warszawskie Dni Informatyki 2019, Warsaw, Poland, March 26th 2019
Native-like experience using modern web APIs
{
"name": "HexRoulette",
"short_name": "HexRoulette",
"description": "Digital add-on to the physical board game...",
"icons": [
{
"src": "img/icons/icon-32.png",
"sizes": "32x32",
"type": "image/png"
},
// ...
],
"start_url": "/index.html",
"display": "fullscreen",
"theme_color": "#BD6B19",
"background_color": "#161516"
}
if('serviceWorker' in navigator) {
navigator.serviceWorker.register('/roulette/sw.js');
};
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open(cacheName).then(function(cache) {
return cache.addAll(contentToCache);
})
);
});
self.addEventListener('fetch', function(e) {
e.respondWith(
caches.match(e.request).then(function(r) {
return r || fetch(e.request).then(function(response) {
return caches.open(cacheName).then(function(cache) {
cache.put(e.request, response.clone());
return response;
});
});
})
);
});
Build the future (web) games!