I have a function capturing events from an api which works great. The only issue is i dont want the stream to be complete when it fails.
public func getDeviceEvent(deviceUID: String) -> SignalProducer<DeviceEvent, HTTPConnectorError> {
return SignalProducer<DeviceEvent, HTTPConnectorError> { observer, _ in
self.getDeviceEvent(deviceUID: deviceUID) { result in
switch result {
case .success(let deviceEvent):
observer.send(value: deviceEvent)
observer.sendCompleted()
case .failure(let error):
observer.send(error: error)
}
}
}
}
private func getDeviceEvent(deviceUID: String, completion: @escaping (Result<DeviceEvent, HTTPConnectorError>) -> Void) {
httpConnector.request(authenticated: true, target: .deviceLocationEvent(deviceID: deviceUID), parse: makeParser(), completion: completion)
}
Is there a way i can keep the stream going? i know there is retry
but i don't want to add a number of times i just want it to continue.