2,097 questions
0 votes
1 answer
103 views
How to synchronize multiple marquee animations and resetting them when text changed?
I am trying to create a SwiftUI Marquee component that: Can take 2 string items If any of the two string items are longer then the width of its parent then animate them right to left If they are ...
1 vote
1 answer
60 views
How can I get a Subscriber to subscribe to get only 4 elements from an array?
I am trying to implement a subscriber which specifies its own demand for how many elements it wants to receive from a publisher. My code is below: import Combine var array = [1, 2, 3, 4, 5, 6, 7] ...
-1 votes
1 answer
160 views
Implementing Combine map operator that read data from MainActor
I have a feeling that Swift Concurrency is fighting agains me all the time. It is really frustrating. My problem. I need to create Combine publisher to emit battery state on iOS device. So far I have ...
4 votes
2 answers
1k views
How to solve Sending 'self.viewModel' risks causing data races? [closed]
I am looking to migrate my below file into swift 6. There is one way to forcefully use @MainActor everywhere(ViewModels, protocols etc) another is use uncheck-sendable or use @preconcurrency. But I am ...
1 vote
1 answer
113 views
RxSwift's Signal equivalent in Combine / Concurrency
I have been using RxSwift for my apps before Combine, Swift Concurrency and SwiftUI. In RxSwift we can have a Signal that will just emit without replaying the previous value which is very useful to ...
0 votes
0 answers
36 views
Swift 6 only Combine crash [duplicate]
@globalActor public struct TestGlobalActor { public actor ActorType { } public static let shared: ActorType = ActorType() } final class TestCrash: XCTestCase { let subject = ...
1 vote
2 answers
203 views
How to make a Set<AnyCancellable> sendable?
How can I get rid of @unchecked Sendable in this case: final class TestSendable: @unchecked Sendable { private var subscriptions = Set<AnyCancellable>() } apart from: @MainActor ...
-1 votes
2 answers
71 views
How to create custom Generic Subscriber with Combine?
Here is my CustomSubscriber. All I want to achieve is to replace build-in .sink with my own one. Just to better understand how it works under the hood. class CustomSubscriber<Input, Failure>: ...
-2 votes
1 answer
85 views
Where would using Record Publisher with Combine be useful?
I am trying to understand Record Publisher. Here is an example to better understand the case: var subscriptions = [AnyCancellable]() let pub = Record<Int, Never>(output: [1, 101, 102, 1001, 1002]...
0 votes
1 answer
59 views
How to repeatedly connect a timer with onTapGesture?
As title says I have created a timer to publish every second and on the 5th second it disables a picker in my view. The timer itself is started by tapping on the picker and it works on the first try ...
0 votes
1 answer
37 views
Adding Publisher conformance to a class breaks expected computed property getter calls
I’ve encountered unexpected behavior in Swift when a class conforms to Publisher. It appears that just conforming to the protocol causes property getters and setters to stop being called. Reproducible ...
0 votes
0 answers
61 views
Expose a @Published var from an Actor protocol in Swift 6 [duplicate]
I want to listen to the changes (of a boolean for example) value in one of my actors. So I have this protocol that my actor conforms to: protocol MyServiceProtocol: Actor { var myValuePublisher: ...
0 votes
1 answer
50 views
Can you use a combine publisher to stagger events so that they are output a minimum time apart from eachother?
For an animation, I am trying to use Combine to smooth out the animation. There are three image URLs that need to be loaded. I am hoping to make it so that they are loaded in parallel, but that no ...
0 votes
0 answers
31 views
How to cancel all publishers when any send error?
code: 50 publishers, I want to that: any send error, all will stop. Just like RxSwift let singles: [Deferred<Future<Int, Error>>] = (0..<50).compactMap { value in return ...
-2 votes
1 answer
86 views
Create Publisher that emits when month changes
TL:DR Is it possible to create a Publisher that will emit whenever the date ticks over from one month to the next (i.e. at 00:00 on 1st of each month) regardless of whether the app is in the ...