jueves, febrero 22, 2024
InicioiOS Developmentios - unable to map mannequin from one sort to aother with...

ios – unable to map mannequin from one sort to aother with Mix in Swift


I’ve following code in Repository:

public last class TimeTableRepository: TimeTableRepositoryProtocol {
    personal let timeTableRemoteDataSource: TimeTableRemoteDataSource
    
    init(timeTableRemoteDataSource: TimeTableRemoteDataSource) {
        self.timeTableRemoteDataSource = timeTableRemoteDataSource
    }
    
    func getTimeTable() -> AnyPublisher<[TimeTableEntity]?, Error> {
        timeTableRemoteDataSource.getTimeTable().flatMap { return $0.toDomain() }
    }
}

I get following error when I attempt to map the TimeTableModel to TimeTableEntity:

  1. ‘flatMap(maxPublishers:_:)’ produces ‘Publishers.FlatMap<[TimeTableEntity]?, AnyPublisher<TimetableModel,
    any Error>>’, not the anticipated contextual consequence sort
    ‘AnyPublisher<[TimeTableEntity]?, any Error>’ (Mix.Writer)

toDomain operate:

extension TimetableModel {
    func toDomain() -> [TimeTableEntity]? {
        timetable.departures.map{ TimeTableEntity(lineDirection: $0.lineDirection ?? "", ThroughStations: $0.throughTheStations ?? "", timestamp: $0.datetime.timestamp, timezone: $0.datetime.tz) }
    }
}

RELATED ARTICLES

DEJA UNA RESPUESTA

Por favor ingrese su comentario!
Por favor ingrese su nombre aquí

Most Popular

Recent Comments