Skip to main content
Version: Current

BroadcastChannel

@rotorsoft/act-root


@rotorsoft/act-root / act-http/src/sse / BroadcastChannel

Class: BroadcastChannel<S>

Defined in: libs/act-http/src/sse/broadcast.ts:68

Type Parametersโ€‹

Sโ€‹

S extends BroadcastState = BroadcastState

Constructorsโ€‹

Constructorโ€‹

new BroadcastChannel<S>(options?): BroadcastChannel<S>

Defined in: libs/act-http/src/sse/broadcast.ts:79

Parametersโ€‹

options?โ€‹
cache_size?โ€‹

number

Deprecated alias of cacheSize โ€” removal in the next major. When both are given, cacheSize wins.

Deprecated

use cacheSize

cacheSize?โ€‹

number

onOverlayMiss?โ€‹

(streamId) => void

Called when overlay() finds no cached baseline for the stream, so the update cannot be broadcast. Live subscribers receive nothing and have no way to notice โ€” a host that cares should raise cacheSize, re-publish the stream, or push the viewers to refetch. Defaults to a no-op so existing behavior is unchanged apart from being observable.

onSubscriberError?โ€‹

(error, streamId) => void

Called when a subscriber callback throws. The frame is still delivered to every other subscriber and the publish still returns normally โ€” a bad consumer must not break the publisher (#1423). Defaults to the framework's log() port, so it lands wherever the host already routes framework logs.

Returnsโ€‹

BroadcastChannel<S>

Accessorsโ€‹

cacheโ€‹

Get Signatureโ€‹

get cache(): StateCache<S>

Defined in: libs/act-http/src/sse/broadcast.ts:232

Direct access to the state cache (for app-specific reads like presence).

Returnsโ€‹

StateCache<S>

Methodsโ€‹

get_state()โ€‹

get_state(streamId): S | undefined

Defined in: libs/act-http/src/sse/broadcast.ts:227

Parametersโ€‹

streamIdโ€‹

string

Returnsโ€‹

S | undefined

Deprecatedโ€‹

use state โ€” removal in the next major


get_subscriber_count()โ€‹

get_subscriber_count(streamId): number

Defined in: libs/act-http/src/sse/broadcast.ts:222

Parametersโ€‹

streamIdโ€‹

string

Returnsโ€‹

number

Deprecatedโ€‹

use subscriberCount โ€” removal in the next major


overlay()โ€‹

overlay(streamId, overlay_patch): PatchMessage<S> | undefined

Defined in: libs/act-http/src/sse/broadcast.ts:146

Publish a state update that doesn't change the event version (e.g. presence overlay, computed field refresh). Uses the same version as the cached state, single entry.

Parametersโ€‹

streamIdโ€‹

string

overlay_patchโ€‹

Partial<S>

Returnsโ€‹

PatchMessage<S> | undefined


publish()โ€‹

publish(streamId, state, patches?): PatchMessage<S>

Defined in: libs/act-http/src/sse/broadcast.ts:122

Publish domain patches from a commit. patches[i] corresponds to version baseV + i + 1.

Parametersโ€‹

streamIdโ€‹

string

The event store stream ID

stateโ€‹

S

Full state with _v set from snap.event.version

patches?โ€‹

Partial<S>[] = []

Array of domain patches, one per emitted event

Returnsโ€‹

PatchMessage<S>


publish_overlay()โ€‹

publish_overlay(streamId, overlay_patch): PatchMessage<S> | undefined

Defined in: libs/act-http/src/sse/broadcast.ts:214

Parametersโ€‹

streamIdโ€‹

string

overlay_patchโ€‹

Partial<S>

Returnsโ€‹

PatchMessage<S> | undefined

Deprecatedโ€‹

use overlay โ€” removal in the next major


state()โ€‹

state(streamId): S | undefined

Defined in: libs/act-http/src/sse/broadcast.ts:209

Get the cached state for a stream (for reconnects / initial SSE yield).

Parametersโ€‹

streamIdโ€‹

string

Returnsโ€‹

S | undefined


subscribe()โ€‹

subscribe(streamId, cb): () => void

Defined in: libs/act-http/src/sse/broadcast.ts:192

Subscribe to broadcast messages for a stream. Returns a cleanup function that removes the subscription.

Parametersโ€‹

streamIdโ€‹

string

cbโ€‹

Subscriber<S>

Returnsโ€‹

() => void


subscriberCount()โ€‹

subscriberCount(streamId): number

Defined in: libs/act-http/src/sse/broadcast.ts:204

Get the number of subscribers for a stream.

Parametersโ€‹

streamIdโ€‹

string

Returnsโ€‹

number