Skip to main content

core.medplumclient.getmastersubscriptionemitter

Home > @medplum/core > MedplumClient > getMasterSubscriptionEmitter

MedplumClient.getMasterSubscriptionEmitter() method

Get the master SubscriptionEmitter for the SubscriptionManager.

The master SubscriptionEmitter gets messages for all subscribed criteria as well as WebSocket errors, connect and disconnect events, and the close event.

It can also be used to listen for heartbeat messages.

------

Signature:

getMasterSubscriptionEmitter(): SubscriptionEmitter;

Returns:

SubscriptionEmitter

the master SubscriptionEmitter from the SubscriptionManager.

Example

### Listening for heartbeat:

const masterEmitter = medplum.getMasterSubscriptionEmitter();

masterEmitter.addEventListener('heartbeat', (bundle: Bundle<SubscriptionStatus>) => {
console.log(bundle?.entry?.[0]?.resource); // A `SubscriptionStatus` of type `heartbeat`
});