Skip to main content

Class: Stream

A convenience API for managing and accessing an individual stream.

Properties

id

Readonly id: StreamID

Important Methods

addToStorageNode

addToStorageNode(storageNodeAddress, waitOptions?): Promise\<void>

Assigns the stream to a storage node.

Parameters

NameTypeDescription
storageNodeAddressstring-
waitOptionsObjectcontrol how long to wait for storage node to pick up on assignment
waitOptions.timeout?number-

Returns

Promise\<void>

a resolved promise if (1) stream was assigned to storage node and (2) the storage node acknowledged the assignment within timeout, otherwise rejects. Notice that is possible for this promise to reject but for the storage node assignment to go through eventually.


getPermissions

getPermissions(): Promise\<PermissionAssignment[]>

See StreamrClient.getPermissions.

Returns

Promise\<PermissionAssignment[]>


grantPermissions

grantPermissions(...assignments): Promise\<void>

See StreamrClient.grantPermissions.

Parameters

NameType
...assignmentsPermissionAssignment[]

Returns

Promise\<void>


hasPermission

hasPermission(query): Promise\<boolean>

See StreamrClient.hasPermission.

Parameters

NameType
queryOmit\<UserPermissionQuery, "streamId"> | Omit\<PublicPermissionQuery, "streamId">

Returns

Promise\<boolean>


publish

publish(content, metadata?): Promise\<Message>

See StreamrClient.publish.

Parameters

NameType
contentunknown
metadata?PublishMetadata

Returns

Promise\<Message>


revokePermissions

revokePermissions(...assignments): Promise\<void>

See StreamrClient.revokePermissions.

Parameters

NameType
...assignmentsPermissionAssignment[]

Returns

Promise\<void>


Other Methods

delete

delete(): Promise\<void>

Deletes the stream.

Returns

Promise\<void>

Remarks

Stream instance should not be used afterwards.


detectFields

detectFields(): Promise\<void>

Attempts to detect and update the config metadata of the stream by performing a resend.

Returns

Promise\<void>

be mindful that in the case of there being zero messages stored, the returned promise will resolve even though fields were not updated

Remarks

Only works on stored streams.


getMetadata

getMetadata(): StreamMetadata

Returns the metadata of the stream.

Returns

StreamMetadata


getStorageNodes

getStorageNodes(): Promise\<string[]>

See StreamrClient.getStorageNodes.

Returns

Promise\<string[]>


getStreamParts

getStreamParts(): StreamPartID[]

Returns the partitions of the stream.

Returns

StreamPartID[]


removeFromStorageNode

removeFromStorageNode(nodeAddress): Promise\<void>

See StreamrClient.removeStreamFromStorageNode.

Parameters

NameType
nodeAddressstring

Returns

Promise\<void>


update

update(metadata): Promise\<void>

Updates the metadata of the stream by merging with the existing metadata.

Parameters

NameType
metadataPartial\<StreamMetadata>

Returns

Promise\<void>