Hello! The problem here is a circular definition:
{
if (p !== mutable p_value) {
mutable p_value = p;
viewof p.input.p_value = p;
viewof p.dispatchEvent(new CustomEvent("input"));
}
}
The above cell references p and viewof p, so it will run whenever either of those change. But it also sets the value of p (indirectly) by dispatching an input event on viewof p. And, it sets mutable p_value, which triggers viewof p to be re-initialized, because viewof p depends on p_value.
You should avoid circular definitions. I’d delete the mutable p_value cell and instead use only viewof
. Make viewof p the sole definition of the value of p, rather than trying to synchronize a view and a mutable. Here’s a short notebook showing how to mutate a view such as a slider from other cells:
Alternatively, you could use a custom view as your definition of p. Here’s my notebook on custom views:
With a custom view, both the slider and the buttons would be considered “secondary” views: they would mutate the primary view, and listen non-reactively to the main view for value changes.