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

[Enhancement] Update AsyncCommand constructor parameters to match Command ones #771

@maxkoshevoi

Description

@maxkoshevoi

Summary

Related to #709

This repository has AsyncCommand class that accompanies Xamarin's Command class, but for async methods.
It's great, but has two issues:

  1. Sometimes it accepts object as parameter. This is not ideal. We should use static typing whenever we can (that's why generics were created). And we can do this here with little API change.
  2. AsyncCommand and Command should accept the same parameters (that are common for both classes), but right not this is not always the case:
  • canExecute parameter for AsyncCommand<T> accept Func<object, bool> instead of Func<T, bool>? It's Func<T, bool> for regular Command<T>.
  • canExecute parameter for AsyncCommand (without T) accept Func<object, bool> instead of Func<bool>? It's Func<bool> for regular Command.

They should the same parameters so user can seamlessly switch between them (methods become async and sync again all the time).

Common place to create all the commands

Also it would be great to create some CommandHelper.Create() that would automatically resolve what command (sync or async) you're trying to create and return an instance of it. This is helpful because id some method will become async or sync, Create() would automatically return command of needed type. And in general, when creating a command user wouldn't need to think what type it would be, they just need to call Create on whatever method they have.

Intended Use Case

User would be able to change new Command(a, b) to new AsyncCommand(a, b) (and new Command<T>(a, b) to new AsyncCommand<T>(a, b)) and a and b would still be valid arguments.

Who Will Do The Work?

  • I am willing to take this on myself
  • Just putting this out there for someone to pick up

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA request for a new feature.needs-approvalFeature request has been submitted but is awaiting final approval. Please do not implement before!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions