Skip to content

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

feat: Add ItemCommandTask #17

wants to merge 7 commits into from

Conversation

Iguins
Copy link
Contributor

@Iguins Iguins commented Mar 16, 2021

GitHub Issue: #

Proposed Changes

What is the current behavior?

What is the new behavior?

Checklist

Please check if your PR fulfills the following requirements:

  • Documentation has been added/updated
  • Automated Unit / Integration tests for the changes have been added/updated
  • Contains NO breaking changes
  • Updated the Changelog
  • Associated with an issue

Other information

@Iguins Iguins self-assigned this Mar 16, 2021
@Iguins Iguins marked this pull request as ready for review March 16, 2021 19:44
var receivedParameter = default(TestEntity);
var viewModel = new ViewModelBase(serviceProvider: _serviceProvider);

var command = viewModel.GetItemCommandFromTask<TestEntity>(async (ct, p) => receivedParameter = p);
Copy link
Member

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
Copy link
Member

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"
Copy link
Member

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.

Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants