HI i'm trying to create a service worker with autodesk forge viewer, INSTALL and ACTIVATE work but fetching not.
here is my Service worker
const cacheName = 'v1';
const cacheAssets = [
"/index.html",
"/css/main.css",
"/img/myAwesomeIcon.png",
"/js/ForgeTree.js",
"/js/ForgeViewer.js",
"/js/myawesomeextension.js",
"/js/sw.js",
];
self.addEventListener('install', e => {
console.log('service worker: installed');
e.waitUntil(
caches
.open(cacheName)
.then(cache => {
console.log('service worker: caching files');
cache.addAll(cacheAssets);
})
.then(() => self.skipWaiting())
);
});
self.addEventListener('activate', e => {
console.log('service worker: activated');
e.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cache => {
if(cache !== cacheName) {
console.log('service worker: clearing old cache');
return caches.delete(cache);
}
})
);
})
);
});
self.addEventListener('fetch', e => {
console.log(e);
});
what i trying is making my own "disconnected workflow" fetching the posts and caching all the models to view them offline form bim360docs, a360 and using the 2leg forge tutorial.
try to fetch anything with the Browsers Fetch API:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API