Skip to content

remove dep 'component-emitter'#20

Merged
jondubois merged 1 commit into
SocketCluster:masterfrom
initial-wu:master
Oct 21, 2017
Merged

remove dep 'component-emitter'#20
jondubois merged 1 commit into
SocketCluster:masterfrom
initial-wu:master

Conversation

@initial-wu

Copy link
Copy Markdown

No description provided.

@jondubois jondubois merged commit 7e94e3a into SocketCluster:master Oct 21, 2017
@jondubois

jondubois commented Oct 21, 2017

Copy link
Copy Markdown
Member

@initial-wu I had to roll back this change because sc-channel is a dependency of SC on both the client and server-side and it inherits from component-emitter (since EventEmitter cannot be used on the client-side). So for consistency I think we should stick with component-emitter for now.

Is there a technical reason why you want to remove component-emitter as a dependency?
It's possible (and worth considering) but it will be more work.

@initial-wu

Copy link
Copy Markdown
Author

var EventEmitter = require('events').EventEmitter;

@jondubois

jondubois commented Oct 22, 2017

Copy link
Copy Markdown
Member

@initial-wu Right now the philosophy is that front-end and isomorphic modules inherit from the component-emitter Emitter (regardless of if they are running on the client or server) but pure server-side modules inherit from EventEmitter.

The server-side SCSocket is not strictly an isomorphic module but because it shares a lot of functionality with the client-side SCSocket (which is isomorphic), I thought it would be best if they are consistent.

That said, I think the way things are right now is definitely confusing... Maybe we should split up the sc-channel module into two separate ones; client and server versions; that way the SCChannel doesn't need to be isomorphic and that lets us be more consistent (use EventEmitter everywhere on the backend and Emitter everywhere on the frontend).

Note that this is still slightly confusing because client-side != frontend (e.g. you can run socketcluster-client inside Node.js on the backend)... But I guess it's less confusing.

Dynamically checking if the module is running in the browser vs server at runtime (and requiring Emitter vs EventEmitter based on that) is likely to be messy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants