CommunityToolkit / CommunityToolkit/MVVM-Samples
[RelayCommand] accepting multiple taps and executing the command multiple times
- Dominant language
- No language data
- Stars
- 1.4k
- Forks
- 265
- PR merge metrics
- No merged PRs in 30d
Description
Per the documentation on the [RelayCommand] source generator I believe that by default that multiple taps on a button should not execute the same command multiple times. However, I am experiencing the situation where I load a page from a tap gesture command and the page gets pushed multiple times. Trying to figure out how to prevent this from happening. Is this a bug or is there something missing in the code that prevents this from happening.
https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/relaycommand#handling-concurrent-executions
This can be observed in this test app
https://bradyguychambers@dev.azure.com/bradyguychambers/MyNextBook/_git/Test%20Multiple%20Taps
```
```
```
[RelayCommand]
private async void Tap(object param)
{
try
{
System.Diagnostics.Debug.WriteLine("SelectionTap:" );
if (param != null)
{
Series s = (Series)param;
System.Diagnostics.Debug.WriteLine("SelectionTap:" + s.Name);
await Shell.Current.GoToAsync($"booksview?name={s.Name}");
}
}
catch (Exception ex)
{
//todo: call appcenter analytics
System.Diagnostics.Debug.WriteLine("Crash: " + ex.Message);
}
}
```
This can be observed in this test app.
https://bradyguychambers@dev.azure.com/bradyguychambers/MyNextBook/_git/Test%20Multiple%20Taps
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.