-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
W3C API compatibility #18
Comments
I think that's a very natural direction for the api to take at this point. @3rd-Eden added an emulation layer for the .onmessage, .onerror etc. events, which also has an event object rather than the message being passed as first parameter for message events. Expanding the event object to hold more information (including a flag for binary) is one thing I'd like to do. Adding Would it be a fair middle way to introduce a proper event object for |
This is mostly browser vs node talk. Which API do you want to adopt and support? I would personally just keep the And just use the .onmessage as a browser compatibly layer. So you have clear separation between the two different API's and not an odd mix of both |
I like that idea. This is my understanding of what you are saying:
|
@aslakhellesoy, exactly. I don't see any problems with that. I'd welcome a pullreq, or alternatively look into it myself later this week. |
@3rd-Eden I agree that the W3C API wrapping messages in an event object is a little cumbersome, but it is the standard, and making this library follow it makes it easier to write portable code. I'm not a big fan of the IIRC, older node versions aliased |
Correction - Node's |
So should we remove |
@ikhattab Why would we remove it? The functionality still exists. |
@3rd-Eden oops sorry, my mistake. |
I'm writing a library on top of your excellent library that I'd like to use both on Node.js and in browsers. I have ran into a couple of issues with API incompatibility. The W3C API allows these two variants:
Your implementation allows:
I'm proposing 3 changes:
Event
object with adata
attributews.addEventListener(eventName, Function)
ws.onmessage = Function
This would break the current API, but it would also make it follow the official API more closely. Would you be interested in a patch for this?
Aslak
The text was updated successfully, but these errors were encountered: