cx-org / combinex Goto Github PK
View Code? Open in Web Editor NEWOpen source implementation of Apple's Combine
License: MIT License
Open source implementation of Apple's Combine
License: MIT License
Hi,
Thank you for tackling the combine requirements issue. I believe this will help a lot but will require a lot of contributions.
There is another port being build at https://github.com/broadwaylamb/OpenCombine.
Maybe you could merge yours efforts ? I'm opening the same issue on the other repo.
It happens from time to time.
Hi,
Environment variables seem tricky and Xcode doesn't seem to recognize them (I'm trying Environment Variables setting under executable target scheme). I am wondering why didn't you choose launch arguments instead (under executable target scheme) ?
PS: It works if I set environment variable before launching Xcode though.
Thanks for helping!
Shahzad
I've changed supported platform to .macOS(.v10_10)
and everything works just fine.
CXWrappers
is a misleading namespace, and it leaks implementation detail. When use with system Combine, CXWrappers.DispatchQueue
is simply a typealias to DispatchQueue
and doesn't wrap anything.
I think CX
is a better namespace, also CX.DispatchQueue
is symmetrical with DispatchQueue.CX
.
Seeing errors about missing files building from master:
error: Build input files cannot be found: 'Carthage/Checkouts/CombineX/Sources/CXUtility/Extensions.swift', 'Carthage/Checkouts/CombineX/Sources/CXUtility/Lock.swift' (in target 'CXUtility_iOS' from project 'CombineX-Carthage'
Debounce seems to get into an endless loop emitting last received value.
This code:
let pub = PassthroughSubject<Int, Never>()
pub
.debounce(for: 1.0, scheduler: DispatchQueue.main.cx)
.sink(receiveValue: {
print("received: \($0) at: \(Date())")
})
.store(in: &subscribers)
(0...10).forEach(pub.send)
Gives this result:
received: 10 at: 2019-11-07 10:16:58 +0000
received: 10 at: 2019-11-07 10:16:59 +0000
received: 10 at: 2019-11-07 10:17:00 +0000
received: 10 at: 2019-11-07 10:17:01 +0000
received: 10 at: 2019-11-07 10:17:02 +0000
received: 10 at: 2019-11-07 10:17:03 +0000
received: 10 at: 2019-11-07 10:17:04 +0000
received: 10 at: 2019-11-07 10:17:05 +0000
received: 10 at: 2019-11-07 10:17:06 +0000
received: 10 at: 2019-11-07 10:17:07 +0000
received: 10 at: 2019-11-07 10:17:08 +0000
received: 10 at: 2019-11-07 10:17:09 +0000
received: 10 at: 2019-11-07 10:17:10 +0000
received: 10 at: 2019-11-07 10:17:11 +0000
received: 10 at: 2019-11-07 10:17:12 +0000
received: 10 at: 2019-11-07 10:17:13 +0000
received: 10 at: 2019-11-07 10:17:14 +0000
The latest version released to CocoaPods is 0.1.1.
Running pod install --repo-update
installs this version, not the latest 0.3.0.
Hi, in a very simple use case debounce seems to crash, but it might just be me using the cx proxy wrong?
This code crashes with EXC_BAD_INSTRUCTION:
let pub = PassthroughSubject<Int, Never>()
pub
.debounce(for: 2.0, scheduler: DispatchQueue.global().cx)
.sink(receiveValue: {
print($0)
})
.store(in: &subscribers)
(0...10).forEach(pub.send) //Crashes here: Thread 1: EXC_BAD_INSTRUCTION
It seems that we need runtime support to implement this.
๐ค, I am considering the feasibility of introducing runtime as a dependency.
Publishers.FlatMap
should request .unlimited
demand instead of .max(1)
if itself received unlimited demand.
Failing test case here: https://github.com/cx-org/CombineX/blob/master/Tests/CXInconsistentTests/FailingTests/FailingFlatMapSpec.swift
Would be great to get this updated if possible. My main reason for advocating for this is to avoid consumers (myself included) from having test dependencies included, since this was resolved in the most recent update.
Optional.CX.Publisher
and Result.CX.Publisher
have special operator overloads which returns Optional.CX.Publisher
and Result.CX.Publisher
.
I'm using xcbeautify
for my personal project, here is my workflow: https://github.com/Cyberbeni/TypedNotificationCenter/blob/c7c60960468e939008f15a2984d7e90953a6e726/.github/workflows/run_tests.yml#L6
Here is how the output looks: https://github.com/Cyberbeni/TypedNotificationCenter/runs/1289031608?check_suite_focus=true#step:4:31
xcbeautify
works for both macOS and Linux, install-swift-tool
takes care of building and caching of xcbeautify
, so consecutive runs will only have a couple seconds of overhead for downloading it.
When use CXShim with system Combine and target on 'Any iOS Device', we got "No such module 'Combine'" error. As reported in #116 and sbertix/Swiftagram#191.
This is because CXShim
always have low system requirement. To re-export system Combine, we need to bump platform to iOS 13.0.
However, system requirement is applied to both CombineX
and CXShim
. We can make it configurable via environment variable, but we can't make them both work out of the box. Currently CX_CONTINUOUS_INTEGRATION=YES CX_COMBINE_IMPLEMENTATION=Combine
will force high platform and CX_COMBINE_IMPLEMENTATION=CombineX
will force low platform.
I believe CombineX
and CXShim
are equally important. Mandatory env configuration can make integration significantly more obscure. The best solution I can think of is to move CXShim
to a separate repo. So we can lift system requirement just for CXShim
. This would be a breaking change.
Hi,
I am trying to test Zip3 operator and it doesn't seem to be working as expected:
My Code:
`var disposable: [AnyCancellable] = []
func testZip3() {
let p1 = [3, 4, 5].cx.publisher
let p2 = ["Hello", "World"].cx.publisher
let p3 = [0.2, 0.6].cx.publisher
Publishers.Zip3(p1, p2, p3)
.print()
.sink(receiveCompletion: { result in
print(result)
}, receiveValue: { (r1, r2, r3) in
print(r1, r2, r3)
})
.store(in: &disposable)
}`
Output:
: receive subscription: (MapError) : request unlimited : receive finished finished
PS: Same code works fine when I use Apple Combine.
Apple's implementations of the Foundation and Dispatch publishers and schedulers are part of the Swift open-source project. Have you considered adapting those implementations for CX?
Here are the files of interest:
Hi! I am not sure if this is indeed a CombineX issue, but it crashes when running on device when subscribing to a publisher inside a propertywrapper.
The message is:
failed to demangle witness for associated type 'Failure' in conformance 'CombineX.Publishers.Drop<CombineX.CurrentValueSubject<Swift.Optional<Swift.String>, Swift.Never>>: Publisher' from mangled name '7Failure8CombineX9PublisherPQz'
The code is this
import Foundation
import CXFoundation
@propertyWrapper
struct StoredObservable<Key: StringProtocol, Value: Codable> {
private var store: DataCaching
private var key: Key
private var value: Value?
private var publisher: CurrentValueSubject<Value?, Never>
private var subscriber: AnyCancellable
var wrappedValue: Value? {
get {
return value
}
set {
value = newValue
publisher.send(newValue)
}
}
var projectedValue: CurrentValueSubject<Value?, Never> {
mutating get {
return publisher
}
}
init(_ key: Key, _ store: DataCaching) {
let compositeKey: Key = "StoredObservable.\(key)"
self.key = compositeKey
self.store = store
self.value = store.fetchCachedValue(forKey: String(compositeKey), ofType: Value.self)
publisher = .init(self.value)
self.subscriber = publisher
.dropFirst()
.sink(receiveCompletion: { _ in }, receiveValue: {
do {
try store.setCachedValue($0, forKey: String(compositeKey))
} catch {
print(error)
assertionFailure()
}
})
}
}
and it crashes here:
Update: This doesn't seem to be caused by the property wrapper context at all. I seem to hit this a lot now.
@luoxiu Do you have any idea what causes failed to demangle witness for associated type 'Failure' in conformance
and how I might avoid it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.