Topics

Note Selector

Attribute Proxies

Wednesday, October 20, 2021

What if two different widgets wanted to share a value between one of their attributes? You would use an ASC or value change detection. A problem with these solutions is that they usually only work in one direction.

Say you have AttrA and AttrB, and they belong to different widgets. You want them to share a value. AttrA can establish a sharing relationship with AttrB, so when AttrA's value changes, AttrB gets updated. But what about when AttrB gets a value change? With an ASC, you need a special call to obtain the shared-to-attribute's value. With value change detection, you risk running into an infinite loop.

Wouldn't it be nice if there was just one attribute altogether? Enter the concept of Attribute Proxies.

Attribute Proxy Example Image

Attribute A would need to be setup to update Themeable B when its value is updated. However, Attribute A needs to know to stop updating Themeable B in the event that Themeable B is destroyed.