Skip to content
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 BindableReactiveProperty #40

Merged
merged 4 commits into from
Jan 14, 2024
Merged

Add BindableReactiveProperty #40

merged 4 commits into from
Jan 14, 2024

Conversation

neuecc
Copy link
Member

@neuecc neuecc commented Jan 13, 2024

#39
If it's okay, I'd like to hear your opinions (on Twitter as well) @runceel, @xin9le

I have prepared a class that implements INotifyPropertyChanged and INotifyDataErrorInfo for binding in XAML.
In runceel/ReactiveProperty, the relationship seems to be such that ReactiveProperty becomes ReactivePropertySlim, and BindableReactiveProperty becomes ReactiveProperty.

In R3, since ReactiveProperty is a Subject (BehaviorSubject) and does not stop on OnError, I made it so that calling OnErrorResume from outside will set an error flag.
It would be good if OnErrorResume is called from external validation or error streams.
For clearing the error, I thought it would be sufficient to have ResetError called separately.

Would this approach work without issues in WPF (or other XAML platforms)?

@neuecc
Copy link
Member Author

neuecc commented Jan 14, 2024

Thanks for the clarification(on Twitter).

Add support DataAnnotation and some changes for usage.
We can enable validation like this.

public class Hoge
{
    [Range(1, 10)]
    public BindableReactiveProperty<int> MyProperty1 { get; set; } = new BindableReactiveProperty<int>().EnableValidation<Hoge>();

    [Range(1, 10)]
    public BindableReactiveProperty<int> MyProperty2 { get; set; }

    public Hoge()
    {
        MyProperty2 = new BindableReactiveProperty<int>().EnableValidation(() => MyProperty2);
    }
}

@neuecc neuecc merged commit eb55456 into main Jan 14, 2024
@neuecc neuecc deleted the xaml-bindablereactiveproperty branch January 14, 2024 11:23
@neuecc
Copy link
Member Author

neuecc commented Jan 14, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant