Public
Edited
Mar 23, 2024
12 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof config = Inputs.input()
Insert cell
Insert cell
businessLogic = {
yield htl.svg`<svg style="position: fixed;top:0px;height:100%" viewBox="0 0 1 1">
<rect width="1" height="1" fill=${config.color} />
</svg>`;
await new Promise((resolve) => setTimeout(resolve, 100));
yield undefined;
}
Insert cell
Insert cell
viewof source1 = Inputs.button("source1: red", {
required: true,
reduce: () => ({
color: "#f002"
})
})
Insert cell
source1
Insert cell
Insert cell
viewof source2 = Inputs.input()
Insert cell
viewof var2 = Inputs.button("var2: yellow", {
required: true,
reduce: () => ({
color: "#ff04"
})
})
Insert cell
copyVar2IntoSource2 = {
viewof source2.value = var2;
viewof source2.dispatchEvent(new Event("input", { bubbles: true }));
}
Insert cell
source2
Insert cell
Insert cell
connectSources = {
// Note these appear to be wired backwards!
// Source is in the target argument slot!
// Bind is not symmetrical!
Inputs.bind(viewof source1, viewof config, invalidation);
Inputs.bind(viewof source2, viewof config, invalidation);
}
Insert cell
Insert cell
<style>
code {
border-radius: 20px;
padding: 4px;
background-color: #f5f5f5;
}
</style>
Insert cell
import { footer } from "@tomlarkworthy/footer"
Insert cell
footer
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