                 .filter { $0.0 == peripheral.peripheral }
                 .map { (_, error) -> T in
                     throw BluetoothError.peripheralDisconnected(peripheral, error)
-            }
+                }
         }
     }
 

                    return peripheralTable.map {
                        Peripheral(manager: strongSelf, peripheral: $0)
                    }
            }
        }
        return ensure(.poweredOn, observable: observable)
    }


    func monitorPeripheral(on peripheralAction: Observable<RxPeripheralType>, peripheral: Peripheral)
        -> Observable<Peripheral> {
        let observable =
            peripheralAction
            .filter { $0 == peripheral.peripheral }
            .map { _ in peripheral }
        return ensure(.poweredOn, observable: observable)
    }

    #if os(iOS)
        /// Emits `RestoredState` instance, when state of `BluetoothManager` has been restored,
        /// Should only be called once in the lifetime of the app
        /// - Returns: Observable which emits next events state has been restored
        public func listenOnRestoredState() -> Observable<RestoredState> {
            return centralManager
                .rx_willRestoreState
                .take(1)
                .flatMap { [weak self] dict -> Observable<RestoredState> in
                    guard let strongSelf = self else { throw BluetoothError.destroyed }
                    return .just(RestoredState(restoredStateDictionary: dict, bluetoothManager: strongSelf))
                }
        }
    #endif
}
