Closed MickL closed 3 years ago
Hi! I could not reproduce the issue, both examples seem to work.
That's a bit weird though:
hiredis
is indeed required here: https://github.com/NodeRedis/node-redis-parser/blob/v.2.6.0/lib/hiredis.js#L3But hiredis
is not in the dependencies
of the redis-parser
package...
should redis be a peerDependency?
I think it should even be in the devDependencies
list, and let the user provide its own redis client.
const io = require('socket.io-emitter')(redisClient, { /* additional options */});
But this change would need to be well documented..
I already have Redis in my project (v3) and socket.io-emitter imports v2 so I have two instances running.
You should be able to create the emitter instance with a redis client v3 (the example above).
The problem are the dependencies: I already have redis v3 in my project and this package imports redis v2. If I change redis for this package to v3 then it works.
I think redis should at least be a peerDependency
Hey @darrachequesne I see you updated the readme. Can we still remove redis from the dependencies and force the user to insert a client?
Yes, let's do this :+1:
Done in https://github.com/socketio/socket.io-emitter/commit/a70db12877d901dd0f7085def0a91145b7c83163.
You'll now need to explicitly install the redis
package (or another compatible package like ioredis), and pass it in the Emitter constructor:
const { Emitter } = require("socket.io-emitter");
const { createClient } = require("redis");
const redisClient = createClient();
const io = new Emitter(redisClient);
Thats nice! I did the same at nats-emitter https://github.com/MickL/socket.io-nats-emitter#readme
May you add an example how to use with TypeScript? I tried both:
and
but i get:
Btw. should
redis
be a peerDependency? I already have Redis in my project (v3) and socket.io-emitter imports v2 so I have two instances running.