Skip to content

@oneplatform/sdk


@oneplatform/sdk / Subscription

Interface: Subscription

Defined in: packages/sdk/src/types/subscription.ts:49

Properties

id

readonly id: string

Defined in: packages/sdk/src/types/subscription.ts:51

Server-assigned subscription ID (from the first 'connected' SSE event).


lastEventId

readonly lastEventId: string | null

Defined in: packages/sdk/src/types/subscription.ts:57

Last event ID received. Used for reconnection resumption.


status

readonly status: "connecting" | "connected" | "reconnecting" | "closed"

Defined in: packages/sdk/src/types/subscription.ts:54

Current connection lifecycle state.

Methods

on()

Call Signature

on(event, handler): this

Defined in: packages/sdk/src/types/subscription.ts:63

Register a listener for status changes.

Parameters
event

"status"

handler

(status) => void

Returns

this

Call Signature

on(event, handler): this

Defined in: packages/sdk/src/types/subscription.ts:70

Register a listener for connection errors (emitted before reconnect attempts). AuthError is emitted for 401 responses — the subscription closes immediately in that case and no reconnection is attempted.

Parameters
event

"error"

handler

(error) => void

Returns

this


unsubscribe()

unsubscribe(): void

Defined in: packages/sdk/src/types/subscription.ts:60

Terminate the subscription and close the SSE connection.

Returns

void