Poll read() until it returns a value different from baseline, then call
onChange with it. Gives up after timeoutMs. Returns a cancel function.
The engine commits a click on the score a moment after the DOM event (it
waits to rule out a double-click), so reading the selection straight away
returns the previous click's note. Waiting for the value to change is robust
to the engine's exact timing.
Poll
read()until it returns a value different frombaseline, then callonChangewith it. Gives up aftertimeoutMs. Returns a cancel function.The engine commits a click on the score a moment after the DOM event (it waits to rule out a double-click), so reading the selection straight away returns the previous click's note. Waiting for the value to change is robust to the engine's exact timing.