bcoin-org / bcoin-org/bsock

`on` vs `bind`

Open
#7 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9
Forks
7
PR merge metrics
No merged PRs in 30d

Description

It's odd that `Socket` inherits from EventEmitter but implements its own event cycle with `bind`

https://github.com/bcoin-org/bsock/blob/master/lib/socket.js#L19

https://github.com/bcoin-org/bsock/blob/master/lib/socket.js#L837-L887

I raise this issue because I was mistakenly using `on` and not `bind` so events we're firing, but there is something odd about the implementation as such, its managing two lifecycles one on the Socket, one internally on Events.

Perhaps as a solution, `on` could proxy to `bind` when sensible to maintain a consistent event emitter implementation

Contributor guide

No contributing guide indexed for this repository

Research direction

Read lib/socket.js at lines 19 and 837-887, then compare Socket's inherited EventEmitter behavior with its internal bind-based event lifecycle. Clarify whether on should proxy to bind and define how event registration and emission should remain consistent; validate the chosen behavior against the existing socket event flow.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
networking
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.