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
class Batching { | |
/** | |
* We declare and initialize a variable to keep track of whether | |
* or not an update has already been requested | |
*/ | |
updateRequested = false; | |
scheduleUpdate() { | |
/** |
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
console.log(1); | |
Promise.resolve().then(() => { | |
console.log(2); | |
}); | |
console.log(3); |
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
class MyElement extends LitElement { | |
foo() { | |
this.myPropertyA = 1; | |
} | |
} |
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
self.addEventListener('install', event => { | |
// cache a cat SVG | |
event.waitUntil( | |
caches.open('static-v1') | |
.then(cache => cache.add('cat.svg')) | |
); | |
}); | |
self.addEventListener('activate', event => { | |
clients.claim(); |
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
self.addEventListener('install', event => { | |
// cache a cat SVG | |
event.waitUntil( | |
caches.open('static-v1') | |
.then(cache => cache.add('cat.svg')) | |
); | |
}); | |
self.addEventListener('activate', event => { | |
clients.claim(); |
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
self.addEventListener('install', event => { | |
// cache a cat SVG | |
event.waitUntil( | |
caches.open('static-v1') | |
.then(cache => cache.add('cat.svg')) | |
); | |
}); |
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'); | |
}); | |
} | |
setTimeout(() => { | |
const img = new Image(); |
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'); | |
}); | |
} | |
// ... |
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
button.addEventListener('click', async () => { | |
deferredPrompt.prompt(); | |
const { outcome } = await deferredPrompt.userChoice; | |
if (outcome === 'accepted') button.setAttribute('hidden', '); | |
// Send an analytics event for either dismissed or accepted! | |
}); |
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
button.addEventListener('click', async () => { | |
deferredPrompt.prompt(); | |
// ... | |
}); |