Public
Edited
Sep 10, 2021
5 forks
41 stars
Insert cell
Insert cell
{
const div = html`<div>`;
let request = requestAnimationFrame(function tick() {
div.textContent = Date.now();
request = requestAnimationFrame(tick);
});
invalidation.then(() => cancelAnimationFrame(request));
return div;
}
Insert cell
Insert cell
{
const div = html`<div>`;
while (true) {
div.textContent = Date.now();
yield div;
}
}
Insert cell
Insert cell
html`<div>${now}`
Insert cell
Insert cell
{
++mutable count; // This should always be one.
yield mutable count === 1
? html`<div style="color:green;">Success!</div>`
: html`<div style="color:red;">Failure!</div>`;
try {
yield invalidation;
} finally {
--mutable count;
}
}
Insert cell
Insert cell
Insert cell
Generators.observe(notify => {
notify(42);
return () => console.log("invalidated");
})
Insert cell
Insert cell
{
let done = false;
return {
next() {
if (done) return {done: true};
done = true;
return {done: false, value: 42};
},
return() {
console.log("invalidated");
}
};
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more