Skip to main content

SubscribeMessageRangeArgs

type SubscribeMessageRangeArgs = object;

This type represents the arguments you pass to PanelExtensionContext.subscribeMessageRange.

Properties

topic

topic: string;

Topic to be subscribed to.


convertTo?

optional convertTo: string;

Convert messages to this schema before delivering to the subscriber.

MessageEvents for the subscription will contain the converted message and an originalMessageEvent field with the original message event. If no convertTo schema is specified, then no message converters will be used. If no message converter exists for converting the original schema to the convertTo schema, then no messages are delivered for this subscription.


onNewRangeIterator()

onNewRangeIterator: (batchIterator) => Promise<void>;

onNewRangeIterator is a function that receives an async iterable when there is message data available on the subscription.

To read messages, your function should iterate through the provided async iterable. Each item of the iterable is a batch of message events for the subscription's topic. These batches and messages are in log time order. When there are no more messages to read the iterator will finish.

async function onNewRangeIterator(batchIterator) {
for await (const batch of batchIterator) {
//...
}
}

onNewRangeIterator is called again when the upstream topic data changes. I.E subscribing to a user-script output topic and the user script changes, or subscribing to an aliased topic and the alias changes. When topic data changes, the previous iterator will end, and its data is no longer valid. When onNewRangeIterator is called, you should discard previously received data.

If your onNewRangeIterator function throws an error, the iterator will end and you will not receive any more messages until onNewRangeIterator is called again. Your error will appear in the problems sidebar for user visibility.

Parameters

ParameterType
batchIteratorAsyncIterable<Immutable<MessageEvent[]>>

Returns

Promise<void>


onReset()?

optional onReset: (batchIterator) => Promise<void>;

Parameters

ParameterType
batchIteratorAsyncIterable<Immutable<MessageEvent[]>>

Returns

Promise<void>

Deprecated

This method has been renamed. Use onNewRangeIterator.