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
1 answer

Crash when deleting an item from List in SwiftUI with custom RandomAccessCollection

Basic approach I am currently tring to clean up my Core Data/SwiftUI code, and part of that is moving code out of my Views and into my ViewModels. Since it seems that @FetchRequest does not work in VMs, I tried to create something similar that works…
BlackWolf
  • 5,239
  • 5
  • 33
  • 60
0
votes
2 answers

Swift binding to a computed property

Have the following situation. I have a view model that is an observable object with a computed property of type Bool. I want to be able to enable/disable a navigation link based on the computed property, but I need a binding to do so. Here a…
LeftiBus
  • 11
  • 5
0
votes
1 answer

dataTask in networking is not executing

In RestManager class, using URLSession I want to return AnyPublisher, Never>. So I made this code class RestManager { func fetchData(url: URL) -> AnyPublisher, Never> { return…
0
votes
1 answer

custom error type handling after receiving data from internet

I have RestManager class which is used to fetch data from Internet class RestManager { func fetchData(url: URL) -> AnyPublisher { URLSession.shared .dataTaskPublisher(for: url) .map { $0.data } …
0
votes
1 answer

I'm racking my head and can't figure out why I'm getting No value associated with key CodingKeys error

I've been racking my head for the last day trying to figure out why I'm getting the error below. I've tried changing from an array to a dictionary and no luck. failure(Swift.DecodingError.keyNotFound(CodingKeys(stringValue: "datalist", intValue:…
Robert
  • 809
  • 3
  • 10
  • 19
0
votes
0 answers

Combine two publishers in swift to observe NSManagedObjects?

I have the following publisher: func publisher(for managedObject: T, in context: NSManagedObjectContext, changeTypes: [ChangeType]) -> AnyPublisher<(object: T, type: ChangeType), Never> { let notification =…
zumzum
  • 17,984
  • 26
  • 111
  • 172
0
votes
1 answer

Swift Combine: is it available to obeserve zip multiple UIbuttons status?

I would like to enable "Proceed" button when every checkbox buttons are selected using combine and publisher. There must be the way to zip those multiple UIButtons(works on UIKit) isSelected status are all true.
dev Crying
  • 55
  • 1
  • 7
0
votes
2 answers

How to get unwrap value using combine framework

I am totally new at using the Combine framework. The struct I am using: enum AuthenticateResponse: Decodable, Hashable { struct Success: Decodable, Hashable { let url, id, firstName, lastName: String let email, phone: String …
Ferrakkem Bhuiyan
  • 2,741
  • 2
  • 22
  • 38
0
votes
2 answers

Firebase signInAnonymously using SwiftUI

Could anyone please help me with configuring the Firebase signInAnonymously? In fact, I am able to login anonymously. However, whenever I start a new simulator I get the error "There is no user logged in". The error disappears when restarting this…
0
votes
1 answer

Get reference for an @Published that can update the value

I'm trying to dynamically update a reference to an @Published var, but I'm not sure how to do it. Returning the value only is just a bool value and loses it's reference to the publisher and doesn't work. I tried returning the publisher itself…
Alex
  • 3,861
  • 5
  • 28
  • 44
0
votes
1 answer

Combine: How to stream an array of parsed objects via a publisher?

// get handle of native data task publisher let publisher = URLSession.shared.dataTaskPublisher(for: URL) .handleEvents( receiveSubscription: { _ in activityIndicatorPublisher.send(true) },…
Fabrizio Prosperi
  • 1,398
  • 4
  • 18
  • 32
0
votes
1 answer

Updates changes for nested models

ObservableObject doesn't emit change events for nested observables by default. Here a nested settings object within a view model, which is then observed by a view. In this small example, the menu doesn't see changes of settings (enable value). How…
Joannes
  • 2,569
  • 3
  • 17
  • 39
0
votes
0 answers

Combine merging database and network request outputs together

I consider how I can make stream that merges outputs from database and network request together in the following way: returns current state from database makes request, saved data to database, and returns them do caller via combine publisher let…
Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143
0
votes
1 answer

How to make this publisher extension generic

I have the following extension on a Publisher which allows me to paginate a URL request. I originally used this in a specific use case, where the Output of the publisher was of type CustomType. extension Publisher where Output == CustomType, …
Tometoyou
  • 7,792
  • 12
  • 62
  • 108
0
votes
2 answers

Combine: update values each other

The example code here is very simple. Sliders update double values but not the other way around. Using Combine how to update two or more sliders on each other? struct Centimeters { var value: Double func updateInches() -> Double { …
Joannes
  • 2,569
  • 3
  • 17
  • 39