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

SwiftUI SearchBar keyword not publishing value to viewModel

I made a custom SearchBar with SwiftUI and put it in the view, having BookListViewModel as @ObservedObject, but how do it call fetchBooks() from BookListViewModel and show as list? Here is my SearchView() struct SearchView: View { …
J L
  • 11
0
votes
1 answer

Combine map with switchToLatest confuse

I have a source publisher, and have an another publisher rely source publisher. This is playground test code for my situation: import Foundation import Combine import PlaygroundSupport PlaygroundPage.current.needsIndefiniteExecution =…
sunny
  • 43
  • 5
0
votes
2 answers

How can I catch that @Published has changed with combine ? (UIKit)

It takes data in my @Published variable in CarDetailViewModel, but I could not pass the data inside this variable to the variable in the ViewController. ViewModel: class CarDetailViewModel: ObservableObject { @Published var carDetail: Car =…
Ufuk Köşker
  • 1,288
  • 8
  • 29
0
votes
1 answer

How to add and delete objects from a List from an object who's inside another List in SwiftUI and Realm

In the following code I have a List of Cars and each Car from that list has its own list of Services, I can add and delete Cars without a problem by calling carViewModel.addNewCar(make:String, model:String) and carViewModel.deleteCar(at…
fs_tigre
  • 10,650
  • 13
  • 73
  • 146
0
votes
0 answers

JSON Pagination (20 data per page)

I want to get the first 20 data for the first page from the url below. I want to get the next 20 data on the second page. I don't want to get all the data in the first time. I just want to get the first 20…
Ufuk Köşker
  • 1,288
  • 8
  • 29
0
votes
0 answers

Is there a way to check if downstream handles a event a publisher publishes in Combine?

I have an event bus that publishes events happening over a custom text field(a chat message input box), like attachMediaEvent, sendMessageEvent, selectTextEvent. I want to provide provide default actions for the events, but only in case downstream…
Aswath
  • 1,236
  • 1
  • 14
  • 28
0
votes
0 answers

Cannot find root cause of an error "outlined release of model"

I have a consistent crash that I cannot find the solution for. In one of the modal views in my application, the user could create several cards and when the user is "DONE", I collect the created cards and POST them one by one(The modal view will…
Aswath
  • 1,236
  • 1
  • 14
  • 28
0
votes
1 answer

List item is not being updated

So I have a View with List of subviews that take an object. These objects come from array that is in my data manager. struct ContentView: View { @ObservedObject var manager = AppConnectivityManager.shared var body: some View { List { …
beowulf
  • 546
  • 1
  • 10
  • 16
0
votes
1 answer

SwiftUI+Combine - Dynamicaly subscribing to a dict of publishers

In my project i hold a large dict of items that are updated via grpc stream. Inside the app there are several places i am rendering these items to UI and i would like to propagate the realtime updates. Simplified code: struct Item: Identifiable { …
mike_t
  • 2,484
  • 2
  • 21
  • 39
0
votes
1 answer

SwiftUI/Combine Are publishers bi-directional?

The execution of this code is confusing me: class RecipeListViewModel: ObservableObject { @Published var recipeList = [RecipeViewModel]() init(){ RecipeRepository.$allRecipeVMs.map { recipes in recipes.map {…
Spdollaz
  • 165
  • 10
0
votes
1 answer

"Receive canceled" when transform Publisher

I would like to create a module, that will refresh token if needed and repeat latest request using Combine from Apple. For now, every part is works well, but not this one: public func executeRequest( _…
hbk
  • 10,908
  • 11
  • 91
  • 124
0
votes
0 answers

Swift flatMap Error Type of expression is ambiguous without more context

func httpLoginSignal() -> AnyPublisher, Error>{ return API.shared.combine_loadModelResource(GetOauthTokenAPI(ccCode: "86", phone: "332134", authType: "password",password: "123456a"), type: OauthToken.self) …
corotata
  • 11
  • 1
0
votes
1 answer

Apple Combine add TapPublisher to UIView

Can I add a tap publisher to a UIView or UILabel? UIButton has tapPublisher built in. I tried making an extension, but extensions can't store properties. Also, is it bad practices to try and use a tap publisher on anything that isn't a button? …
Jay Strawn
  • 215
  • 3
  • 14
0
votes
2 answers

Chaining with flatMap

I'm having difficulty trying to figure out how to loop TMDb results from my publisher 1 and use the value I'm getting from key id for my second publisher. It's not looping through each result, it does get the proper URL inside my func fetchVideos(_…
cole
  • 1,039
  • 1
  • 8
  • 35
0
votes
1 answer

Observe property change in custom view SwiftUI

I created a custom view, NetworkImage, to load image asynchronously. import Combine import SwiftUI struct NetworkImage: View { @StateObject private var viewModel = NetworkImageViewModel() let url: String? let…
Edwin ZAP
  • 419
  • 1
  • 4
  • 16
1 2 3
99
100