JSFiddle - React, Tailwind, and code Playground
by jdanyow
JavaScript
import {html, render} from 'https://unpkg.com/lit-html/lib/lit-extended.js?module';
const wait = (t) => new Promise((resolve) => setTimeout(resolve, t));
/**
* Returns an async iterable that yields increasing integers.
*/
async function* countUp() {
let i = 0;
while (true) {
yield i++;
await wait(1000);
}
}
render(html`
Count: <span>${asyncReplace(countUp())}</span>.
`, document.body);