Published
Edited
Jun 1, 2022
12 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
html`${(await await getData(notebookURL)).content}`
Insert cell
Insert cell
Insert cell
generate = async (id) => {
console.log("generate", id);
const container = document.createElement("article");
const [{ Runtime, Inspector }, { default: define }] = await Promise.all([
import(
"https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js"
),
import(`https://api.observablehq.com/d/${id}.js?v=3`)
]);

let pending = 0;

new Runtime().module(define, (name) => {
const node = document.createElement("div");
container.appendChild(node);
if (name) node.id = name;
return {
pending() {
pending++;
},
fulfilled(value) {
if (value instanceof HTMLElement) {
node.replaceWith(value);
} else {
console.log("skipping", value);
}
pending--;
},
rejected(error) {
pending--;
}
};
});
let secs = 0;
do {
console.log("wait");
await new Promise((resolve) => setTimeout(resolve, 1000));
secs++;
} while (pending > 0 && secs < 2);
return container;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more