Skip to content

Instantly share code, notes, and snippets.

View thepassle's full-sized avatar

Pascal Schilp thepassle

View GitHub Profile
<html>
<body>
<form id="todoInput">
<input type="text" name="todo"></input>
<button type="submit">submit</button>
</form>
<ul id="todoList">
class Batching {
// ...
async scheduleUpdate() {
if(!this.updateRequested) {
this.updateRequested = true;
this.updateRequested = await false;
this.update();
}
}
class Batching {
/**
* We declare and initialize a variable to keep track of whether
* or not an update has already been requested
*/
updateRequested = false;
scheduleUpdate() {
/**
console.log(1);
Promise.resolve().then(() => {
console.log(2);
});
console.log(3);
class MyElement extends LitElement {
foo() {
this.myPropertyA = 1;
}
}
@thepassle
thepassle / sw.js
Created October 28, 2019 14:48
clientsclaim9
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();
@thepassle
thepassle / sw.js
Created October 28, 2019 14:47
clientsclaim7
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();
@thepassle
thepassle / sw.js
Created October 28, 2019 14:46
clientsclaim5
self.addEventListener('install', event => {
// cache a cat SVG
event.waitUntil(
caches.open('static-v1')
.then(cache => cache.add('cat.svg'))
);
});
@thepassle
thepassle / index.html
Created October 28, 2019 14:45
clientsclaim4
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./sw.js');
});
}
setTimeout(() => {
const img = new Image();
@thepassle
thepassle / index.html
Created October 28, 2019 14:44
clientsclaim2
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./sw.js');
});
}
// ...