//-----------------------------------------------------------------------
//
// Copyright (c) lanedirt. All rights reserved.
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
//-----------------------------------------------------------------------
namespace AliasVault.Admin.Services;
///
/// Global loading service that can be used to show or hide a global layout loading spinner.
///
public class GlobalLoadingService
{
private bool _isLoading;
///
/// Occurs when the loading state changes.
///
public event Action? OnChange;
///
/// Gets or sets a value indicating whether the global loading spinner is currently visible.
///
public bool IsLoading
{
get => _isLoading;
set
{
if (_isLoading != value)
{
_isLoading = value;
OnChange?.Invoke();
}
}
}
///
/// Show the global loading spinner.
///
public void Show() => IsLoading = true;
///
/// Hide the global loading spinner.
///
public void Hide() => IsLoading = false;
}