Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
70 views

func getCharactersList(from url: URL) -> AnyPublisher<[Character], NetworkRequestError> { if shouldReturnError { // Fail with concrete NetworkRequestError return Fail(...
Tainted's user avatar
  • 15
0 votes
1 answer
108 views

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 ...
kaylanx's user avatar
  • 908
1 vote
1 answer
60 views

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] ...
Asaad Jaber's user avatar
-1 votes
1 answer
170 views

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 ...
Marcin Kapusta's user avatar
4 votes
2 answers
1k views

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 ...
Amit's user avatar
  • 685
1 vote
1 answer
118 views

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 ...
Bawenang Rukmoko Pardian Putra's user avatar
0 votes
0 answers
37 views

@globalActor public struct TestGlobalActor { public actor ActorType { } public static let shared: ActorType = ActorType() } final class TestCrash: XCTestCase { let subject = ...
Todanie's user avatar
  • 528
1 vote
2 answers
217 views

How can I get rid of @unchecked Sendable in this case: final class TestSendable: @unchecked Sendable { private var subscriptions = Set<AnyCancellable>() } apart from: @MainActor ...
Todanie's user avatar
  • 528
-1 votes
2 answers
71 views

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>: ...
Bartłomiej Semańczyk's user avatar
-2 votes
1 answer
89 views

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]...
Bartłomiej Semańczyk's user avatar
0 votes
1 answer
59 views

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 ...
user17852191's user avatar
0 votes
1 answer
38 views

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 ...
Данил Войдилов's user avatar
0 votes
0 answers
61 views

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: ...
Xys's user avatar
  • 11.3k
0 votes
1 answer
50 views

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 ...
CalebK's user avatar
  • 737
0 votes
0 answers
31 views

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 ...
DaiElliot's user avatar
-2 votes
1 answer
86 views

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 ...
Oliver Pearmain's user avatar
1 vote
1 answer
59 views

I am struggling to understand the behavior of throttle. When I click the button multiple times, instead of seeing "sink" printed once and all the other being dropped by the throttle, it will ...
Programmer54's user avatar
1 vote
1 answer
495 views

I tried to make as simple example as possible using Swift 6 to produce this problem which I am having difficulty to solve: func getValue() async -> Int { 0 } func getValuePublisher() -> ...
Matic Oblak's user avatar
  • 16.9k
2 votes
1 answer
164 views

I have a dict/json type of object that I captured from the output of a REST API call, let's say it's in a variable/register named ouput. The data looks like below. For completeness, I shared the ...
zagpoint's user avatar
  • 149
0 votes
1 answer
56 views

I have two deferred publishers emitting an array of Ints. They are Futures under the hood of that maters. I would like to have these two publishers "run" in parallel so lets say p1 returns [...
CalebK's user avatar
  • 737
0 votes
1 answer
177 views

I have a following synthetic example: final class MainViewModel: ObservableObject { @Published var response: String? func makeSecondaryViewModel() -> SecondaryViewModel { ...
Richard Topchii's user avatar
0 votes
0 answers
392 views

I am building an app that is mostly not a grid view. However there is one screen that is a grid view and because I need the extra preloading performance in order to prioritize fast scrolling image ...
CalebK's user avatar
  • 737
4 votes
1 answer
667 views

I was under the impression that Combine is supposed to be thread safe, even though the documentation is sparse. I noticed that when publishing to a CurrentValueSubject on a thread other than the one ...
Guig's user avatar
  • 10.6k
2 votes
3 answers
143 views

I have a ObservableObject class that has a @Published variable that is mutable. I have a function that mutates the value on the ObservableObject class a number of times. How could I collect the ...
Aswath's user avatar
  • 1,548
0 votes
0 answers
70 views

Following Apple's documentation on components, I think I understand the basic idea. A component is an object that captures the state of an entity and can be manipulated by a system. So far so good, I ...
Salvador   Molina's user avatar
-1 votes
1 answer
144 views

I want to use the MVVM approach to separate UI presentation logic from the view presentation itself. I'm doing it like this: struct ViewA: View { @StateObject var viewModel: ViewModel ...
Diego A. Rincon's user avatar
-2 votes
1 answer
126 views

So I having a trouble when reading the Convert incoming raw data to your types with Combine operators section of Processing URL session data task results with Combine article. Here is the template ...
Avicii4ever's user avatar
0 votes
0 answers
205 views

I have a simple Microphone class which conforms to @Observable, with public properties that trigger redraws for some SwiftUI Views. But I also want these property changes to trigger logic in non-Views,...
NRitH's user avatar
  • 14k
2 votes
1 answer
69 views

Consider the following snippet: enum MyError: Error { case test } let subject = PassthroughSubject<Int, MyError>() subject .eraseToAnyPublisher() .last(where: { $0 % 2 == 0 }) .sink(...
chlkdst's user avatar
  • 197
-1 votes
1 answer
98 views

I'm trying to observe a publisher so that I wait till I encounter a particular value, at which point, I start a task. To have it play well with existing structured concurrency code, I added a ...
Aswath's user avatar
  • 1,548
0 votes
1 answer
443 views

The following code gives error when building under Swift 6 language version in Xcode. Is this an issue in architecture or has an easy fix? Type Bool is Sendable but it's publisher is not. Non-sendable ...
Deepak Sharma's user avatar
0 votes
2 answers
136 views

I want to initialise all properties in my class. I don't want isEmptyPublisher property to start working when it is first accessed. I want it to start working as soon as it is initialised. Why can't I ...
user10711707's user avatar
1 vote
1 answer
328 views

I am using the Combine framework in my iOS project, and I am writing unit tests for my code. However, I encounter problems when testing code that uses schedulers. Here's an example of a function I ...
Levan Karanadze's user avatar
-1 votes
1 answer
184 views

I have a view model, that has a network service that returns us a Combine publisher. The VM reacts to this publisher by updating its state. And the UIViewController would then update based on the VM ...
iOSer's user avatar
  • 274
8 votes
3 answers
3k views

Consider this XCTest-based unit test: func testImageRetrieved() { let expectation = XCTestExpectation() let cancellable = viewModel.$image.dropFirst().sink { _ in // Do nothing on completion. ...
lazarevzubov's user avatar
  • 2,493
1 vote
0 answers
389 views

In iOS development using Swift, what options do I have for testing code that utilizes the Combine framework? Specifically, I'm looking to test a function that returns an AnyPublisher asynchronously. I ...
Levan Karanadze's user avatar
0 votes
1 answer
248 views

I am writing a text editing field that autosaves to a server. I wrote this helper view to make debouncing such views simple. The trick is I need to support when there is an initial value or when a new ...
CalebK's user avatar
  • 737
1 vote
1 answer
478 views

I am trying to initialize my MapKit Map in SwiftUI using the User's Location I obtained from Core Location, currently I initialize my Map with a MapCameraPosition type Variable, how can I start the ...
HugoOchoaLP's user avatar
0 votes
0 answers
282 views

When it comes to debouncing text fields I find just about every example does so in the view. And while this is ok I guess logically in my case it would be a better fit for the view model. In theory ...
CalebK's user avatar
  • 737
0 votes
1 answer
109 views

I'm trying to test my client code which uses Apple's Timer.publish(every:on:in:). I want to control time in my unit tests to avoid using wait(for:timeout:) and be able to test everything synchronously....
grego's user avatar
  • 512
2 votes
2 answers
426 views

I am currently working on a system communicating some UserDefaults values to another system on change. I was trying to use UserDefaults.standard.publisher as seen in the example below to observe ...
timfraedrich's user avatar
0 votes
1 answer
135 views

I'm trying to use Combine instead of delegates while implementing the Coordinator pattern. However, when I remove a coordinator from the childCoordinators list, it causes a memory leak. How can I ...
Shape Fit's user avatar
0 votes
1 answer
123 views

In this code, why debug: multicast triggered.. is printed only once while there are 2 subscribers. Since Apple says multicast(_:) creates a new publisher for each subscriber, shouldn't the print ...
Shuaiqing Luo's user avatar
0 votes
1 answer
222 views

I have the following code for mapping ReactiveSwift SignalProducer to Combine Publisher: import Combine import Foundation import ReactiveSwift /// This is a custom Publisher that wraps SignalProducer ...
user27576792's user avatar
1 vote
1 answer
109 views

I’ve written SwiftUI code that uses Combine to display CPU usage metrics such as User, System, Nice, and Idle values for each core on the system. The functionality works initially in the sense that ...
Karl Ehrlich's user avatar
-1 votes
1 answer
91 views

here is the function , and in postman when I put Accept-Language "en" it get the data in English , but my code not , why func fetchDataByToken<T: Decodable>(urlString: String, type: T....
Mohamed's user avatar
  • 11
0 votes
1 answer
68 views

when I post comment I have to fetch the comment list (all product details) again to show the new comment I use combine , any solution to show the comment immediately in the comments list when post? ...
Mohamed's user avatar
  • 11
2 votes
1 answer
424 views

I’m encountering an issue in my app where a test occasionally fails. I’ve managed to narrow the problem down to this code snippet. The snippet contains two asynchronous sequences that both observe and ...
user27165230's user avatar
0 votes
1 answer
131 views

Example code: class SwiftViewController: UIViewController { private var cancellable: AnyCancellable? override func viewDidLoad() { super.viewDidLoad() let ...
Yanni Wang's user avatar
0 votes
1 answer
36 views

I am learning Combine on iOS. This is my code: struct ContentView: View { let aiRepsonse = "View the latest news and breaking news today for U.S., world, weather, entertainment, politics and ...
Rufus's user avatar
  • 689

1
2 3 4 5
42