4.0.0
版本发布时间: 2021-03-10 19:49:47
socketio/socket.io最新发布版本:2.5.1(2024-06-19 17:36:33)
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:
- Diff: https://github.com/socketio/socket.io/compare/3.1.2...4.0.0
- Client release: 4.0.0
- engine.io version:
~5.0.0
- ws version:
~7.4.2