A simple test for maybe doing events in the backgrounds between pages in Blazor.
1namespace EventsInBlazorTests.Services;
2
3internal class NotifyService(ILogger<NotifyService> logger)
4{
5 public event Action? OnNotificationReceived;
6
7 // Sendet eine Benachrichtigung an alle registrierten Abonnenten.
8 public void SendNotification()
9 {
10 logger.LogInformation("Sende Benachrichtigung");
11 NotificationReceivedHandler();
12 logger.LogInformation("Benachrichtigung gesendet");
13 }
14
15
16 // Klasseninterne Funktion zum Triggern des Eventhandlers
17 private void NotificationReceivedHandler() => OnNotificationReceived?.Invoke();
18}