Table of Contents

Class CommandExtensions

Namespace
Dmnk.Blazor.Mvvm.CommunityToolkit
Assembly
Dmnk.Blazor.Mvvm.CommunityToolkit.dll
public static class CommandExtensions
Inheritance
CommandExtensions
Inherited Members

Methods

Bind<T>(IAsyncRelayCommand, AbstractMvvmComponentBase<T>)

Exactly like Bind<T>(ICommand, AbstractMvvmComponentBase<T>), but for IAsyncRelayCommand instead of ICommand.

Convert a parameterless IAsyncRelayCommand to a parameterless Func<TResult>. The returned Func<TResult> will check if the command can be executed before executing it.

Blazor components will typically not accept commands but lambdas. This method allows for a slightly nicer syntax, but more importantly, it avoids allocating new Func<TResult> instances on every render.

You probably want to put @using Dmnk.Blazor.Mvvm.CommunityToolkit in your _Imports.razor so that this method takes precedence over Bind<T>(ICommand, AbstractMvvmComponentBase<T>).

public static Func<Task> Bind<T>(this IAsyncRelayCommand cmd, AbstractMvvmComponentBase<T> component) where T : INotifyPropertyChanged

Parameters

cmd IAsyncRelayCommand
component AbstractMvvmComponentBase<T>

Returns

Func<Task>

Type Parameters

T