Skip to content

Instance Method

addListener(channel:handler:)

Add a handler for NotificationResponse messages on a certain channel. This is used in conjunction with PostgreSQL’s LISTEN/NOTIFY support: to listen on a channel, you add a listener using this method to handle the NotificationResponse messages, then issue a LISTEN query to instruct PostgreSQL to begin sending NotificationResponse messages.
@discardableResult @preconcurrency func addListener(channel: String, handler notificationHandler: @escaping @Sendable (PostgresListenContext, PostgresMessage.NotificationResponse) -> Void) -> PostgresListenContext