This file contains 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
importScripts('https://cdn.jsdelivr.net/npm/[email protected]/comlink.global.min.js'); | |
class Fetch { | |
constructor() | |
getBaseUrl() | |
getDefaultHeaders() | |
getDefaultBody() | |
setBaseUrl(baseUrl) |
This file contains 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
import { Comlink } from './node_modules/comlinkjs/comlink.es6.js'; | |
const worker = new Worker('./node_modules/comlink-fetch/src/fetch.worker.js'); | |
const proxy = Comlink.proxy(worker); | |
async function getSecondaryInfo() { | |
const API = await new proxy.Fetch; | |
API.setBaseUrl("https://jsonplaceholder.typicode.com/"); |
This file contains 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Comlink Fetch</title> | |
</head> | |
<body> | |
<script type="module" src="index.js"></script> |
This file contains 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
workbox.routing.registerRoute( | |
new RegExp('https://jsonplaceholder.typicode.com/users'), | |
workbox.strategies.cacheFirst() | |
); |
This file contains 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
workbox.strategies.cacheFirst() | |
workbox.strategies.networkFirst() | |
workbox.strategies.staleWhileRevalidate() |
This file contains 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
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js'); | |
console.log('this is my custom service worker'); | |
workbox.precaching.precacheAndRoute([ | |
{ | |
"url": "css/app.css", | |
"revision": "fd2e1d3c4c8d43da10afe67a7d69fbd1" | |
}, | |
{ | |
"url": "index.html", | |
"revision": "39b8fb34f8be7ecf969530f1b9e69ba1" |
This file contains 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
module.exports = { | |
"globDirectory": "build/", | |
"globPatterns": [ | |
"**/*.{css,html,js}" | |
], | |
"swDest": "build/sw.js", | |
"swSrc": "src-sw.js" | |
}; |
This file contains 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
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.0.0/workbox-sw.js'); | |
console.log('this is my custom service worker'); | |
workbox.precaching.precacheAndRoute([]); |
This file contains 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
<script> | |
if ('serviceWorker' in navigator) { | |
window.addEventListener('load', () => { | |
navigator.serviceWorker.register('/sw.js'); | |
}); | |
} | |
</script> |
This file contains 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
module.exports = { | |
"globDirectory": "build/", | |
"globPatterns": [ | |
"**/*.{css,html,js}" | |
], | |
"swDest": "build/sw.js" | |
}; |
NewerOlder