Table of Contents

Class LoadingService

Namespace
NuvTools.AspNetCore.Blazor.Services
Assembly
NuvTools.AspNetCore.Blazor.dll

Default implementation of ILoadingService for managing loading indicator state.

public sealed class LoadingService : ILoadingService
Inheritance
LoadingService
Implements
Inherited Members

Remarks

This service uses a counter to track nested Show/Hide calls, ensuring correct behavior when multiple components request loading state simultaneously.

Should be registered as scoped to maintain state per Blazor circuit.

Properties

IsLoading

Gets a value indicating whether the loading indicator should be shown.

public bool IsLoading { get; }

Property Value

bool

Methods

Hide()

Hides the loading indicator.

public void Hide()

RunAsync(Func<Task>)

Executes an async operation while showing the loading indicator. Automatically hides the indicator when complete, even if an exception occurs.

public Task RunAsync(Func<Task> work)

Parameters

work Func<Task>

The async operation to execute.

Returns

Task

A task representing the async operation.

Show()

Shows the loading indicator.

public void Show()

Events

OnChange

Occurs when the loading state changes.

public event Action? OnChange

Event Type

Action