Class: Stream

Stream

A Sync primitive for pub-sub messaging. Stream Messages are not persisted, exist only in transit, and will be dropped if (due to congestion or network anomalies) they cannot be delivered promptly.

Properties:
Name Type Argument Default Description
sid String The immutable system-assigned identifier of this stream. Never null.
uniqueName String <optional>
null A unique identifier optionally assigned to the stream on creation.
Fires:

Methods


publishMessage(value)

Publish a Message to the Stream. The system will attempt delivery to all online subscribers.
Parameters:
Name Type Description
value Object The body of the dispatched message. Maximum size in serialized JSON: 4KB. A rate limit applies to this operation, refer to the Sync API documentation for details.
Returns:
A promise which resolves after the message is successfully published to the Sync service. Resolves irrespective of ultimate delivery to any subscribers.
Type
Promise.<StreamMessage>

removeStream()

Permanently delete this Stream.
Returns:
A promise which resolves after the Stream is successfully deleted.
Type
Promise.<void>

Events


messagePublished

Fired when a Message is published to the Stream either locally or by a remote actor
Parameters:
Name Type Description
args Object Arguments provided with the event
Properties
Name Type Description
message StreamMessage Published message
isLocal Boolean Equals 'true' if message was published by local code, 'false' otherwise

removed

Fired when a stream is removed entirely, whether the remover was local or remote.
Parameters:
Name Type Description
args Object Arguments provided with the event
Properties
Name Type Description
isLocal Boolean Equals 'true' if stream was removed by local code, 'false' otherwise