-
Notifications
You must be signed in to change notification settings - Fork 459
[Enhancement] Update AsyncCommand constructor parameters to match Command ones #771
Description
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:
- 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. AsyncCommand
andCommand
should accept the same parameters (that are common for both classes), but right not this is not always the case:
canExecute
parameter forAsyncCommand<T>
acceptFunc<object, bool>
instead ofFunc<T, bool>
? It's Func<T, bool> for regularCommand<T>
.canExecute
parameter forAsyncCommand
(without T) acceptFunc<object, bool>
instead ofFunc<bool>
? It'sFunc<bool>
for regularCommand
.
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