AsyncCommand can execute questions #709
-
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 7 replies
-
|
@brminnick you are probably the best person to answer this if I'm not mistaken? |
Beta Was this translation helpful? Give feedback.
-
|
No problem! Since some answers are quite verbose, I'll break them out into separate responses to help with readability 👍 |
Beta Was this translation helpful? Give feedback.
-
Question 1
AnswerIn We purposely did not use public ICommand PullToRefreshCommand { get; } = new AsyncCommand((int) count => FetchNewData(count), (bool) isBusy => !isBusy)This implementation best honors the paradigm of I strongly disagree with Xamarin.Forms' original implementation of RecommendationFor a type-safe public ICommand PullToRefreshCommand { get; } = new AsyncCommand<int,bool>(count => FetchNewData(count), isBusy => !isBusy) |
Beta Was this translation helpful? Give feedback.
-
Question 2
AnswerSimilar to the Answer for Question #1, I.e. Foregoing an input parameter for Here is an example where public ICommand PullToRefreshCommand { get; } = new AsyncCommand(() => FetchNewData(count), (bool) isBusy => !isBusy)Again, I strongly disagree with Xamarin.Forms' implementation of |
Beta Was this translation helpful? Give feedback.
-
Question 3
AnswerGood point! We should include The reason I chose the name tl;dr ResolutionI'll open a PR to add |
Beta Was this translation helpful? Give feedback.
-
Question 4
AnswerBecause If we try to use The good news is that we are using |
Beta Was this translation helpful? Give feedback.

Question 1
Answer
In
AsyncCommand<T>,Tis the type for the parameter forAsyncCommand.Execute(T parameter).We purposely did not use
TforcanExecute<object, bool>to allow for scenarios whereCanExecuteand andExecuteuse different parameters. For example, here is a case where we are using anintfor the Execute parameter and aboolfor the CanExecute parameter:This implementation best honors the paradigm of
ICommand…