MCPcopy Create free account
hub / github.com/microsoft/SandDance / target

Function target

docs/app/js/sanddance-app.js:141995–142005  ·  view source on GitHub ↗

* Bind the signal to an external EventTarget.

(bind2, node, param, view)

Source from the content-addressed store, hash-verified

141993/**
141994 * Bind the signal to an external EventTarget.
141995 */ function target(bind2, node, param, view) {
141996 const type = param.event || "input";
141997 const handler = ()=>bind2.update(node.value); // initialize signal value to external input value
141998 view.signal(param.signal, node.value); // listen for changes on the element
141999 node.addEventListener(type, handler); // register with view, so we can remove it upon finalization
142000 trackEventListener(view, node, type, handler); // propagate change to element
142001 bind2.set = (value)=>{
142002 node.value = value;
142003 node.dispatchEvent(event(type));
142004 };
142005}
142006function event(type) {
142007 return typeof Event !== "undefined" ? new Event(type) : {
142008 type

Callers 1

onStreamFunction · 0.70

Calls 3

trackEventListenerFunction · 0.70
eventFunction · 0.70
signalMethod · 0.45

Tested by

no test coverage detected