ReactiveProperty provides MVVM and asynchronous support features under Reactive Extensions. Target frameworks are .NET 6+, .NET Framework 4.7.2 and .NET Standard 2.0.
The following code will result in a compile error.
Type mismatch. The type of Name property is ReactivePropertySlim<string>, but ctor assigns ReactiveProperty<string>
public class AViewModel
{
public ReactivePropertySlim<string> Name { get; }
public ReactivePropertySlim<string> Memo { get; }
public ReactiveCommandSlim DoSomethingCommand { get; }
public AViewModel()
{
Name = new ReactiveProperty<string>()
.SetValidateNotifyError(x => string.IsNullOrEmpty(x) ? "Invalid value" : null);
Memo = new ReactiveProperty<string>()
.SetValidateNotifyError(x => string.IsNullOrEmpty(x) ? "Invalid value" : null);
DoSomethingCommand = new[]
{
Name.ObserveHasErrors,
Memo.ObserveHasErrors,
}
.CombineLatestValuesAreAllFalse()
.ToReactiveCommand()
.WithSubscribe(() => { ... });
}
}
Is the correct code as follows?
public class AViewModel
{
public ValidatableReactiveProperty<string> Name { get; }
public ValidatableReactiveProperty<string> Memo { get; }
public ReactiveCommandSlim DoSomethingCommand { get; }
public AViewModel()
{
Name = new ValidatableReactiveProperty<string>("",
x => string.IsNullOrEmpty(x) ? "Invalid value" : null);
Memo = new ValidatableReactiveProperty<string>("",
x => string.IsNullOrEmpty(x) ? "Invalid value" : null);
DoSomethingCommand = new[]
{
Name.ObserveHasErrors,
Memo.ObserveHasErrors,
}
.CombineLatestValuesAreAllFalse()
.ToReactiveCommand()
.WithSubscribe(() => { ... });
}
}
The following code will result in a compile error. Type mismatch. The type of Name property is
ReactivePropertySlim<string>
, but ctor assignsReactiveProperty<string>
Is the correct code as follows?