Last active
December 5, 2020 04:36
-
-
Save mp5maker/7a63602c74dd4b97467e54d414a877a6 to your computer and use it in GitHub Desktop.
Service Worker Install Section
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.addEventListener('install', function(event) { | |
console.log(caches) | |
console.log("SW Install Event: Is in the process"); | |
const onSuccessCachesOpen = (cache) => { | |
console.log(cache) | |
console.log("SW Install Event: Successfully opened the cache and add the cache list"); | |
return cache.addAll(CACHE_LIST) | |
} | |
// Works like async/await | |
event.waitUntil( | |
// caches is a global variable inside the service workers file [readily available] | |
caches.open(STATIC_CACHE_VERSION).then(onSuccessCachesOpen) | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment