Skip to content

ChangeStreamClient

Defined in: libs/runtime/src/change-stream-client.ts:102

The spoke’s side of a hub’s change stream: subscribes to the hub’s server-sent events and pushes revisions to it. Reconnects on a dropped connection, resuming from the last change it delivered.

Constructors

Name Description
new ChangeStreamClient() Creates a client for one hub.

Properties

Name Description
url Public so a replicator can read the stream once without reaching into a private field.

Accessors

Name Description
lastEventId The seq of the last change delivered, which a reconnect resumes from.

Methods

Name Description
push() Push revisions to the hub, and resolve to how many it applied.
requestHeaders() The extra headers for the next request (empty when none were configured).
subscribe() Subscribe to the hub’s change stream, handing each change to handlers.

new ChangeStreamClient(url, options?): ChangeStreamClient

Defined in: libs/runtime/src/change-stream-client.ts:114

Creates a client for one hub.

string

The hub’s base URL. Changes are read and pushed at <url>/changes.

ChangeStreamClientOptions = {}

How it retries, and the headers to send.

ChangeStreamClient

readonly url: string

Defined in: libs/runtime/src/change-stream-client.ts:116

Public so a replicator can read the stream once without reaching into a private field.

get lastEventId(): number

Defined in: libs/runtime/src/change-stream-client.ts:121

The seq of the last change delivered, which a reconnect resumes from.

number

push(records, signal?): Promise<number>

Defined in: libs/runtime/src/change-stream-client.ts:131

Push revisions to the hub, and resolve to how many it applied. The other half of duplex — SSE has no back-channel.

readonly ChangeRecord[]

AbortSignal

Promise<number>


requestHeaders(): Promise<Record<string, string>>

Defined in: libs/runtime/src/change-stream-client.ts:126

The extra headers for the next request (empty when none were configured).

Promise<Record<string, string>>


subscribe(handlers, from?): ChangeStreamSubscription

Defined in: libs/runtime/src/change-stream-client.ts:153

Subscribe to the hub’s change stream, handing each change to handlers. Reconnects on a dropped connection, resuming from Last-Event-ID.

ChangeStreamHandlers

number = 0

ChangeStreamSubscription

TypeDBLite is an independent open-source project, built on TypeDB with thanks. It is not affiliated with, sponsored by, or endorsed by TypeDB Ltd. Released under the MPL-2.0 license.