Skip to main content

Stream

Class: Stream<T>

Stream implements an Asynchronous Iterable over messages received from a topic. As such can be used with constructs like for-await-of, yield*, array destructing, etc.

Type parameters

Name
T

Constructors

constructor

new Stream<T>(client, topics, messageTransformer, messageFilter?, contentTopicUpdater?)

Type parameters

Name
T

Parameters

NameType
clientClient
topicsstring[]
messageTransformerMessageTransformer<T>
messageFilter?MessageFilter
contentTopicUpdater?ContentTopicUpdater

Defined in

Stream.ts:33

Properties

callback

callback: undefined | (env: Envelope) => Promise<void>

Defined in

Stream.ts:29


client

client: Client

Defined in

Stream.ts:22


messages

messages: T[]

Defined in

Stream.ts:24


resolvers

resolvers: (value: IteratorResult<T, any>) => void[]

Defined in

Stream.ts:26


topics

topics: string[]

Defined in

Stream.ts:21


unsubscribeFn

Optional unsubscribeFn: UnsubscribeFn

Defined in

Stream.ts:31

Methods

[asyncIterator]

[asyncIterator](): AsyncIterableIterator<T>

Returns

AsyncIterableIterator<T>

Defined in

Stream.ts:123


newMessageCallback

Private newMessageCallback(transformer, filter?, contentTopicUpdater?): (env: Envelope) => Promise<void>

Parameters

NameType
transformerMessageTransformer<T>
filter?MessageFilter
contentTopicUpdater?ContentTopicUpdater

Returns

fn

(env): Promise<void>

Parameters
NameType
envEnvelope
Returns

Promise<void>

Defined in

Stream.ts:52


next

next(): Promise<IteratorResult<T, any>>

Returns

Promise<IteratorResult<T, any>>

Defined in

Stream.ts:148


resubscribeToTopics

Private resubscribeToTopics(topics): Promise<void>

Parameters

NameType
topicsstring[]

Returns

Promise<void>

Defined in

Stream.ts:163


return

return(): Promise<IteratorResult<T, any>>

Returns

Promise<IteratorResult<T, any>>

Defined in

Stream.ts:131


start

Private start(): Promise<void>

Returns

Promise<void>

Defined in

Stream.ts:88


create

Static create<T>(client, topics, messageTransformer, messageFilter?, contentTopicUpdater?): Promise<Stream<T>>

Type parameters

Name
T

Parameters

NameType
clientClient
topicsstring[]
messageTransformerMessageTransformer<T>
messageFilter?MessageFilter
contentTopicUpdater?ContentTopicUpdater

Returns

Promise<Stream<T>>

Defined in

Stream.ts:104