RedditPP Mascot

RedditPP

r/xamarindevelopers • … • u/dotnetmaui

Are you adding "allowsMultipleExecutions: false" to the AsyncCommand that's behind every button in Xamarin forms?

We have a situation where when a user taps a button a couple of times by accident it seems to trigger a command to run twice on Android. I suppose this is not unexpected.

The solution to this appears to be adding

DeletePersonCmd = new AsyncCommand<Person>(person => DeletePerson(person));

The solution to this appears to be adding: "allowsMultipleExecutions: false"

DeletePersonCmd = new AsyncCommand<Person>(person => DeletePerson(person), allowsMultipleExecutions: false);

Currently we are using:

Xamarin.CommunityTookkit.ObjectModel.AsyncCommand<T>

Is that the same as you are using?

Note that I believe this is not a problem with MVVMHelpers.Commands.AsyncCommand so I'm very interested to hear of the experience of others.

— 0