-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the equivalent of NotifyPropertyChangedFor
#13
Comments
I'm confused by the usage of |
The fields declared here are never used. [AutoBindable] simply reads the names of the fields, remove any _ and transform to PascalCase, then generate a BindableProperty. The BindableProperty is the holder of the value, and accessors are generated to access its value. Check out the example here: https://github.com/rrmanzano/maui-bindableproperty-generator#usage---simple-implementation
Adding This issue goes over the subject and proposes an alternative: #9 |
First off, thanks for the detailed explanation, I appreciate it! :)
So the For instance: public partial class Test
{
[ObservableProperty]
private bool _isBusy;
} Generates: using ObservablePropertyAttribute = CommunityToolkit.Mvvm.ComponentModel.ObservablePropertyAttribute;
partial class Test
{
/// <inheritdoc cref="_isBusy"/>
[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", "8.2.0.0")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public bool IsBusy
{
get => _isBusy;
set
{
if (!global::System.Collections.Generic.EqualityComparer<bool>.Default.Equals(_isBusy, value))
{
OnIsBusyChanging(value);
OnIsBusyChanging(default, value);
OnPropertyChanging(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangingArgs.IsBusy);
_isBusy = value;
OnIsBusyChanged(value);
OnIsBusyChanged(default, value);
OnPropertyChanged(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangedArgs.IsBusy);
}
}
}
} If I understand correctly, whereas .NET MAUI MVVM (Sorry if this is off-topic, I was intrigued by the use of EDIT: D'OH, it's a different paradigm, |
That's correct, |
I find myself quite often having to use the
OnChanged
property of theAutoBindable
attribute to callOnPropertyChanged
on a property with a getter. Here is an example:I have a computed property relying on 2 other bindable properties, which I believe is a common pattern.
Here is what I would suggest having:
Pros:
Cons:
The text was updated successfully, but these errors were encountered: