> [Globals](../globals) / PgChannelEmitter # Class: PgChannelEmitter Implements event emitting/subscribing on PostgreSQL LISTEN/NOTIFY named channels. ## Hierarchy * EventEmitter ↳ **PgChannelEmitter** ## Index ### Constructors * [constructor](PgChannelEmitter#constructor) ### Events * [channel](PgChannelEmitter#channel) ### Properties * [defaultMaxListeners](PgChannelEmitter#defaultmaxlisteners) * [errorMonitor](PgChannelEmitter#errormonitor) ### Methods * [addListener](PgChannelEmitter#addlistener) * [emit](PgChannelEmitter#emit) * [eventNames](PgChannelEmitter#eventnames) * [getMaxListeners](PgChannelEmitter#getmaxlisteners) * [listenerCount](PgChannelEmitter#listenercount) * [listeners](PgChannelEmitter#listeners) * [off](PgChannelEmitter#off) * [on](PgChannelEmitter#on) * [once](PgChannelEmitter#once) * [prependListener](PgChannelEmitter#prependlistener) * [prependOnceListener](PgChannelEmitter#prependoncelistener) * [rawListeners](PgChannelEmitter#rawlisteners) * [removeAllListeners](PgChannelEmitter#removealllisteners) * [removeListener](PgChannelEmitter#removelistener) * [setMaxListeners](PgChannelEmitter#setmaxlisteners) * [listenerCount](PgChannelEmitter#listenercount) ## Constructors ### constructor \+ **new PgChannelEmitter**(`options?`: EventEmitterOptions): [PgChannelEmitter](PgChannelEmitter) *Inherited from [PgChannelEmitter](PgChannelEmitter).[constructor](PgChannelEmitter.md#constructor)* #### Parameters: Name | Type | ------ | ------ | `options?` | EventEmitterOptions | **Returns:** [PgChannelEmitter](PgChannelEmitter) ## Events ### channel • **channel**(`payload`: [AnyJson](../globals#anyjson)): void Channel listener event, occurs whenever the listening channel gets a new payload message. **`asmemberof`** PgChannelEmitter #### Parameters: Name | Type | Description | ------ | ------ | ------ | `payload` | [AnyJson](../globals#anyjson) | event payload | **Returns:** void ## Properties ### defaultMaxListeners ▪ `Static` **defaultMaxListeners**: number *Inherited from [PgChannelEmitter](PgChannelEmitter).[defaultMaxListeners](PgChannelEmitter.md#defaultmaxlisteners)* ___ ### errorMonitor ▪ `Static` `Readonly` **errorMonitor**: unique symbol *Inherited from [PgChannelEmitter](PgChannelEmitter).[errorMonitor](PgChannelEmitter.md#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](../PgClient).[addListener](../interfaces/PgClient.md#addlistener)* #### Parameters: Name | Type | ------ | ------ | `event` | string \| symbol | `listener` | (...args: any[]) => void | **Returns:** this ___ ### emit ▸ **emit**(`event`: string \| symbol, ...`args`: any[]): boolean *Inherited from [PgClient](../PgClient).[emit](../interfaces/PgClient.md#emit)* #### Parameters: Name | Type | ------ | ------ | `event` | string \| symbol | `...args` | any[] | **Returns:** boolean ___ ### eventNames ▸ **eventNames**(): Array\ *Inherited from [PgClient](../PgClient).[eventNames](../interfaces/PgClient.md#eventnames)* **Returns:** Array\ ___ ### getMaxListeners ▸ **getMaxListeners**(): number *Inherited from [PgClient](../PgClient).[getMaxListeners](../interfaces/PgClient.md#getmaxlisteners)* **Returns:** number ___ ### listenerCount ▸ **listenerCount**(`event`: string \| symbol): number *Inherited from [PgClient](../PgClient).[listenerCount](../interfaces/PgClient.md#listenercount)* #### Parameters: Name | Type | ------ | ------ | `event` | string \| symbol | **Returns:** number ___ ### listeners ▸ **listeners**(`event`: string \| symbol): Function[] *Inherited from [PgClient](../PgClient).[listeners](../interfaces/PgClient.md#listeners)* #### Parameters: Name | Type | ------ | ------ | `event` | string \| symbol | **Returns:** Function[] ___ ### off ▸ **off**(`event`: string \| symbol, `listener`: (...args: any[]) => void): this *Inherited from [PgClient](../PgClient).[off](../interfaces/PgClient.md#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](../PgClient).[once](../interfaces/PgClient.md#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](../PgClient).[prependListener](../interfaces/PgClient.md#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](../PgClient).[prependOnceListener](../interfaces/PgClient.md#prependoncelistener)* #### Parameters: Name | Type | ------ | ------ | `event` | string \| symbol | `listener` | (...args: any[]) => void | **Returns:** this ___ ### rawListeners ▸ **rawListeners**(`event`: string \| symbol): Function[] *Inherited from [PgClient](../PgClient).[rawListeners](../interfaces/PgClient.md#rawlisteners)* #### Parameters: Name | Type | ------ | ------ | `event` | string \| symbol | **Returns:** Function[] ___ ### removeAllListeners ▸ **removeAllListeners**(`event?`: string \| symbol): this *Inherited from [PgClient](../PgClient).[removeAllListeners](../interfaces/PgClient.md#removealllisteners)* #### Parameters: Name | Type | ------ | ------ | `event?` | string \| symbol | **Returns:** this ___ ### removeListener ▸ **removeListener**(`event`: string \| symbol, `listener`: (...args: any[]) => void): this *Inherited from [PgClient](../PgClient).[removeListener](../interfaces/PgClient.md#removelistener)* #### Parameters: Name | Type | ------ | ------ | `event` | string \| symbol | `listener` | (...args: any[]) => void | **Returns:** this ___ ### setMaxListeners ▸ **setMaxListeners**(`n`: number): this *Inherited from [PgClient](../PgClient).[setMaxListeners](../interfaces/PgClient.md#setmaxlisteners)* #### Parameters: Name | Type | ------ | ------ | `n` | number | **Returns:** this ___ ### listenerCount ▸ `Static`**listenerCount**(`emitter`: EventEmitter, `event`: string \| symbol): number *Inherited from [PgChannelEmitter](PgChannelEmitter).[listenerCount](PgChannelEmitter.md#listenercount)* **`deprecated`** since v4.0.0 #### Parameters: Name | Type | ------ | ------ | `emitter` | EventEmitter | `event` | string \| symbol | **Returns:** number