LiveEventSource class
Broadcasts live share events to all clients and can be received by an LiveEventTarget
.
Remarks
Live objects won't typically create an LiveEventSource
directly. They will, instead,
create an LiveEventTarget
class, which can both send & receive events.
Constructors
Live |
Creates a new |
Methods
send |
Broadcasts an event to any listening |
send |
Same as |
Constructor Details
LiveEventSource<TEvent>(LiveEventScope, string)
Creates a new LiveEventSource
instance.
new LiveEventSource(scope: LiveEventScope, eventName: string)
Parameters
- scope
- LiveEventScope
Scope to use for sending events.
- eventName
-
string
Name of the event to broadcast.
Method Details
sendEvent(TEvent)
Broadcasts an event to any listening LiveEventTarget
instances.
function sendEvent(evt: TEvent): Promise<ILiveEvent<TEvent>>
Parameters
- evt
-
TEvent
Optional. Partial event object to send. The ILiveEvent.name
,
ILiveEvent.timestamp
, and ILiveEvent.clientId
fields will be automatically populated prior to sending.
Returns
Promise<ILiveEvent<TEvent>>
The full event, including ILiveEvent.name
,
ILiveEvent.timestamp
, and ILiveEvent.clientId
fields if known.
sendLocalEvent(TEvent)
Same as SendEvent
but only sent locally. Useful for events that do not need to be sent as a signal.
function sendLocalEvent(evt: TEvent): Promise<ILiveEvent<TEvent>>
Parameters
- evt
-
TEvent
Optional. Partial event object. The ILiveEvent.name
,
ILiveEvent.timestamp
, and ILiveEvent.clientId
fields will be automatically populated.
Returns
Promise<ILiveEvent<TEvent>>
The full event, including ILiveEvent.name
,
ILiveEvent.timestamp
, and ILiveEvent.clientId
fields if known.