3 ms·
This observable.on("click", observerFunc); // or observable.addEventListener(...); is an executable statement. And this class Widget : Element {
by c-smile 8y ago
This
observable.on("click", observerFunc);
// or observable.addEventListener(...);
is an executable statement. And this
class Widget : Element {
event click { … observer's code … }
}
is a declaration.
That executable statement needs to be called at some point of time. So the observable can be in two states - with and without that event handler.
While class declaration is an invariant (at least in Sciter) - as soon as element is in DOM it has that class and consistent set of event handlers in place. Such binding is done by, again, CSS declaration:
widget {
prototype: Widget url(path); // <widget> controller
display: block;
...
}
"I've done a fair bit of GUI stuff"
AFAIR VB6 and Delphi allow to declare event handlers without explicit/runtime binding - that's close as a concept to the above.