-
I'm doing some tests with MVUX and I'm facing this error trying to update the value of a IState using Set. In both cases using a variable or using a new object I get the same error:
public partial record OsmoViewModel
{
public IState<Uri> ImgSrc { get; }
public OsmoViewModel()
{
ImgSrc = State<Uri>.Value(this, () => new Uri("ms-appx:///Assets/Images/crono1.jpg"));
}
public async ValueTask ImgCommand(CancellationToken ct = default)
{
Uri newUri = new Uri("ms-appx:///Assets/Images/crono.jpg");
await ImgSrc.SetAsync(newUri, ct);
await Task.Delay(2000);
await ImgSrc.SetAsync(new Uri("ms-appx:///Assets/Images/crono1.jpg"), ct);
}
} This is the example in the documentation: public async ValueTask SetSliderMiddle(CancellationToken ct = default)
{
await SliderValue.Set(50, ct);
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Can you use .UpdateAsync( v => ... ) ? Set has a specific meaning that @dr1rrb can explain. |
Beta Was this translation helpful? Give feedback.
-
This is to ensure the ACID properties. The |
Beta Was this translation helpful? Give feedback.
As this is a recurring friction point, I think we should instead create an analyzer to detect the common issue :
and then allow the
Set
no matter the type ofT
@francoistanguay any opinion?