Skip to main content

Class: FhircastConnection

A class representing a FHIRcast connection.

FhircastConnection extends EventTarget and emits 3 lifecycle events:

  1. connect - An event to signal when a WebSocket connection has been opened. Fired as soon as a WebSocket emits open.
  2. message - Contains a payload field containing a FHIRcast message payload exactly as it comes in over WebSockets.
  3. disconnect - An event to signal when a WebSocket connection has been closed. Fired as soon as a WebSocket emits close.

To close the connection, call connection.disconnect() and listen to the disconnect event to know when the connection has been disconnected.

Hierarchy

Constructors

constructor

new FhircastConnection(subRequest)

Creates a new FhircastConnection.

Parameters

NameTypeDescription
subRequestSubscriptionRequestThe subscription request to initialize the connection from.

Overrides

TypedEventTarget.constructor

Defined in

packages/core/src/fhircast/index.ts:421

Properties

subRequest

subRequest: SubscriptionRequest

Defined in

packages/core/src/fhircast/index.ts:414

Methods

dispatchEvent

dispatchEvent<TEventType>(event): void

Type parameters

NameType
TEventTypeextends "message" | "connect" | "disconnect"

Parameters

NameType
eventFhircastSubscriptionEventMap[TEventType]

Returns

void

Inherited from

TypedEventTarget.dispatchEvent

Defined in

packages/core/src/eventtarget.ts:53


addEventListener

addEventListener<TEventType>(type, handler): void

Type parameters

NameType
TEventTypeextends "message" | "connect" | "disconnect"

Parameters

NameType
typeTEventType
handler(event: FhircastSubscriptionEventMap[TEventType]) => void

Returns

void

Inherited from

TypedEventTarget.addEventListener

Defined in

packages/core/src/eventtarget.ts:57


removeEventListener

removeEventListener<TEventType>(type, handler): void

Type parameters

NameType
TEventTypeextends "message" | "connect" | "disconnect"

Parameters

NameType
typeTEventType
handler(event: FhircastSubscriptionEventMap[TEventType]) => void

Returns

void

Inherited from

TypedEventTarget.removeEventListener

Defined in

packages/core/src/eventtarget.ts:64


disconnect

disconnect(): void

Returns

void

Defined in

packages/core/src/fhircast/index.ts:460