Contents

monitorNotifications(reportIDsToMonitor:elementsToMonitor:)

Creates an asynchronous that receives notifications about the associated device.

Declaration

func monitorNotifications(reportIDsToMonitor: [ClosedRange<HIDReportID>], elementsToMonitor: [HIDElement]) -> AsyncThrowingStream<HIDDeviceClient.Notification, any Error>

Parameters

Mentioned in

Return Value

An asynchronous stream that receive notifications.

Discussion

Notifications come in asynchronously from the device at arbitrary times when relevant events occur.

Example usage:

for await notification in try await client.monitorNotifications(reportIDsToMonitor: [HIDReportID.allReports], elementsToMonitor: await client.elements) {
switch notification {
case .inputReport(let reportID, let report, let timestamp):
    break
case .elementUpdates(let values):
    break
case .deviceSeized:
    break
case .deviceUnseized:
    break
case .deviceRemoved:
    break
}

See Also

Monitor device notifications