Realtime updates
ovok.realtime.subscribe() creates a FHIR Subscription, opens its authenticated
- Stable unknown
- Release candidate since 0.1.0-rc.4
- Development since 0.1.0-dev.26+c361756
ovok.realtime.subscribe() creates a FHIR Subscription, opens its authenticated
WebSocket, and calls your handler for each matching resource change. The criteria
uses the FHIR subscription search format.
final stop = await ovok.realtime.subscribe(
'Observation?subject=Patient/$patientId',
handleNotification,
);The handler receives SubscriptionStatus event notifications.
notification['resources'] holds the changed resources the server sent with
each one, in server order. Handshake, heartbeat and ping/pong messages stay
internal.
void handleNotification(RealtimeNotification notification) {
final resources = notification['resources'] as List<Map<String, dynamic>>;
// Update your state from the changed resources.
}Use the notification to update your state or refresh the affected view. Keep FHIR payloads out of application logs.
Keep the returned function while the screen or service needs updates, then call it to close the socket and delete the server-side Subscription:
await stop();The client reconnects after a dropped connection, refreshes its short-lived
WebSocket binding, and pauses while signed out. It resumes when the same profile
signs in again. Changing profiles ends the subscription. A blank criteria string
throws OvokValidationException.
Last updated on