Properties can be used for some aspects of two-way-binding, like setting
values of HTML inputs and setting attributes or styles to DOM elements, or
bind them to data objects. They also integrate into the event dispatching
mechanism by triggering events on the widget classes if property value changes,
of course only if used on Events deriving objects.
import{Events}from'events'import{Property}from'properties'/** * Object defining a {Property} where we can listen on changes. */classMyObjectextendsEvents{constructor(){// Create property named 'some_prop'.newProperty(this,'some_prop');}/** * Default event handler if 'prop' gets changed on an * instance of ``MyObject`` * * @param {Object} val - Value the property was set to. */on_some_prop(val){}}// Create instanceletob=newMyObject();// When setting the value of 'some_prop', 'on_some_prop'// default handler gets calledob.some_prop='New Value';