typescene
typescene copied to clipboard
`shadowObservable` doesn't work on property of `ViewActivity`
In the example below, the binding to foo doesn't seem to work:
class MyActivity extends PageViewActivity.with(
UICell.with(
UILabel.withText(bind("foo"))
)
) {
@shadowObservable("bar")
get foo() { return this.bar + 1 }
bar = 1
// ...
}
The reason here is that foo is already observed in the class that results from PageViewActivity.with(...); this class is then extended, and the shadow observable property is added. At that point it is too late to change the behavior of the binding.
Resolution: in shadowObservable() function, check for observed/managed properties in prototypes and fail if there are any.
If there really must be a shadow observable property, it must be added on a class first, and then the class can be extended using .with(/* view */).