Published unlisted
Edited
Jul 3, 2021
Insert cell
Insert cell
viewof nonDom = delayedInput("value set by the timeout")
Insert cell
viewof name = Inputs.bind(Inputs.text({label: "Name"}), viewof nonDom)
Insert cell
name + "."
Insert cell
(viewof name).value
Insert cell
function delayedInput(value) {
//const res = Inputs.input("initial")
const res = Inputs.text({value: "initial"}) // now is a dom Input
window.setTimeout(() => set(res, "value set in setTimeout"), 2000);
return res
}
Insert cell
Inputs.button([
["Set value in nonDom", () => set(viewof nonDom, "value set by the button `nonDom`")],
["Set value in name", () => set(viewof name, "value set by the button `name`")],
["delayed Set value in nonDom", () => window.setTimeout(() => set(viewof nonDom, "delayed value set by the button `nonDom`"), 2000)],
["delayed Set value in name", () => window.setTimeout(() => set(viewof name, "delayed value set by the button `name`"), 2000)]
])
Insert cell
function set(input, value) {
input.value = value;
// input.dispatchEvent(new Event("input"));
input.dispatchEvent(new Event("input", {bubbles:true}));
}
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