Skip to content

PgChannelEmitter

Mykhailo Stadnyk edited this page Nov 23, 2020 · 4 revisions

Globals / PgChannelEmitter

Class: PgChannelEmitter

Implements event emitting/subscribing on PostgreSQL LISTEN/NOTIFY named channels.

Hierarchy

  • EventEmitter

    PgChannelEmitter

Index

Constructors

Events

Properties

Methods

Constructors

constructor

+ new PgChannelEmitter(options?: EventEmitterOptions): PgChannelEmitter

Inherited from PgChannelEmitter.constructor

Parameters:

Name Type
options? EventEmitterOptions

Returns: PgChannelEmitter

Events

channel

channel(payload: AnyJson): void

Channel listener event, occurs whenever the listening channel gets a new payload message.

asmemberof PgChannelEmitter

Parameters:

Name Type Description
payload AnyJson event payload

Returns: void

Properties

defaultMaxListeners

Static defaultMaxListeners: number

Inherited from PgChannelEmitter.defaultMaxListeners


errorMonitor

Static Readonly errorMonitor: unique symbol

Inherited from PgChannelEmitter.errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

addListener

addListener(event: string | symbol, listener: (...args: any[]) => void): this

Inherited from PgClient.addListener

Parameters:

Name Type
event string | symbol
listener (...args: any[]) => void

Returns: this


emit

emit(event: string | symbol, ...args: any[]): boolean

Inherited from PgClient.emit

Parameters:

Name Type
event string | symbol
...args any[]

Returns: boolean


eventNames

eventNames(): Array<string | symbol>

Inherited from PgClient.eventNames

Returns: Array<string | symbol>


getMaxListeners

getMaxListeners(): number

Inherited from PgClient.getMaxListeners

Returns: number


listenerCount

listenerCount(event: string | symbol): number

Inherited from PgClient.listenerCount

Parameters:

Name Type
event string | symbol

Returns: number


listeners

listeners(event: string | symbol): Function[]

Inherited from PgClient.listeners

Parameters:

Name Type
event string | symbol

Returns: Function[]


off

off(event: string | symbol, listener: (...args: any[]) => void): this

Inherited from PgClient.off

Parameters:

Name Type
event string | symbol
listener (...args: any[]) => void

Returns: this


on

on(channelName: string, listener: typeof channel): this

Overrides void

Sets channel listener event handler

Parameters:

Name Type Description
channelName string channel name to listen
listener typeof channel channel event handler

Returns: this


once

once(channelName: string, listener: typeof channel): this

Overrides PgClient.once

Sets channel listener event handler which will be fired only one time

Parameters:

Name Type Description
channelName string channel name to listen
listener typeof channel channel event handler

Returns: this


prependListener

prependListener(event: string | symbol, listener: (...args: any[]) => void): this

Inherited from PgClient.prependListener

Parameters:

Name Type
event string | symbol
listener (...args: any[]) => void

Returns: this


prependOnceListener

prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): this

Inherited from PgClient.prependOnceListener

Parameters:

Name Type
event string | symbol
listener (...args: any[]) => void

Returns: this


rawListeners

rawListeners(event: string | symbol): Function[]

Inherited from PgClient.rawListeners

Parameters:

Name Type
event string | symbol

Returns: Function[]


removeAllListeners

removeAllListeners(event?: string | symbol): this

Inherited from PgClient.removeAllListeners

Parameters:

Name Type
event? string | symbol

Returns: this


removeListener

removeListener(event: string | symbol, listener: (...args: any[]) => void): this

Inherited from PgClient.removeListener

Parameters:

Name Type
event string | symbol
listener (...args: any[]) => void

Returns: this


setMaxListeners

setMaxListeners(n: number): this

Inherited from PgClient.setMaxListeners

Parameters:

Name Type
n number

Returns: this


listenerCount

StaticlistenerCount(emitter: EventEmitter, event: string | symbol): number

Inherited from PgChannelEmitter.listenerCount

deprecated since v4.0.0

Parameters:

Name Type
emitter EventEmitter
event string | symbol

Returns: number