Expand description
interface WxEnd {
close: () => void;
isClosed: () => boolean;
onClose: (callback: () => void) => () => void;
send: (message: WxMessage) => WxVoid;
}Properties§
§§§§
close: { ... }Mark the channel as closed and unregisters all message handlers registered by the end. If handshake is still in progress, it will be aborted.
is Closed: { ... }Check if the end is closed
on Close: { ... }Add a subscriber to the close event. The subscriber will be called when the end is closed at most once
send: { ... }Send a message to the other end
Messaging primitive representing one end of an established messaging channel
This is an abstraction of the underlying messaging channel, be it a
Worker,Window, or possiblyWebSocketor HTTP requests in the future.Workex provides factory functions for creating
WxEnds for different messaging channels. Note that sinceWxEndis an abstraction over an established channel, the design pattern is that any validWxEndobjects you create with functions in this library will first establish the handshake.