Skip to content

ChatNotificationsClient

Defined in: core/client.ts:44

Subscribes to a user’s own Chat realtime notifications (message.created, typing, presence.updated — see docs/notifications.md) without depending on any external library. Talks to the backend’s context-scoped GET /tenants/:tenant_id/applications/:application_id/notifications/realtime-token endpoint to get a ready-to-open stream URL — the backend does the realtime vendor’s entire handshake server-side, so this class never knows or cares which vendor is behind it — then opens it with the browser’s native EventSource. No vendor SDK, no vendor config, no bundle-size cost, no vendor-specific type ever appears in this class’s public surface.

One connection always carries the caller’s personal channel and the broadcast topics of the CHANNEL conversations they are a member of, plus (optionally) one more PUBLIC CHANNEL conversation via subscribeToConversation/unsubscribeFromConversation — matching the backend’s realtime-token?conversation_id=<id> capability, which accepts only one conversation id at a time. Changing that, or a proactive token refresh, closes and reopens the stream — SSE has no way to add/remove channels on a live connection.

The same reopen happens automatically when this user gains a CHANNEL conversation (a conversation.created for a CHANNEL, or their own member.added), since the current stream’s credential predates that membership and so lacks the conversation’s broadcast topic.

new ChatNotificationsClient(options): ChatNotificationsClient

Defined in: core/client.ts:64

ChatNotificationsClientOptions

ChatNotificationsClient

get connectionState(): ConnectionState

Defined in: core/client.ts:97

ConnectionState

on<K>(event, handler): Unsubscribe

Defined in: core/client.ts:101

K extends keyof ChatNotificationEventMap | "connectionStateChange"

K

(payload) => void

Unsubscribe


connect(): void

Defined in: core/client.ts:105

void


disconnect(): void

Defined in: core/client.ts:114

void


subscribeToConversation(conversationId): void

Defined in: core/client.ts:124

Adds one CHANNEL conversation’s broadcast topic (e.g. a PUBLIC channel being viewed) — replaces any previously added one.

string

void


unsubscribeFromConversation(conversationId): void

Defined in: core/client.ts:134

string

void