Replies: 4 comments 6 replies
-
|
Your new discussion is similar to the non-static method discussions and PR:
|
Beta Was this translation helpful? Give feedback.
-
|
After reviewing #3001 and PR #3002 and the standup video, I see my proposal mostly as a complement to the original request rather than a separate or competing idea. Both approaches aim to remove the need for user-authored static methods for all BindableProperty callbacks, but my suggestion goes one step further by proposing to drop explicit attribute parameters entirely and rely on convention-based instance method names, similar to the patterns used in I created this discussion following a suggestion on discord from @pictos, who also participated in the earlier discussion, with the intent of helping clarify the scope and potentially move the conversation forward rather than reopening settled topics. At this point, I’d mainly like to understand where things stand today: whether the team still sees value in this feature, if there is active interest in pursuing it, and what the current plan or direction might be. More concretely, should we aim to converge on a single approach, iterate further on the design, or close the proposal for now? |
Beta Was this translation helpful? Give feedback.
-
|
@tranb3r did you see my partial method addition? #3001 (comment) |
Beta Was this translation helpful? Give feedback.
-
|
Playing devil's advocate, there is some merit in keeping the current [BindableProperty(PropertyChangedMethodName = nameof(OnMyPropertyChanged))]
public partial string MyProperty { get; set; }
static void OnMyPropertyChanged(BindableObject b, object o, object n) => ((MyControl)b).DoSomething((string)n);If you look at how .NET MAUI implements the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First of all, thank you for adding the
BindablePropertysource generator to CommunityToolkit.Maui — it’s a great addition and a big step forward for reducing boilerplate.I’d like to start a discussion around a possible developer experience (DevEx) improvement regarding how
PropertyChangedis handled in the generator.Current behavior (CommunityToolkit.Maui)
Today, reacting to property changes requires explicitly specifying a static method and dealing with
BindableObjectcasts:This is perfectly functional and efficient, but it exposes a lot of framework-level complexity to the consumer:
BindableObjectandobjectProposed alternative (partial method pattern)
Inspired by:
CommunityToolkit.Mvvmobservable propertiesSQuan.Helpers.Maui.Mvvm)The idea is to allow an optional partial method with a strongly-typed signature:
Benefits
CommunityToolkit.MvvmpatternsNobody would be forced to use it — this would be an opt-in convenience.
Known concerns (from discussion on Discord)
Delegate allocation and performance
It was pointed out that:
BindableProperty.PropertyChangedrequires a delegateThis is a valid concern and the main technical objection raised so far.
Generator complexity
One possible mitigation is:
This introduces:
So the question becomes whether the DevEx gain justifies the added complexity.
Why I still think it’s worth discussing
CommunityToolkit.MvvmOpen questions for the team
PropertyChangedhook be acceptable as an optional feature?ObservableObjectconsidered a goal here, or is Maui a fundamentally different space?I’m not advocating for an immediate change, but I think this tradeoff is worth discussing openly.
Thanks for reading 👍
Beta Was this translation helpful? Give feedback.
All reactions