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
- reportIDsToMonitor:
The report IDs that should trigger an Inputreport(id:data:timestamp:) notification.
- elementsToMonitor:
The elements that should trigger an Elementupdates(values:) notification. Elements of interest can be parsed from Elements.
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
}