musictheory / NilScript

Objective-C-style language superset of JavaScript with a tiny, simple runtime
Other
50 stars 5 forks source link

Rethink @observe #170

Open iccir opened 1 year ago

iccir commented 1 year ago

@observe was too complex. In practice, we only used @observe(after=) and almost exclusively called a single "sync properties to the DOM" method.

For now, we can safely refactor this functionality into @property via a change= attribute:

@property (change=_updateContent) title : String

Eventually, I'd like to have a simple observe attribute:

@property (observe) title : String

This would call propertyDidChange/observePropertyChange/etc in setTitle:. From there, implementation-specific methods like setNeedsUpdate or setNeedsLayout could be called.