question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proxy or Calculated Property

See original GitHub issue

Is your feature request related to a problem? Please describe.

Shortcoming have been discovered in the property system related to dependent properties and properties calculated from others. These same deficiencies existed in WPF so this is nothing new. However, there is an opportunity to solve this better in the future.

Describe the solution you’d like

  1. Properties that should change and raise property changed events together.
    • First noted here by @grokys where SelectedItem and SelectedIndex, if styled properties, have some synchronization issues.
    • This was apparent after the switch from DirectProperty to StyledProperty. With DirectProperty full control is given in this case to raise events together after both properties are internally handled.
  2. Properties that alias other properties (proxy)
    • This came up in the past to basically support some properties for compatibility with WPF that just alias existing properties with a new type and/or name.
      • This includes properties that are calculated directly from another
      • For example WPF/WinUI’s Visibility property could be an alias of IsVisible.
      • Another example is WPF/WinUI’s ActualHeight and ActualWidth property could be an alias of Bounds. #11325
    • Another use-case that was discussed in the past is to allow us to fix API mistakes while keeping compatibility. Currently it is very difficult to rename a Styled/DirectProperty. With such a mechanism we can rename a property then keep an old, obsolete proxy/alias property (with the original name/type) around for compatibility until the next major version.
    • https://github.com/AvaloniaUI/Avalonia/pull/6836#pullrequestreview-797475570. “I guess BorderBrush and BorderThickness could be “aliases” for BorderPen.Brush and BorderPen.Thickness but that might raise complications?”

Describe alternatives you’ve considered

None, these are issues that haven’t been solved in WPF or WinUI and weren’t fully solved with DirectProperty either.

Additional context Add any other context or screenshots about the feature request here.

Issue Analytics

  • State:open
  • Created 5 months ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
robloocommented, May 11, 2023

@rabbitism, The WPF compatibility considerations were an example. There may be other use cases for this concept.

That said, avoiding ambiguity and duplication is important so I see your point there.

2reactions
maxkatz6commented, Apr 29, 2023

I would also add an inherited readonly properties support. Or, readonly styled properties. Use case - ActualThemeVariant, which right now implemented as an inherited property, and technically can be changed by the user (using SetValue directly).

It alternatively can be a computed property as well. But it would require adding some inheritance functionality to the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Computed Properties — Valtio, makes proxy-state simple for ...
proxy-memoize uses a similar usage-based tracking approach as Valtio's snapshot function, so it will only re-calculate the getter if fields accessed by the ......
Read more >
JavaScript Proxy Explained Clearly By Practical Examples
The computed properties are properties whose values are calculated based on values of existing properties.
Read more >
Vue.js Proxying
Because Vue takes any data property, method, computed property, etc. and adds a proxy property of the same name at the top level...
Read more >
Understanding the Power of Proxy in JavaScript
A Proxy is an object that envelops another object and intercepts basic operations on it, such as accessing, assigning, and deleting properties.
Read more >
What does Proxy mean in the console in Vue 3?
a Proxy is an object that encases another object or function and allows you to intercept it. Proxies are stealthy "wrapper" objects which...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found