Luigi Pinca
Luigi Pinca
I think it is not possible to use the Node.js `EventTarget` implementation without introducing breaking changes and performance regressions. - We would need to call `ws.dispatchEvent()` every time we call...
> Or maybe yes :-) NodeEventTarget extends from `EventTarget` and implements the `EventEmitter` API on top of it. I read in the development discussion that it was specifically designed for...
I prefer to keep making `WebSocket` inherit from `EventEmitter` for now. Advantages: - No breaking changes. - No feature detection and polyfill. - The `WebSocket` class is always an `EventEmitter`...
With the introduction of e173423c180dc1e4e6ee8938d9e4376a7a8b9757 subclassing `EventTarget` would be even harder. Also the pattern used in the issue description would not work even if `WebSocket` was a subclass of `EventTarget`....
It can but you need to wait for the previous dispatch to complete.
We could do something like this diff ```diff diff --git a/lib/event-target.js b/lib/event-target.js index cc4f3ba..1da1f1a 100644 --- a/lib/event-target.js +++ b/lib/event-target.js @@ -1,21 +1,32 @@ 'use strict'; +const event = new Event('foo');...
The `once` option is already supported. See https://github.com/websockets/ws/commit/2e5c01f5b550ae4171d127b0b707ebcec5925cc3.
I would be open to that **if** [`Symbol('kTarget')`](https://github.com/nodejs/node/blob/e2a6399be742f53103474d9fc1e56fadf7f90ccc/lib/internal/event_target.js#L51) was exposed.
> Ah ok, but if I use .onmessage at the same time it doesn't seem to work IIRC It works if `websocket.addEventListener()` is used after `websocket.onmessage`. It doesn't if the...
> It's a big strange buggy mess because you tried making your own events. I respect your opinion, but I didn't do it. I've just tried to improve it. From...