Skip to content

How to update the value of a IState<Uri> using Set/SetAsync #16724

Answered by dr1rrb
mcNets asked this question in Q&A
Discussion options

You must be logged in to vote

As this is a recurring friction point, I think we should instead create an analyzer to detect the common issue :

var myValue = await MyState;
myUpdatedValue = myValue with { MyProperty = 42 };
MyState.Set(myUpdatedValue);

and then allow the Set no matter the type of T

@francoistanguay any opinion?

Note: The right way to do example above is

MyState.UpdateAsync(myValue => myValue with { MyProperty = 42 });

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@dr1rrb
Comment options

Answer selected by mcNets
@mcNets
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants