SwiftBluetooth
SwiftBluetooth copied to clipboard
Receive disconnect event
Hi! Great project. Would appreciate a method to receive a change in the disconnect event without having to use regular Core-Bluetooth's Delegate functionality. Thanks a lot 😄
This is possible.
var switchDisconnectSubscription : AsyncSubscription<PeripheralEvent> = peripheral.eventSubscriptions.queue { event, done in
guard case .didDisconnect(let error) = event else { return }
print("did disconnect: \(String(describing: error))")
}
As far as I know, it's not directly documented, it's more of a feature of this repository that I had to dig for.
Thank you very much <3
Sorry, how did you get this to work? eventSubscription is marked internal. Did you fork the repo?