Review feedback

This commit is contained in:
2020-05-01 00:16:10 -07:00
parent c60685bf20
commit c6fa9fe960
5 changed files with 22 additions and 19 deletions
@@ -17,7 +17,7 @@ protocol ServerMultiplexDelegate
enum ServerMultiplexError : Error
{
case UnknownDevice
case unknownDevice
}
class ServerMultiplex
@@ -26,7 +26,7 @@ class ServerMultiplex
public private(set) var devices = Set<AnyDevice>()
private var servers: [Server] = []
public var numServers: Int { get { return servers.count } }
public var numServers: Int { return servers.count }
public func addServer(_ server: Server)
{
@@ -48,7 +48,7 @@ class ServerMultiplex
devices[index].state = state
}
} else {
completion(ServerMultiplexError.UnknownDevice)
completion(ServerMultiplexError.unknownDevice)
}
}
+4 -6
View File
@@ -76,17 +76,15 @@ class WemoServer : Server
func fetchDevices(_ completion: @escaping (Result<[AnyDevice], Error>) -> Void)
{
let op = FetchDevicesOperation(baseURL: self.baseURL, session: _urlSession)
weak var weakOp = op
op.completionBlock = {
guard let strongOp = weakOp else { return }
if let error = strongOp.error {
op.completionBlock = { [unowned op] in
if let error = op.error {
self._logError("Error fetching devices", error: error)
completion(.failure(error))
} else {
self.devices = strongOp.devices
self.devices = op.devices
}
self.devices = strongOp.devices
self.devices = op.devices
completion(.success(self.devices.map { AnyDevice($0) }))
}