-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Add ItemCommandTask #17
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
base: main
Are you sure you want to change the base?
Conversation
src/DynamicMvvm.Abstractions/ViewModel/IViewModel.Extensions.Commands.cs
Outdated
Show resolved
Hide resolved
src/DynamicMvvm.Abstractions/ViewModel/IViewModel.Extensions.Commands.cs
Outdated
Show resolved
Hide resolved
src/DynamicMvvm.Abstractions/ViewModel/IViewModel.Extensions.Commands.cs
Show resolved
Hide resolved
src/DynamicMvvm.Abstractions/ViewModel/IViewModel.Extensions.Commands.cs
Outdated
Show resolved
Hide resolved
var receivedParameter = default(TestEntity); | ||
var viewModel = new ViewModelBase(serviceProvider: _serviceProvider); | ||
|
||
var command = viewModel.GetItemCommandFromTask<TestEntity>(async (ct, p) => receivedParameter = p); |
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.
You should have a test that validates that all instances returned by this method are different, even when using the same name.
public static IDynamicCommand GetItemCommandFromTask<TParameter>( | ||
this IViewModel viewModel, Func<CancellationToken, TParameter, Task> execute, | ||
Func<IDynamicCommandBuilder, IDynamicCommandBuilder> configure = null, | ||
[CallerMemberName] string name = null |
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.
this parameter could be renamed to namePrefix
because that's what it really is
@@ -162,6 +162,20 @@ public class MyViewModel : ViewModelBase | |||
// command parameter when executed. The CancellationToken will be cancelled if the IViewModel is disposed. | |||
public IDynamicCommand MyCommandFromTaskWithParameter => this.GetCommandFromTask<int>(ExecuteMyTaskWithParameter); | |||
private async Task ExecuteMyTaskWithParameter(CancellationToken ct, int parameter) => Task.CompletedTask; | |||
|
|||
// This will create and attach a new IDynamicCommand named "MyCommandForItemFromTask + GUID" |
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.
Instead of repeating the same thing as before, I would just refer to GetCommandFromTask
and explain what the ItemCommand does differently.
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.
I think this might be the best strategy for the XML doc as well (if possible).
GitHub Issue: #
Proposed Changes
What is the current behavior?
What is the new behavior?
Checklist
Please check if your PR fulfills the following requirements:
Other information