Closed mbostock closed 3 years ago
Or even simpler:
class View extends EventTarget {
constructor(value) {
super();
Object.defineProperties(this, {
_value: {value, writable: true}
});
}
get value() {
return this._value;
}
set value(value) {
this._value = value;
this.dispatchEvent({type: "input", value});
}
}
But Safari doesn’t support extending EventTarget yet, boo.
Fixed in #207.
As shown in https://beta.observablehq.com/@mbostock/views-are-mutable-values