Coder Social home page Coder Social logo

Comments (19)

doronkatz avatar doronkatz commented on May 19, 2024 1

Thanks @broadwaylamb I think I had a cache issue. I re-did the imports and added the targets and it works now perfectly... OpenCombineFoundation is my savior across both platforms.

Thanks!

from opencombine.

MaxDesiatov avatar MaxDesiatov commented on May 19, 2024

Hi @doronkatz, none of Foundation extensions that Combine provides are in OpenCombine yet. As for the second error, it seems like a type inference issue, most probably caused by dataTaskPublisher not available in current scope, thus the compiler is not able to figure out in which namespace .tryMap is invoked.

from opencombine.

doronkatz avatar doronkatz commented on May 19, 2024

Oh thanks @MaxDesiatov. I see... Yeah may have to wait or help contribute to get that across.. As for the second issue, it only happens on Unix and not on iOS/macOS. So that's why i wasn't sure about the context..

from opencombine.

broadwaylamb avatar broadwaylamb commented on May 19, 2024

@doronkatz hi! I’ll get to URLSession as soon as #84 is ready, since it lays the groundwork for supporting Foundation extensions.

It should be pretty soon!

from opencombine.

doronkatz avatar doronkatz commented on May 19, 2024

from opencombine.

broadwaylamb avatar broadwaylamb commented on May 19, 2024

The functionality is available in master.

Note that on Darwin platforms, you'll need to use the ocombine property to disambiguate (since Foundation extends URLSession with a method with the same name):

let publisher = self.urlSession.ocombine.dataTaskPublisher(for: request)

On Linux, you can omit this.

from opencombine.

doronkatz avatar doronkatz commented on May 19, 2024

Thanks @broadwaylamb. Silly question but how do you test if its linux? I was looking at #if canImport(Combine) .... but don't think that works for this

from opencombine.

broadwaylamb avatar broadwaylamb commented on May 19, 2024

We don’t need to test if it’s Linux. The ambiguity takes place only if Combine is present on your platform, so #if canImport(Combine) should be enough.

from opencombine.

doronkatz avatar doronkatz commented on May 19, 2024

Right, so when i run it on my macOS it works fine, but when i build it in Docker Unix:

/app/Sources/SwiftRecommendations/Services/APIService.swift:62:45: error: value of type 'URLSession' has no member 'ocombine'
            let publisher = self.urlSession.ocombine.dataTaskPublisher(for: request)

My code changes are:

#if canImport(Combine)
            let publisher = self.urlSession.dataTaskPublisher(for: request)
            #else
            let publisher = self.urlSession.ocombine.dataTaskPublisher(for: request)
            #endif

from opencombine.

MaxDesiatov avatar MaxDesiatov commented on May 19, 2024

Did you build from latest master and added import OpenCombine to APIService.swift?

from opencombine.

MaxDesiatov avatar MaxDesiatov commented on May 19, 2024

Probably requires import OpenCombineFoundation as well.

from opencombine.

doronkatz avatar doronkatz commented on May 19, 2024

I didn't try the last one, but it can't find OpenCombineFoundation. I have the latest (master) and have imported OpenCombine.

My package:

.package(url: "https://github.com/broadwaylamb/OpenCombine.git",
                 .branch("master"))

from opencombine.

MaxDesiatov avatar MaxDesiatov commented on May 19, 2024

Thanks for reporting this, I've created #124, which should fix this.

from opencombine.

doronkatz avatar doronkatz commented on May 19, 2024

from opencombine.

broadwaylamb avatar broadwaylamb commented on May 19, 2024

Right, so when i run it on my macOS it works fine, but when i build it in Docker Unix:

/app/Sources/SwiftRecommendations/Services/APIService.swift:62:45: error: value of type 'URLSession' has no member 'ocombine'
            let publisher = self.urlSession.ocombine.dataTaskPublisher(for: request)

My code changes are:

#if canImport(Combine)
            let publisher = self.urlSession.dataTaskPublisher(for: request)
            #else
            let publisher = self.urlSession.ocombine.dataTaskPublisher(for: request)
            #endif

You don’t have to write this condition. ocombine is available on Linux too. Basically, if you want to use OpenCombine on Linux, and leverage Combine on macOS, you use self.urlSession.dataTaskPublisher(for: request). If you want to just use OpenCombine everywhere, use self.urlSession.ocombine.dataTaskPublisher(for: request).

from opencombine.

doronkatz avatar doronkatz commented on May 19, 2024

@broadwaylamb so if I use just urlSession.dataTaskPublisher... I get on Unix:

error: value of type 'URLSession' has no member 'dataTaskPublisher'
            let publisher = self.urlSession.dataTaskPublisher(for: request)

So not sure if it is the case pr i am doing something else... I do want to use OCombine for Unix and Combine for Darwin ideally

from opencombine.

broadwaylamb avatar broadwaylamb commented on May 19, 2024

Are you also importing the OpenCombineFoundation module? Because it is required in order to use URLSession extensions.

from opencombine.

doronkatz avatar doronkatz commented on May 19, 2024

from opencombine.

broadwaylamb avatar broadwaylamb commented on May 19, 2024

Yes, if you upgrade to the latest master and import OpenCombineFoundation, everything should work.

from opencombine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.