Skip to content

4.0.0

Compare
Choose a tag to compare
@darrachequesne darrachequesne released this 10 Mar 11:49
· 72 commits to master since this release
5eaeffc

Blog post: https://socket.io/blog/socket-io-4-release/
Migration guide: https://socket.io/docs/v3/migrating-from-3-x-to-4-0/

Bug Fixes

  • make io.to(...) immutable (ac9e8ca)

Features

  • add some utility methods (b25495c)
  • add support for typed events (#3822) (0107510)
  • allow to exclude specific rooms when broadcasting (#3789) (7de2e87)
  • allow to pass an array to io.to(...) (085d1de)

BREAKING CHANGES

  • io.to(...) now returns an immutable operator

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.

Links: