blob: dca7de51b0b8c5518276e70ae219b7bc8f869a95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
async function broadcast(msg) {
for (const client of await clients.matchAll()) {
client.postMessage(msg);
}
}
self.addEventListener('fetch', event => {
event.waitUntil(broadcast(event.request.url));
event.respondWith(fetch(event.request));
});
self.addEventListener('activate', event => {
self.clients.claim();
});
|