CommunityToolkit / dotnet

.NET Community Toolkit is a collection of helpers and APIs that work for all .NET developers and are agnostic of any specific UI platform. The toolkit is maintained and published by Microsoft, and part of the .NET Foundation.
https://docs.microsoft.com/dotnet/communitytoolkit/?WT.mc_id=dotnet-0000-bramin
Other
2.99k stars 294 forks source link

Unseal RelayCommand and AsyncRelayCommand #802

Open jhert0 opened 10 months ago

jhert0 commented 10 months ago

Overview

I'm working on custom command that will let the developer pass a permission string into the constructor and if the user has that permission then command will be enabled if CanExecute returns true and will be disabled when CanExecute returns false or the user doesn't have that permission. I wanted to inherit from RelayCommand and AsyncRelayCommand but am not able to due to them being marked as sealed.

API breakdown

Remove sealed keyword from RelayCommand and AsyncRelayCommand.

Usage example

public class CustomCommand : RelayCommand {
    ...
}
public class AsyncCustomCommand : AsyncRelayCommand {
    ...
}

Breaking change?

No

Alternatives

Re-implement RelayCommand and AsyncRelayCommand functionality for custom commands.

Additional context

No response

Help us help you

No, just wanted to propose this

Palatis commented 9 months ago

i think you can implement your own IRelayCommand? and for what you're trying to do, maybe the check should be done in the CanExecute callback?