Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

AsyncCommand can execute questions #709

Discussion options

You must be logged in to vote

Question 1

Why does canExecute parameter for AsyncCommand<T> accept Func<object, bool> instead of Func<T, bool>? It's Func<T, bool> for regular Command<T>.

Answer

In AsyncCommand<T>, T is the type for the parameter for AsyncCommand.Execute(T parameter).

We purposely did not use T for canExecute<object, bool> to allow for scenarios where CanExecute and and Execute use different parameters. For example, here is a case where we are using an int for the Execute parameter and a bool for the CanExecute parameter:

public ICommand PullToRefreshCommand { get; } = new AsyncCommand((int) count => FetchNewData(count), (bool) isBusy => !isBusy)

This implementation best honors the paradigm of ICommand

Replies: 6 comments 7 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@maxkoshevoi
Comment options

@TheCodeTraveler
Comment options

@maxkoshevoi
Comment options

Answer selected by maxkoshevoi
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@TheCodeTraveler
Comment options

@maxkoshevoi
Comment options

@TheCodeTraveler
Comment options

Comment options

You must be logged in to vote
1 reply
@maxkoshevoi
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