PostgresNIO 1.0.0 Beta 2.2
Pre-release
Pre-release
- Added
PostgresConnection.addListener(channel:handler:)
(#60)
This method lets you add handlers for LISTEN
/ NOTIFY
messages.
// add notification listener to connection
conn.addListener(channel: "example") { context, notification in
print(notification) // notification payload
context.stop() // stop listening
}
// subscribe to notifications on this connection
_ = try conn.simpleQuery("LISTEN example").wait()
// send notification w/ empty payload
_ = try conn.simpleQuery("NOTIFY example").wait()