socketio / socketio/socket.io

Docs: Document `io.on`, `io.use` etc in the Server API docs

Open
#4,608 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
TypeScript
Stars
63.2k
Forks
10.3k
Avg merge
11d 20h
Merged PRs (30d)
2

Description

https://socket.io/docs/v4/server-api/ shows some examples of .e.g io.use(), but it never explains what they are.

https://socket.io/docs/v4/namespaces/#main-namespace explains that all those versions are interacting with the main namespace:

io.on("connection", (socket) => {});
io.use((socket, next) => { next() });
io.emit("hello");
// are actually equivalent to
io.of("/").on("connection", (socket) => {});
io.of("/").use((socket, next) => { next() });
io.of("/").emit("hello");

A section in the Server API docs should preferably document all these, as they are part of the API of io but never explained there.

(If I could chose, I would in version 5 actually remove the direct usage of those and only allow io.of() as I believe explicit-over-implicit is good in this case and also simplifies a lot of documentation and explanation around this. But that is highly subjective and I am sure others like the shortcuts).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the Server API documentation at https://socket.io/docs/v4/server-api/ and compare it with the main namespace explanation at https://socket.io/docs/v4/namespaces/#main-namespace. Document the direct io.on(), io.use(), io.emit(), and related APIs, including their io.of("/") equivalents; done means the Server API page explains these shortcuts rather than only showing examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
api, documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.