Skip to content

Comments

feat(socket.io): allow passing a Set to to(), in(), and except()#5459

Open
Not-Sarthak wants to merge 1 commit intosocketio:mainfrom
Not-Sarthak:feat/to-accept-set
Open

feat(socket.io): allow passing a Set to to(), in(), and except()#5459
Not-Sarthak wants to merge 1 commit intosocketio:mainfrom
Not-Sarthak:feat/to-accept-set

Conversation

@Not-Sarthak
Copy link

Summary

Closes #5418

The to(), in(), and except() methods now accept Set<Room> in addition to Room and Room[]. This is a natural extension of the array support added in 085d1de.

// before (workaround needed)
const rooms = new Set(["room1", "room2"]);
io.to(Array.from(rooms)).emit("hello");

// after
io.to(rooms).emit("hello");

Updated across all entry points: BroadcastOperator, Namespace, Socket, and Server.

Test plan

  • Added test: "emits to rooms with a Set"
  • All 204 socket.io unit tests pass
  • Type tests (tsd) pass
  • Formatting checks pass

The to(), in(), and except() methods now accept Set<Room> in addition
to Room and Room[]. This avoids the need for Array.from() when working
with Sets of rooms.

Closes socketio#5418
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send message to a Set<Room>

1 participant