Skip to content

Instantly share code, notes, and snippets.

View raubin-kumar's full-sized avatar
🏠
Working from home

raubin-kumar

🏠
Working from home
View GitHub Profile
@raubin-kumar
raubin-kumar / activate-service-worker.js
Last active October 7, 2021 13:10
Service worker files
//service-worker.js
const cacheVersion = 'v1';
self.addEventListener('activate', function (event) {
event.waitUntil(
caches.keys().then(function (cacheNames) {
cacheNames.map(function (cacheName) {
if (cacheName.indexOf(cacheVersion) < 0) {
return caches.delete(cacheName);
}
@raubin-kumar
raubin-kumar / _main.js
Last active October 7, 2021 13:05
Worker files
const timeWorker = new Worker("worker.js");
timeWorker.postMessage({ type: "GET_CURRENT_DATE" });
timeWorker.onmessage = (evt) => {
console.log(evt.data);
}