API Reference
BioLiveStore
Observable data store for real-time biosignal UI — @Published properties, signal access, and chart data.
An ObservableObject that aggregates live biosignal data, device states, and session info for SwiftUI views.
public final class BioLiveStore: ObservableObjectAccess via sdk.live:
let sdk = try await BioSDKClient.initialize(configuration: config)
struct DashboardView: View {
@ObservedObject var live: BioLiveStore
var body: some View {
Text("Session: \(live.currentSessionId ?? "none")")
}
}
// Pass sdk.live to your view
DashboardView(live: sdk.live)Published Properties
Signal Data
| Property | Type | Description |
|---|---|---|
signals | [String: [BioSample]] | All samples grouped by signal name |
signalsByDevice | [String: [String: [BioSample]]] | Samples grouped by device ID, then signal name |
Device State
| Property | Type | Description |
|---|---|---|
deviceNames | [String: String] | Map of device ID → display name |
deviceConnectionStates | [String: BioConnectionState] | Connection state per device |
deviceStreamStates | [String: BioStreamState] | Stream state per device |
deviceAutoStream | [String: Bool] | Auto-stream enabled per device |
deviceBattery | [String: Int] | Battery percentage per device |
Session State
| Property | Type | Description |
|---|---|---|
currentSessionId | String? | Active backend session ID |
conflictingSessionId | String? | Session ID from a 409 conflict |
conflictingSessionStartedAt | Date? | When the conflicting session started |
sessionError | String? | Current session error message |
sessionDevices | [SessionDevice] | Devices enrolled in the current session |
Convenience Accessors
// Get samples for a specific signal
public func samples(for signalName: String) -> [BioSample]
// Get samples for a signal from a specific device
public func samples(for signalName: String, deviceId: String) -> [BioSample]
// List all signal names that have data
public var availableSignals: [String] { get }
// List all device IDs that have sent data
public var availableDevices: [String] { get }Chart Data
Pre-formatted data for BioUI chart components:
public var ecg: [TimeSeries] { get }
public var ppg: [TimeSeries] { get }
public var eda: [TimeSeries] { get }
public var temp: [TimeSeries] { get }Example with BioUI:
import BioUI
struct LiveChartsView: View {
@ObservedObject var live: BioLiveStore
var body: some View {
VStack {
BioECGChart(data: live.ecg)
BioPPGChart(data: live.ppg)
}
}
}Background Memory Management
Call these methods from your SceneDelegate or SwiftUI lifecycle to reduce memory usage when the app is backgrounded:
// Trim in-memory sample buffers for background
public func enterBackgroundMode()
// Restore full sample buffering
public func enterForegroundMode()Data Ingestion
// Ingest a sample into the store (called automatically by the SDK)
public func ingest(_ sample: BioSample, deviceId: String)Device Management
// Register a device name
public func noteDevice(deviceId: String, name: String)
// Update connection/stream state for a device
public func updateDeviceState(
deviceId: String,
connection: BioConnectionState,
stream: BioStreamState
)
// Update battery level
public func updateDeviceBattery(deviceId: String, battery: Int?)
// Update auto-stream setting
public func updateDeviceAutoStream(deviceId: String, enabled: Bool)
// Mark a device as disconnected
public func noteDeviceDisconnected(deviceId: String)
// Restore persisted state (e.g., after app relaunch)
public func restoreState(
deviceNames: [String: String],
deviceConnectionStates: [String: String],
deviceStreamStates: [String: String],
deviceBattery: [String: Int],
deviceAutoStream: [String: Bool]
)Session Updates
// Update the current session ID and devices
public func updateSession(id: String?, devices: [SessionDevice] = [])
// Set conflict state
public func updateSessionConflict(activeId: String, startedAt: Date?)
// Clear conflict state
public func clearSessionConflict()
// Set or clear a session error message
public func updateSessionError(_ message: String?)
// Reset all state (clears signals, device states, session info)
public func reset()