socket.io
socket.io copied to clipboard
comment: write js docs in on
The kind of change this PR does introduce
- [ ] a bug fix
- [x] a new feature
- [ ] an update to the documentation
- [ ] a code change that improves performance
- [x] other
Current behavior
- About
socket-io-client-emitter/Emitteronmethod. - It was difficult for us to know what the reserved event names were without looking at the docs.
New behavior
- I thought it would be better to use JSDoc without changing the types. This is because there is an advantage of auto-completion when using union, etc., but developers often use custom event names, so I thought the type could actually cause confusion.
- So I used JSDoc. If the user checks the JSDoc, they can see the scheduled event name and its brief description. If developers are curious about more, I have linked the docs.
Other information (e.g. related issues)
- If you want to edit, change or delete content, please always leave a comment.
- I've only written about
onat the moment, so if you think it would be good to write about something else as well, please let me know.
Hi! Thanks a lot for your PR.
I'm not sure this is right though, as the emitter provided by the @socket.io/component-emitter is used in several places, not just for the Socket object of the socket.io-client package.
Another possibility would be to override the on method in the Socket class, and add the improved documentation there. What do you think?
@darrachequesne There is a way like that! I also think this is better.
Hi. I commit this. Is this correct what you said?
- I was confused about where to place the overridden method. First of all, since it is a new change, I placed it at the very bottom.
- I am wondering how to use the
ReversedEventstype defined as a generic in theEmitter. Basically, it simply inherits EventMaps, so I created a new interface:interface ReservedEvents extends EventsMap {}. However, there remains a question as to whether this will ensure a consistent type with the on of theEmiiterin the future.
If it doesn't fit your intention, or if you have any comments, please let me know!