Comments (19)
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.
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.
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.
@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.
from opencombine.
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.
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.
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.
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.
Did you build from latest master
and added import OpenCombine
to APIService.swift
?
from opencombine.
Probably requires import OpenCombineFoundation
as well.
from opencombine.
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.
Thanks for reporting this, I've created #124, which should fix this.
from opencombine.
from opencombine.
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.
@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.
Are you also importing the OpenCombineFoundation module? Because it is required in order to use URLSession extensions.
from opencombine.
from opencombine.
Yes, if you upgrade to the latest master and import OpenCombineFoundation, everything should work.
from opencombine.
Related Issues (20)
- the `*` in DispatchQueue scheduler's SchedulerTimeType gives wrong value HOT 3
- Ready for production? HOT 3
- [Consideration] Bridge from OpenCombine to Combine publishers HOT 12
- Slack Invite is no longer valid HOT 1
- Doesn't compile on macOS Monterey / XCode 13 HOT 2
- [Feature Request] Async Publisher.values HOT 1
- Re-enable concurrency tests on Wasm when swiftwasm supports them
- Re-enable concurrency tests on Windows when Windows issues are fixed
- error HOT 5
- [Bug]The Publishers.ReceiveOn may lead to subscriber never receive the published single when schedule is concurrent queue.
- [Bug]The Publishers.ReceiveOn may lead to subscriber never receive the published signal when scheduler is concurrent queue.
- would be nice to be able to use "@Published" directive in earlier Swift versions that do not know it HOT 2
- Add primary associated type support HOT 1
- Unable to build on Ubuntu 22.04.1 HOT 2
- Zip crash HOT 3
- When BUILD_LIBRARY_FOR_DISTRIBUTION is set to YES, the build will fail. HOT 1
- Xcode 15 crash HOT 1
- EXC_BAD_ACCESS when repeatedly using Future HOT 3
- When Future call Cancel, why parent is copied by take()?
- error build: Undefined symbol: _OBJC_CLASS_$
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opencombine.