artsy/eidolon

MapTo operator is not compiler

douglastaquary opened this issue · 4 comments

Hello @ashfurrow @orta !Thanks, very thanks for shared this project. I'm studying it, and set several pattens in my projects. Look for branch ofswift3-update, in piece of code, more specifically on class ListingViewModel:

 // Fetches all pages of the auction
    fileprivate func allListingsRequest() -> Observable<[SaleArtwork]> {
        let backgroundJSONParsing = scheduleOnBackground(retrieveAllListingsRequest(1)).reduce([Any]())
            { (memo, object) in
                guard let array = object as? Array<Any> else { return memo }
                return memo + array
            }
            .mapTo(arrayOf: SaleArtwork.self)
            .logServerError(message: "Sale artworks failed to retrieve+parse")
            .catchErrorJustReturn([])

        return scheduleOnForeground(backgroundJSONParsing)
    }

let backgroundJSONParsing = scheduleOnBackground(retrieveAllListingsRequest(1)).reduce([Any]())

.mapTo(arrayOf: SaleArtwork.self)
these lines of code, there is problem of types. The compiler complains that :

`Value of type 'Observable<[Any].Type> (aka 'Observable<Array.Type>') has no member 'mapTo'``

MapTo is a new operator set in new version of RxSwift, right?

Are you can to compile this version of code?

There is some solution for these?

And more times, thanks for shared of project.

Hi there, thanks for the kind words! Great question. mapTo is not a part of RxSwift, but rather a part of our codebase. The functions are in this file: https://github.com/artsy/eidolon/blob/a7bb061c89cd4bed44d956b1376909ca0e72060b/Kiosk/Observable%2BJSONAble.swift Let me know if I can clarify anything!

Ok, @ashfurrow
Very thanks for answer, i understand. thanks for listening to me

@ashfurrow Sorry, but only more a detail: as is the flow of the sequence?

 .mapTo(arrayOf: SaleArtwork.self)
            .logServerError(message: "Sale artworks failed to retrieve+parse")
            .catchErrorJustReturn([])

.logServerError(message: "Sale artworks failed to retrieve+parse")

Because these line of code, the compiler complains too :
Value of type 'Observable<[SaleArtwork]> (aka 'Observable<Array<SaleArtwork>>') has no member 'logServerError'

this function is part of your codebase too?

Exactly, yup!