-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: (mvux) Add new UpdateItemasync Extension Method #2642
base: main
Are you sure you want to change the base?
Conversation
/// <param name="newT">The new value for the item.</param> | ||
/// <param name="ct">A token to abort the async add operation.</param> | ||
/// <returns></returns> | ||
public static ValueTask UpdateItemAsync<T>(this IListState<T> state, T oldT, T newT, CancellationToken ct = default) where T : IKeyEquatable<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be consistent with other methods like this (e.g. State.SetAsync
) in order to protect ACID properties, I would add a constraint on T
: struct
(and add overloads with T?
and string
).
Also not a fan of the names of the parameters, I would rename those:
public static ValueTask UpdateItemAsync<T>(this IListState<T> state, T oldT, T newT, CancellationToken ct = default) where T : IKeyEquatable<T> | |
public static ValueTask UpdateItemAsync<T>(this IListState<T> state, T oldItem, T newItem, CancellationToken ct = default) where T : IKeyEquatable<T> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dr1rrb Added a new overload and also updated the parameter names.
Co-authored-by: David <[email protected]>
2983601
to
4fe5eca
Compare
GitHub Issue (If applicable): closes #2582
PR Type
What kind of change does this PR introduce?
What is the current behavior?
To update an item, we need to do something like ListState.UpdateAllAsync(t => t.KeyEquals(newT), newT);
What is the new behavior?
PR Checklist
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Run
results.Other information
Internal Issue (If applicable):