Skip to content

psosnicki/pgnotify-net

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.NET library to easily subscribe and listen PostgreSQL Database real time notifications

build

Install

PM> Install-Package PgNotifyNet -Version 1.0.1-beta

Example

Blazor SignalR Postgresql PgNotifyNet sample application

Sample Code

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
        };
    }

License

MIT

About

.NET library to easily subscribe and listen PostgreSQL Database real time notifications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages