Currently the second argument in publish(channel, arg) is required. This contradict the typical event emitter pattern where the argument is not necessary required (sometimes only the event itself matters). I propose to make the second argument optional. If it's required due to downstream implementation details, I propose to make it equal to null by default.
> PGPubsub = require('pg-pubsub'); new PGPubsub('postgres://localhost/xxx').publish('foo')
Promise {
<pending>,
domain:
Domain {
domain: null,
_events:
{ removeListener: [Function: updateExceptionCapture],
newListener: [Function: updateExceptionCapture],
error: [Function: debugDomainError] },
_eventsCount: 3,
_maxListeners: undefined,
members: [] } }
> Successful retry attempt for pubsub
(node:56886) UnhandledPromiseRejectionWarning: VError: Failed to publish to channel: syntax error at or near "NULL"
at _getDB.then.catch.err (/Users/semenov/xxx/node_modules/pg-pubsub/index.js:126:34)
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:56886) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
Currently the second argument in
publish(channel, arg)
is required. This contradict the typical event emitter pattern where the argument is not necessary required (sometimes only the event itself matters). I propose to make the second argument optional. If it's required due to downstream implementation details, I propose to make it equal tonull
by default.See demos:
1) works fine when sending
null
:Throws when sending without arguments: