@@ -25,9 +25,9 @@ class Subscriber extends events.EventEmitter {
|
||||
}
|
||||
|
||||
subscribe(channel: string): void {
|
||||
const handler = (message) => {
|
||||
const handler = message => {
|
||||
this.emit('message', channel, message);
|
||||
}
|
||||
};
|
||||
this.subscriptions.set(channel, handler);
|
||||
this.emitter.on(channel, handler);
|
||||
}
|
||||
@@ -51,9 +51,7 @@ function createSubscriber(): any {
|
||||
|
||||
const EventEmitterPubSub = {
|
||||
createPublisher,
|
||||
createSubscriber
|
||||
}
|
||||
createSubscriber,
|
||||
};
|
||||
|
||||
export {
|
||||
EventEmitterPubSub
|
||||
}
|
||||
export { EventEmitterPubSub };
|
||||
|
||||
@@ -25,7 +25,7 @@ interface Publisher {
|
||||
* @param {String} channel the channel in which to publish
|
||||
* @param {String} message the message to publish
|
||||
*/
|
||||
publish(channel: string, message: string):void;
|
||||
publish(channel: string, message: string): void;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import redis from 'redis';
|
||||
|
||||
function createPublisher({redisURL}): any {
|
||||
function createPublisher({ redisURL }): any {
|
||||
return redis.createClient(redisURL, { no_ready_check: true });
|
||||
}
|
||||
|
||||
function createSubscriber({redisURL}): any {
|
||||
function createSubscriber({ redisURL }): any {
|
||||
return redis.createClient(redisURL, { no_ready_check: true });
|
||||
}
|
||||
|
||||
const RedisPubSub = {
|
||||
createPublisher,
|
||||
createSubscriber
|
||||
}
|
||||
createSubscriber,
|
||||
};
|
||||
|
||||
export {
|
||||
RedisPubSub
|
||||
}
|
||||
export { RedisPubSub };
|
||||
|
||||
Reference in New Issue
Block a user