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
3 answers

Combine pipeline for object with image

I have built a simplified combine pipeline in my Xcode Playground, to make car objects [CarWithImage] from an array of cars, [Car]. That seems to work fine. But I would like the pipeline to check each car object for imageString, and if it isn't nil…
Ivan C Myrvold
  • 680
  • 7
  • 23
0
votes
1 answer

Swift Combine framework setFailureType error operator

For scientific reasons I've created a Publisher and a Subscriber so I can dive into Combine. The Publisher has been converted from a never failing to the failing one. enum IntegerError: String, Error { case miltupleOf2 = "We are sorry but the…
Jakub Gawecki
  • 801
  • 2
  • 6
  • 14
0
votes
1 answer

XCTest testing asyncronous Combine @Publishers

I'm working on an iOS app (utilizing Swift, XCTest, and Combine) trying to test a function within my view model, which is calling and setting a sink on a publisher. I'd like to test the view model, not the publisher itself. I really don't want to…
0
votes
1 answer

Problems creating a generic MVVM connector to CoreData

First of all, sorry about the post length but I am very new to iOS and SwiftUI development and I don't want to miss any details. I did some small projects with Kotlin on Android and Flutter, so I had some experience in app development. Context I…
lucasmenendez
  • 116
  • 1
  • 11
0
votes
1 answer

Using a Published var to observe a switch case in a Publisher with Combine

I have an enum case which is a @Published var in an ObservableObject class. What I'm trying to do is observe changes to the term var defined below and update an annualRate publisher. Below is the @Published var @Published var term: MortgageTerm =…
Adrian
  • 16,233
  • 18
  • 112
  • 180
0
votes
0 answers

flutter: StreamBuilder doesn't accept merged stream

i have a problem with merged stream and StreamBuilder. im trying to merge multiple streams from firestore that each one represents a grocery list. my result should be a ListView that combines all list in a some group. from some reason,my…
0
votes
1 answer

iOS Combine debounce fire manually

I am using the debounce Operator of the iOS Combine Framework. var subject = PassthroughSubject() var cancellable: Cancellable! cancellable = subject .debounce(for: .seconds(0.1), scheduler: RunLoop.main) .sink { //…
Laufwunder
  • 773
  • 10
  • 21
0
votes
1 answer

Optimize list searches

How can I optimize the searches in the list. I have two thousand records. I don't want to do a search through NSPredicate, because I want to pass what is in the field through a function that cleans up the numbers and reduces the letters, before…
oculorum
  • 49
  • 5
0
votes
1 answer

PassthroughSubject with completion handler output?

I'm just getting started with Combine. I have these questions for this situation: Is it accepted to have a tuple as a PassthroughSubject output? Is it accepted to have a completion handler as part of the PassthroughSubject output? Example…
Simon
  • 1,354
  • 1
  • 14
  • 18
0
votes
1 answer

Swift Combine: Waiting until subscribed to generate values

I'm trying to write a custom publisher that generates some values. Something like this: class MyPublisher: Publisher { typealias Output = Int typealias Failure = Never private let subject = PassThroughSubject() func…
drekka
  • 20,957
  • 14
  • 79
  • 135
0
votes
2 answers

Is there a way to detect when a publisher has a new subscriber? | Swift, Combine

I'm developing a MVVM structure with API calls. I have this structure now: //Get publisher loginPublisher = LoginService.generateLoginPublisher() //Create a subscriber loginSubscriber = loginPublisher! .sink { error…
0
votes
1 answer

How to create a NavigationManager that would change tab within view models?

I have a NavigationManager to handle changing SwiftUI tab bar selection. It work if it is set as a @EnvironmentObject in my SwiftUI views, but not when the NavigationManager is called as a service in my view models. The thing is that I would like to…
Roland Lariotte
  • 2,606
  • 1
  • 16
  • 40
0
votes
1 answer

Create a publisher that emits a value on completion of another publisher

I have a publisher that never emits items and only completes or fails with an error (AnyPublisher). I want to transform that publisher into a publisher that emits a value when the first publisher completes (AnyPublisher),…
Nick
  • 3,958
  • 4
  • 32
  • 47
0
votes
1 answer

Combine and nested JSON objects

I have the following model: struct Book: Codable, Identifiable { var id: Int var title: String var author: String } struct BookWrapper: Codable { var books: [Book] } and JSON: { "books": [ { "id": 1, …
BobC
  • 639
  • 5
  • 19
0
votes
2 answers

How to best create a publisher aggregate of @Published values in Combine?

Given an hierarchical structure of @OberservableObjects - I often find myself in a situation where I need a publisher which provides some kind of updated aggregate of the entire structure (the example below calculates a sum, but it could be…
Michael J
  • 145
  • 10
1 2 3
99
100