iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
✨

ReactiveProperty v9.1 Released

に公開

ReactiveProperty v9.1 has been released.

https://www.nuget.org/packages/ReactiveProperty/9.1.2

This update primarily focuses on functional improvements when using ReactiveProperty with Blazor.

  • Fixed an issue where validation was sometimes not performed correctly when calling ForceNotify on ValidatableReactiveProperty<T>.
  • Added the IsDisabled extension method to ICommand, which returns the opposite result of CanExecute.
  • Supported ValidatableReactiveProperty<T> in the ReactivePropertiesValidator component.

Update Highlights

We have added the IsDisabled extension method. This extension method returns the inverse result of the CanExecute method. It is intended for use with the disabled attribute in elements like button.
While it might not make a huge difference whether it exists or not, it's more convenient to have, so we added it. It is used as follows:

<button 
  @onclick="() => someViewModel.SomeCommand.Execute()" 
  disabled="@someViewModel.SomeCommand.IsDisabled()">
  Click Me
</button>

Without IsDisabled, you would write something like disabled=@(!someViewModel.SomeCommand.CanExecute()), but having to use parentheses is a bit tedious, so I added it as an extension method.

Improvement of the ReactivePropertiesValidator component

We added ValidatableReactiveProperty<T> in ReactiveProperty v9.0.0. Personally, I believe it's better to replace ReactiveProperty<T> with ReactivePropertySlim<T> and ValidatableReactiveProperty<T> going forward.
The issue here (though I suspect there are few users, so no one has pointed it out) was with the ReactivePropertiesValidator component, which links Blazor's EditForm validation with ReactiveProperty<T> validation. I have updated it to work correctly even with ValidatableReactiveProperty<T>.

With this update, I believe there will no longer be a need to use ReactiveProperty<T> when introducing ReactiveProperty to Blazor.

Is there any merit in using ReactiveProperty with Blazor?

While it might not be as significant as in WPF, I think it's reasonably useful if you are establishing a ViewModel-like layer.
Since Blazor handles screen updates quite well even without explicit change notifications, you might not feel the benefits of ReactivePropertySlim<T> or ValidatableReactiveProperty<T> in many cases. However, I believe AsyncReactiveCommand is convenient because it allows you to synchronize the execution status across multiple commands.

Summary

So, the v9 series has reached a milestone for now. Next up is the documentation...

Discussion