Questions tagged [combine]

Combine is Apple's declarative Swift API for processing values over time. It is based on the Reactive Streams semantics. Use this tag for questions about the Combine framework.

Combine is a closed-source Apple framework based on semantics defined by the Reactive Streams initiative.

Combine defines a declarative API in the Swift programming language for processing values over time. Unlike other Swift reactive frameworks such as RxSwift and ReactiveSwift, Combine includes support for back-pressure and flow control at a fundamental level.

Apple first revealed Combine at WWDC on June 3, 2019 and made it available in the first beta release of Xcode 11.

Combine is part of the following SDKs:

  • macOS 10.15 (Catalina) and later,
  • iOS 13 and later,
  • tvOS 13 and later,
  • watchOS 6 and later.
1968 questions
0
votes
0 answers

Is Combine always required to make serial HTTP requests?

(note: I'm a beginner to programming) I just have a semantic question regarding Combine. I was under the impression that Combine was always required for serial HTTP requests but while experimenting I found that the following worked just fine: //…
pakobongbong
  • 123
  • 1
  • 9
0
votes
2 answers

How to retry a request with different input?

Goal to make retry with different input data. func generateRandomName() -> Int { ... } checkIfNameIsAvailable(generateRandomName()) .retry(10) // <- Makes 10 attempts with same link .sink( receiveCompletion: { completion in …
Artem Krachulov
  • 557
  • 6
  • 23
0
votes
1 answer

Swift Combine: Unknown attribute 'ObservedObject' error

I have the following implementation: final class Article: NSManagedObject { @NSManaged var title: String! @NSManaged var summary: String! } class someOtherClass { @ObservedObject var article: Article? } But I'm getting this…
user2924482
  • 8,380
  • 23
  • 89
  • 173
0
votes
2 answers

Notifications not sent when changing an ObservedObject

I have the following code: class Stuff { var str: String? var num = 0 } class MyStuff:ObservableObject { @Published var stuff:Stuff? @Published var numer: Int? } class DoSomething { let observedObject = MyStuff() var…
user2924482
  • 8,380
  • 23
  • 89
  • 173
0
votes
1 answer

How can I map to a type in Combine?

I have numerous pages where users may input information. They may input the fields with dates, numbers, or text. I am trying to receive all changes in Combine and get their outputs as Encodable so I can easily upload the results to the network. A…
Dr. Mr. Uncle
  • 484
  • 5
  • 12
0
votes
1 answer

Swift Combine: PassthroughSubject UnsafeMutablePointer

I have the following implementation: var flag = CurrentValueSubject(false) var flagChange = PassthroughSubject() var subscriptions = Set() init() { flagChange.sink { [unowned self]…
user2924482
  • 8,380
  • 23
  • 89
  • 173
0
votes
1 answer

iOS - Firestore same data retrieving multiple times

My goal: Retrieve data from firestore and display said data once. Problem: Same data is retrieving multiple times. If there is 5 rows of data, the array of my model retrieves 5 times. Why is this happening? Here is my firestore model: "Users -…
Trevor
  • 580
  • 5
  • 16
0
votes
0 answers

How to load next Image while user is looking at first image in the TabView pages carousel with AsyncImageView In SwiftUI?

I have an images carousel that fetching heavy images from a few URLs and displaying asynchronously when user is going to the next page. And the problem is that user need to see a waiting wheel and wait to see the next image. So the ideal case would…
ViOS
  • 187
  • 1
  • 12
0
votes
3 answers

Update property without running combine pipeline

If I have a combine pipeline, that prints changes to an array, is it then possible to update that array without having the pipeline run? class ObserveableTest: ObservableObject { private var cancellables: Set = [] @Published…
magnuskahr
  • 1,137
  • 9
  • 17
0
votes
0 answers

@Published Array is not updating

i'm currently struggling to fetch any changes from an published variable in SwiftUI. Most of the code is created after this tutorial on YouTube. It's basically an app, that fetches cryptos from a firebase database. To avoid high server costs I want…
gavisio
  • 79
  • 5
0
votes
1 answer

Executing Combine Publishers in parallel creates race condition

I'm trying to query HealthKit for heart rate values and steps in the time interval defined by a HKWorkoutEvent to fill a custom local model I have defined to store multiple variables, it's defined below. struct SGWorkoutEvent: Identifiable { let…
javierdemartin
  • 595
  • 6
  • 24
0
votes
1 answer

Combine Timer.TimerPublisher not starting

I'm creating a login token validity timer, and I figured it needs to be a singleton that ticks and every second (or every minute or whatever), checks to see whether the login token is still valid. But I can't even get the singleton to print a…
BaronSharktooth
  • 111
  • 1
  • 6
0
votes
0 answers

Swift Combine weird behaviour when returning from offline mode

In my application I have two View Models that make some work and publish their result via the @Published property. To simplify some code, I use another property alongside the published value to check if the work is complete. EDIT: I misused the…
Valerio
  • 3,297
  • 3
  • 27
  • 44
0
votes
1 answer

Combine return request response with different format

Hei, I have a SwiftUI with its viewModel. When the user taps on the Login button I run the viewModel.registerAccount function. func registerAccount() { authService.registerAccount(params: params) .sink { (dataResponse) in if…
Alexandru Vasiliu
  • 534
  • 1
  • 4
  • 18
0
votes
1 answer

Swift combine sequence of requests stop

So this is basically how my code looks. I run a request, when it's finished and i get some result, i run the next. I do this 3 times, however, it just dies efter the first one and wont continue. private func getSomething(with model: SomeModel) { …
Vollan
  • 1,887
  • 11
  • 26