pg-listener API
    Preparing search index...

    Interface IListenEvents

    Optional event handlers passed into PgListener.listen method.

    interface IListenEvents {
        onConnected?: (con: IConnected<{}, any>, count: number) => void;
        onDisconnected?: (err: any, ctx: ILostContext) => void;
        onFailedReconnect?: (err: any) => void;
        onMessage?: (msg: IListenMessage) => void;
    }
    Index

    Properties

    onConnected?: (con: IConnected<{}, any>, count: number) => void

    A callback for when a new connection has been established.

    This is mainly for logging purposes / diagnostics.

    Type Declaration

      • (con: IConnected<{}, any>, count: number): void
      • Parameters

        • con: IConnected<{}, any>

          New pg-promise connection object.

        • count: number

          Number of times the connection has been established.

        Returns void

    onDisconnected?: (err: any, ctx: ILostContext) => void

    A callback function that is invoked when a disconnection event occurs i.e. when the connection has been lost temporarily.

    This is mainly for logging purposes / diagnostics.

    Type Declaration

      • (err: any, ctx: ILostContext): void
      • Parameters

        • err: any

          The error object pertaining to the disconnection issue.

        • ctx: ILostContext

          The context associated with the disconnection, providing additional details or state information.

        Returns void

    onFailedReconnect?: (err: any) => void

    A callback function that is invoked when a reconnection attempt fails.

    Receiving this event means that the connection has been lost permanently, and the library won't try to auto-reconnect again, i.e. you would need to call PgListener.listen again for another connection attempt, or just exit the application.

    Type Declaration

      • (err: any): void
      • Parameters

        • err: any

          The error object or information related to the failed reconnection attempt.

        Returns void

    onMessage?: (msg: IListenMessage) => void

    A callback for receiving a notification message from Postgres.