We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 90b5977 commit 9bd8507Copy full SHA for 9bd8507
lib/index.js
@@ -290,15 +290,14 @@ function Postgres(url, options) {
290
})
291
}
292
293
- function listen(x, fn) {
294
- if (x.match(/[^a-z0-9_-]/))
295
- return Promise.reject('Only a-z A-Z 0-9 and - . _ allowed in channel names')
296
-
297
- x in listeners
298
- ? listeners[x].push(fn)
299
- : (listeners[x] = [fn])
+ function listen(channel, fn) {
+ if (channel in listeners) {
+ listeners[channel].push(fn)
+ return Promise.resolve(channel)
+ }
300
301
- return query({ raw: true }, getListener(), 'listen "' + x + '"').then(() => x)
+ listeners[channel] = [fn]
+ return query({ raw: true }, getListener(), 'listen ' + escape(channel)).then(() => channel)
302
303
304
function getListener() {
0 commit comments