Skip to content

Commit b9d41c2

Browse files
committed
Changing array to key/value pair scheme.
1 parent 753d1db commit b9d41c2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

bin/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ var client = redis.createClient()
2121
client.on('error', handleErrors)
2222
client.on('message', listenMessages)
2323

24-
// Subscribe to the pubsub channel
25-
for (var ch of channels) {
24+
// Subscribe to the pubsub channels
25+
var keys = Object.keys(channels)
26+
for (var i of keys) {
27+
let ch = channels[i]
2628
log.info(`Listening to channel ${ch.channelName}`)
2729
client.subscribe(ch.channelName)
2830
}

channels/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fs.readdirSync(__dirname).forEach((file) => {
1010
if (file.match(/-channel\.js$/)) {
1111
let module = require('./' + file)
1212
let instance = new module()
13-
channelsList.push(instance)
13+
channelsList[instance.channelName] = instance
1414
}
1515
})
1616

0 commit comments

Comments
 (0)