Skip to content
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

Func<TResult> as an alternative to Command inheritance #62

Closed
wants to merge 1 commit into from

Conversation

robhruska
Copy link
Member

We have some situations (e.g. adapter code) where it's easier to work only with interfaces. This PR experiments with overloads to Invoke*() methods that take Func<TResult> delegates instead of a class that implements SyncCommand or AsyncCommand.

Opening for review and comment. This may be merged into #60.

@CLAassistant
Copy link

CLAassistant commented Sep 18, 2017

CLA assistant check
All committers have signed the CLA.

@@ -384,7 +443,7 @@ public Task<CommandResult<TResult>> InvokeReturnAsync<TResult>(AsyncCommand<TRes

// failureModeForMetrics is just so we can send "throw" or "return" along with the metrics
// event we fire for CommandInvoke(). Not really intended for use beyond that.
private async Task<TResult> InvokeAsync<TResult>(AsyncCommand<TResult> command, InformativeCancellationToken ct, OnFailure failureModeForMetrics)
private async Task<TResult> InvokeAsync<TResult>(AsyncCommand<TResult> command, OnFailure failureModeForMetrics, InformativeCancellationToken ct)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes aren't specific to this PR, but I noticed that the Invoke and InvokeAsync methods were inconsistent with argument order.

{
private readonly Func<CancellationToken?, Task<TResult>> _func;

public DelegateAsyncCommand(string group, Func<CancellationToken?, Task<TResult>> func) : base(group, group, TimeSpan.FromMilliseconds(2000))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timeout here (and below) should reference the default here

@robhruska robhruska closed this Apr 23, 2022
@robhruska robhruska deleted the FuncCommands branch April 23, 2022 13:20
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