Table of Contents

Class MvvmComponentBase<TViewModel>

Namespace
Blazing.Mvvm.Components
Assembly
Blazing.Mvvm.dll

Provides a base Blazor component that resolves and manages a ViewModel of type TViewModel.

public abstract class MvvmComponentBase<TViewModel> : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IView<TViewModel>, IView, IDisposable where TViewModel : IViewModelBase

Type Parameters

TViewModel

The type of the ViewModel associated with this component.

Inheritance

Implements

Inherited Members

Properties

IsDisposed

Gets a value indicating whether the component has been disposed.

protected bool IsDisposed { get; }

Property Value

bool

ParameterResolver

Gets or sets the parameter resolver used to set parameters on the View and ViewModel.

[Inject]
protected IParameterResolver ParameterResolver { get; set; }

Property Value

IParameterResolver

ViewModel

Gets or sets the ViewModel associated with this component, resolved from the dependency injection container.

protected virtual TViewModel ViewModel { get; set; }

Property Value

TViewModel

Methods

Dispose()

Disposes the component and releases resources.

public void Dispose()

Dispose(bool)

Disposes the component and releases unmanaged resources.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

True if called from Dispose(); false if called from a finalizer.

OnAfterRender(bool)

Invoked after the component has rendered.

protected override void OnAfterRender(bool firstRender)

Parameters

firstRender bool

True if this is the first time OnAfterRender(bool) is called; otherwise, false.

OnAfterRenderAsync(bool)

Asynchronously invoked after the component has rendered.

protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender bool

True if this is the first time OnAfterRenderAsync(bool) is called; otherwise, false.

Returns

Task

A Task representing the asynchronous operation.

OnInitialized()

Initializes the component and subscribes to ViewModel property changes.

protected override void OnInitialized()

OnInitializedAsync()

Asynchronously initializes the component.

protected override Task OnInitializedAsync()

Returns

Task

A Task representing the asynchronous operation.

OnParametersSet()

Sets parameters on the component and ViewModel.

protected override void OnParametersSet()

OnParametersSetAsync()

Asynchronously sets parameters on the component and ViewModel.

protected override Task OnParametersSetAsync()

Returns

Task

A Task representing the asynchronous operation.

SetParametersAsync(ParameterView)

Sets parameters from the given Microsoft.AspNetCore.Components.ParameterView on both the View and its ViewModel using the ParameterResolver

public override Task SetParametersAsync(ParameterView parameters)

Parameters

parameters ParameterView

The parameters to set.

Returns

Task

A Task representing the asynchronous operation.

ShouldRender()

Determines whether the component should render.

protected override bool ShouldRender()

Returns

bool

true if the component should render; otherwise, false.