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, decoder, contentTopicUpdater?)

Type parameters

Name
T

Parameters

NameType
clientClient
topicsstring[]
decoderMessageDecoder<T>
contentTopicUpdater?ContentTopicUpdater<T>

Defined in

Stream.ts:28

Properties

callback

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

Defined in

Stream.ts:24


client

client: Client

Defined in

Stream.ts:17


messages

messages: T[]

Defined in

Stream.ts:19


resolvers

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

Defined in

Stream.ts:21


topics

topics: string[]

Defined in

Stream.ts:16


unsubscribeFn

Optional unsubscribeFn: UnsubscribeFn

Defined in

Stream.ts:26

Methods

[asyncIterator]

[asyncIterator](): AsyncIterableIterator<T>

Returns

AsyncIterableIterator<T>

Defined in

Stream.ts:106


newMessageCallback

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

Parameters

NameType
decoderMessageDecoder<T>
contentTopicUpdater?ContentTopicUpdater<T>

Returns

fn

(env): Promise<void>

Parameters
NameType
envEnvelope
Returns

Promise<void>

Defined in

Stream.ts:42


next

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

Returns

Promise<IteratorResult<T, any>>

Defined in

Stream.ts:131


resubscribeToTopics

Private resubscribeToTopics(topics): Promise<void>

Parameters

NameType
topicsstring[]

Returns

Promise<void>

Defined in

Stream.ts:146


return

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

Returns

Promise<IteratorResult<T, any>>

Defined in

Stream.ts:114


start

Private start(): Promise<void>

Returns

Promise<void>

Defined in

Stream.ts:78


create

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

Type parameters

Name
T

Parameters

NameType
clientClient
topicsstring[]
decoderMessageDecoder<T>
contentTopicUpdater?ContentTopicUpdater<T>

Returns

Promise<Stream<T>>

Defined in

Stream.ts:94