Adds a list of channels to listen to and executes LISTEN
on those,
if currently connected.
It will ignore channels that are already on the list.
List of channels to be added.
A promise that resolves to a list of channels actually added (not on the list yet).
Closes the connection allocated by PgListener.listen method,
with optional UNLISTEN
request for all channels.
If successful, it removes the connection from PgListener.connections
list, and returns true
.
It also ends all iterables created by createIterable.
Optional
unlisten: booleanOptional flag indicating whether to
also execute UNLISTEN
for all channels.
A promise that resolves to a boolean indicating whether the cancellation was successful.
Creates an asynchronous iterable object to receive notification messages.
The iteration is infinite, unless you explicitly call cancel, or the connection is lost permanently.
The iterable object never throws any error. Even if connection is lost permanently, it just will end the iteration, and that's it, same as when calling cancel.
An asynchronous iterable object.
Checks if the connection object allocated by PgListener.listen is currently in the connected state.
Checks if the connection object allocated by PgListener.listen is currently in the connected state or trying to connect/reconnect, i.e. if the connection is still generally alive.
When false
, the connection is lost permanently, and event
onFailedReconnect has been triggered.
Sends a notification to the list of specified channels, on the connection allocated by PgListener.listen method.
An array of destination channels where the notification should be sent.
If you pass in an empty list, the method will do nothing and just return false
.
Optional
payload: stringOptional payload data to include in the notification.
A promise that resolves to a boolean indicating the success of notification.
Removes a list of channels from being listened to and executes UNLISTEN
on those,
if currently connected.
It will ignore channels that are not on the list.
If no more channels are left after the removal, the connection is NOT closed.
List of channels to be removed.
A promise that resolves to a list of channels actually removed (those still on the list).
Result from PgListener.listen method.