-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
fix(WebSocket): exports client connection protocol, transport, renames types #509
Conversation
import { WebSocketMessageListener } from './WebSocketOverride' | ||
import { bindEvent } from './utils/bindEvent' | ||
import { CloseEvent } from './utils/events' | ||
import { uuidv4 } from '../../utils/uuid' | ||
|
||
const kEmitter = Symbol('kEmitter') | ||
|
||
export interface WebSocketClientConnectionProtocol { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exporting this protocol means that other consumers, like MSW, can implement custom client connection-like classes. For example, to support .clients
in the browser, MSW creates virtual connection objects that use BroadcastChannel
to implement methods like send()
(signal other clients from other runtimes that they should now receive data).
/** | ||
* The WebSocket client instance represents an incoming | ||
* client connection. The user can control the connection, | ||
* send and receive events. | ||
*/ | ||
export class WebSocketClientConnection { | ||
export class WebSocketClientConnection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extending this class itself to implement connection-like objects is inefficient. It requires to provide a bunch of irrelevant properties, like kEmitter
, socket
, and transport
. Those are internal details of this class but extending it means providing those internal details also.
Released: v0.26.5 🎉This has been released in v0.26.5! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
No description provided.