Skip to main content

Class: TopicHandle<T>

Experimental

Client-side handle for publishing to and subscribing from a single topic.

Constructed via WorkflowStreamClient.topic. Publishes share the underlying client's batching, dedup, and codec path; this object holds only the topic name and the type binding.

Type Parameters​

T​

T = unknown

Properties​

name​

readonly name: string

Experimental

Methods​

publish()​

publish(value, options?): void

Experimental

Buffer value for publishing on this topic.

Equivalent to the underlying client's publish path; the value flows through the same buffer, batch interval, and dedup sequence.

Parameters​

value​

IPayload | T

Value to publish. Goes through the client's payload converter at flush time. A pre-built Payload bypasses conversion (zero-copy fast path), regardless of the handle's bound type.

options?​
forceFlush?​

boolean

If true, wake the flusher to send immediately (fire-and-forget — does not block the caller).

Returns​

void


subscribe()​

subscribe(fromOffset?, options?): AsyncGenerator<WorkflowStreamItem<T>, void, unknown>

Experimental

Async iterator over items on this topic, decoded as T via the client's configured payload converter (custom converter on the underlying Client flows through; otherwise the default).

For raw Payload access, or any other decode path that differs from the handle's bound T, call WorkflowStreamClient.subscribe directly — it yields WorkflowStreamItem<Payload>.

Parameters​

fromOffset?​

number

Global offset to start reading from.

options?​

SubscribeOptions

Returns​

AsyncGenerator<WorkflowStreamItem<T>, void, unknown>