PM> Install-Package PgNotifyNet -Version 1.0.1-beta
Blazor SignalR Postgresql PgNotifyNet sample application
Register in container:
ConfigureServices(IServicesCollection servicesCollection)
{
...
services.AddPgNotifyNet(connectionString,
o => o.Trigger (t => t.OnTable<Category>("categories").After(Change.Update, Change.Delete))
.Trigger (t => t.OnTable<User>("users").After(Change.Insert))
...
);
Implement IHandleNotification<T>
and handle notification:
public class FooNotificationHandler : IHandleNotification<Category>
{
public async Task OnDataChanged(Category oldData,Category newData, Change change)
{
//handle data change
}
}
or subscribe to PgNotificationService OnDataChange
event
public FooController(IPgNotificationService notificationService)
{
notificationService.OnDataChange += (object? sender, OnDataChangeEventArgs e) => {
//handle notification
};
}
MIT