Skip to main content
zerotal

Documentation


Documentation / @zerotal/broadcasting / AnonymousBroadcast

Class: AnonymousBroadcast

Defined in: broadcasting/src/AnonymousBroadcast.ts:12

Fluent builder for broadcasting without a dedicated event class. Returned by Broadcast.on() / Broadcast.private() / Broadcast.presence().

Example

Broadcast.on(`orders.${order.id}`).as("OrderPlaced").with(order).toOthers().send();
Broadcast.private(`orders.${order.id}`).as("OrderPlaced").with({ id: order.id }).send();

Constructors

Constructor

new AnonymousBroadcast(channel): AnonymousBroadcast

Defined in: broadcasting/src/AnonymousBroadcast.ts:17

Parameters

channel

string

Returns

AnonymousBroadcast

Methods

as()

as(event): this

Defined in: broadcasting/src/AnonymousBroadcast.ts:20

Set the wire event name (default "AnonymousEvent").

Parameters

event

string

Returns

this


with()

with(data): this

Defined in: broadcasting/src/AnonymousBroadcast.ts:26

Set the payload.

Parameters

data

unknown

Returns

this


toOthers()

toOthers(): this

Defined in: broadcasting/src/AnonymousBroadcast.ts:32

Exclude the originating connection (its X-Socket-ID).

Returns

this


send()

send(): void

Defined in: broadcasting/src/AnonymousBroadcast.ts:38

Broadcast now. (sendNow() is an alias; queued sending lands with the broadcast queue.)

Returns

void


sendNow()

sendNow(): void

Defined in: broadcasting/src/AnonymousBroadcast.ts:49

Broadcast immediately.

Returns

void