: Publisher { /// The kind of values published by this publisher. public typealias Output = DataTaskResult /// The kind of errors this publisher might publish. public typealias Failure = URLError }
{ ValidationError.error($0) } .flatMap { (result) -> ValidatedPublisher in if isValid(result) { // return the value in the Output/Success stream } else { // return the value in the Failure stream } } }
{ ValidationError.error($0) } .flatMap { (result) -> ValidatedPublisher in if isValid(result) { // return the value in the Output/Success stream } else { // return the value in the Failure stream } } }
{ ValidationError.error($0) } .flatMap { (result) -> ValidatedPublisher in if isValid(result) { // return the value in the Output stream return Just(result) .setFailureType(to: ValidationError.self) .eraseToAnyPublisher() } else { // return the value in the Failure stream } } }
{ ValidationError.error($0) } .flatMap { (result) -> ValidatedPublisher in if isValid(result) { // return the value in the Output stream return Just(result) .setFailureType(to: ValidationError.self) .eraseToAnyPublisher() } else { // return the value in the Failure stream } } }
{ ValidationError.error($0) } .flatMap { (result) -> ValidatedPublisher in if isValid(result) { // return the value in the Output stream return Just(result) .setFailureType(to: ValidationError.self) .eraseToAnyPublisher() } else { // return the value in the Failure stream return Fail( outputType: DataTaskResult.self, failure: ValidationError.jsonError(result.data) ).eraseToAnyPublisher() } } }
{ ValidationError.error($0) } .flatMap { (result) -> ValidatedPublisher in if isValid(result) { // return the value in the Output stream return Just(result) .setFailureType(to: ValidationError.self) .eraseToAnyPublisher() } else { // return the value in the Failure stream return Fail( outputType: DataTaskResult.self, failure: ValidationError.jsonError(result.data) ).eraseToAnyPublisher() } } }
{ ValidationError.error($0) } .flatMap { (result) -> ValidatedPublisher in if isValid(result) { // return the value in the Output stream return Just(result) .setFailureType(to: ValidationError.self) .eraseToAnyPublisher() } else { // return the value in the Failure stream return Fail( outputType: DataTaskResult.self, failure: ValidationError.jsonError(result.data) ).eraseToAnyPublisher() } } }
{ ValidationError.error($0) } .flatMap { (result) -> ValidatedPublisher in if isValid(result) { // return the value in the Output stream return Just(result) .setFailureType(to: ValidationError.self) .eraseToAnyPublisher() } else { // return the value in the Failure stream return Fail( outputType: Output.self, failure: ValidationError.jsonError(result.data) ).eraseToAnyPublisher() } }.eraseToAnyPublisher() }