Skip to content

4.0.0

Compare
Choose a tag to compare
@darrachequesne darrachequesne released this 17 Mar 23:00
· 11 commits to master since this release
c371414

Features

  • allow excluding all sockets in a room (#92) (ad920e4)
  • include features from Socket.IO v4 (a70db12)
  • rename the package to @socket/redis-emitter (592883e)

BREAKING CHANGES

  • the name of the package was updated from socket.io-emitter to @socket.io/redis-emitter in order to better reflect the relationship with Redis

  • the "redis" package is not installed by default anymore, you'll now need to create your own redis client and pass it to the Emitter constructor

Before:

const io = require("socket.io-emitter")({ host: "127.0.0.1", port: 6379 });

After:

const { Emitter } = require("@socket.io/redis-emitter");
const { createClient } = require("redis");

const redisClient = createClient();
const io = new Emitter(redisClient);
  • io.to() is now immutable

Previously, broadcasting to a given room (by calling io.to()) would mutate the io instance, which could lead to surprising behaviors, like:

io.to("room1");
io.to("room2").emit(/* ... */); // also sent to room1

// or with async/await
io.to("room3").emit("details", await fetchDetails()); // random behavior: maybe in room3, maybe to all clients

Calling io.to() (or any other broadcast modifier) will now return an immutable instance.

Diff: 3.2.0...4.0.0