Primitives / API

foldkit-primitives/net

Namespaces

SharedHostOne server in the browser for many documents: every tab and frame of an application meets the same host. A page opens conversations, each a MessagePort with…

Functions

broadcastMessagesEvery post to name from another channel, as Messages. Without a BroadcastChannel API the stream is empty instead of throwing; closing the stream closes the…
isLiveWhether the stream is live: open with no error outstanding. The browser reconnects a dropped stream itself; a Failed only records the error.
isOpenWhether the socket is usable: open with no error outstanding. Gates sends and received frames.
postBroadcastPosts one message to name. Opens a channel, posts, and closes it: the send is one-shot, so it is a Command, not a resource. Without a BroadcastChannel API —…
sseServer-sent events as a bundle: connection lifecycle in the Model, the event stream through one Managed Resource. One-directional, so there is no send: the…
viewOfThe view of a socket, and whether its page still wants it. An error stands until the page stops wanting the socket; a retry still waiting for its socket…
viewOfSseThe view of a stream, and whether its page still wants it. An error stands until the page stops wanting the stream; a retry still waiting for its stream…
websocketA WebSocket as a bundle: connection lifecycle in the Model, full duplex through one Managed Resource. The resource owns the socket; a send helper writes…

Values

BroadcastMessage
OnlineOnline presence as a bundle: online in the Model, kept current by the window's online/offline events. The browser reports facts; the Model owns the state,…
OnlineMessage
OnlineModel
SocketThe live connection, for send and the incoming stream. One assembly holds one.
SocketViewWhat the reader sees: the socket's state, or its error. A page derives this instead of keeping its own connection state machine. lastError is already worded…
SourceThe live stream, for the incoming subscription. One assembly holds one.
SseMessage
SseModel
SseViewWhat the reader sees: the stream's state, or its error. A page derives this instead of keeping its own connection state machine. lastError carries the…
WebSocketMessage
WebSocketModel

Interfaces

AcquiredThe registry value behind the socket tag: the live socket and its incoming queue.
AcquiredSourceThe registry value behind the source tag: the live source and its incoming queue.
BroadcastChannelHandleThe slice of a BroadcastChannel this module needs; satisfied by the platform class.
ConversationOne conversation a page opened: its port, and a signal that aborts once the page is gone.
SharedHostConnectionA page's way to the host.
SharedHostOptionsWhere SharedHost runs the host: in a SharedWorker, or in the page when there is none.
SocketHandleThe slice of a WebSocket the bundle needs; satisfied by the platform socket and test doubles. Handler events are any: the DOM and ws type them differently,…
SourceHandleThe slice of an EventSource the bundle needs; satisfied by the platform class.

Types

ConversationHandlerWhat the host does with each conversation, told what the page opened it for.
SocketServiceThe socket service a placed WebSocket's streams and send commands require.
SourceServiceThe source service a placed SSE stream requires.
StartHostStarts the host, once, the first time a conversation needs it.