From 2d1fa1eb5730e58e6d0e5dcd859c4b7b34d0c1d9 Mon Sep 17 00:00:00 2001 From: Dinesh Harjani Date: Mon, 2 Dec 2024 13:26:47 +0000 Subject: [PATCH] Minor Changes Just making things more readable. --- .../CentralManager/CentralManager.swift | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/Sources/iOS-BLE-Library-Mock/CentralManager/CentralManager.swift b/Sources/iOS-BLE-Library-Mock/CentralManager/CentralManager.swift index a6e5125..b986f00 100644 --- a/Sources/iOS-BLE-Library-Mock/CentralManager/CentralManager.swift +++ b/Sources/iOS-BLE-Library-Mock/CentralManager/CentralManager.swift @@ -144,12 +144,12 @@ extension CentralManager { return self.connectedPeripheralChannel .filter { $0.0.identifier == peripheral.identifier } - .tryMap { p in - if let e = p.1 { - throw e + .tryMap { peripheral, error in + if let error { + throw error } - return p.0 + return peripheral } .prefix(untilUntilOutputOrCompletion: killSwitch) .bluetooth { @@ -201,9 +201,7 @@ extension CentralManager { /// - Returns: A list of the peripherals that are currently connected /// to the system and that contain any of the services /// specified in the `serviceUUID` parameter. - public func retrieveConnectedPeripherals(withServices identifiers: [CBUUID]) - -> [CBPeripheral] - { + public func retrieveConnectedPeripherals(withServices identifiers: [CBUUID]) -> [CBPeripheral] { centralManager.retrieveConnectedPeripherals(withServices: identifiers) } @@ -229,11 +227,7 @@ extension CentralManager { /// - services: The services to scan for. /// - options: A dictionary to customize the scan, such as specifying whether duplicate results should be reported. /// - Returns: A publisher that emits scan results or an error. - public func scanForPeripherals( - withServices services: [CBUUID]?, options: [String: Any]? = nil - ) - -> AnyPublisher - { + public func scanForPeripherals(withServices services: [CBUUID]?, options: [String: Any]? = nil) -> AnyPublisher { stopScan() return centralManagerDelegate.stateSubject .tryFirst { state in