Spaces:
Sleeping
Sleeping
File size: 590 Bytes
313d29f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | using System;
namespace BlazorWebAssembly.Services
{
public class NotificationStateService
{
public int UnreadCount { get; private set; }
public event Action? OnChange;
public void SetUnreadCount(int count)
{
UnreadCount = count;
NotifyStateChanged();
}
public void DecrementCount()
{
if (UnreadCount > 0)
{
UnreadCount--;
NotifyStateChanged();
}
}
private void NotifyStateChanged() => OnChange?.Invoke();
}
}
|