Category "combine"

SwiftUI/Combine: subscribe to value change of @Binding

I have a view with a view model, and actions in this view can change the view model. To be able to break out logic into reusable pieces, I have part of the view

Unit Testing Combine

I'm having difficulties testing Combine. I'm following: https://www.swiftbysundell.com/articles/unit-testing-combine-based-swift-code/ Which tests: final class

SwiftUI Binding default value (Argument labels '(wrappedValue:)' do not match any available overloads)

In Swift you can define default values on a struct that can be overwritten on initialization: struct myStruct { var a: Int = 1 } var instance1 = myStruct()

iOS Swift Combine: cancel a Set<AnyCancellable>

If I have stored a cancellable set into a ViewController: private var bag = Set<AnyCancellable>() Which contains multiple subscription. 1 - Should I canc

Difference between CurrentValueSubject and @Published

So I'm digging into combine and this question came up. Is there any real difference between using CurrentValueSubject (and setting its value using currentValue

Swift Combine - @Published property Array

I am currently doing a project using SwiftUI and Combine. I'm on Xcode11 Beta 5. I would like to fetch my Github repositories, display them and then be able to

Create a Timer Publisher using Swift Combine

I've been watching the Data Flow Through SwiftUI WWDC talk. They have a slide with a sample code where they use a Timer publisher that gets connected to a Swift

What does the dollar sign do in Swift / SwiftUI?

This tutorial by Apple about SwiftUI uses a dollar sign to bind data, and I‘m having trouble finding more information about this data binding in SwiftUI.

How to have a publisher emit only to the last subscriber in Combine

Is there a way to have the publisher emit a value only to the latest subscriber/observer? An example for that would be; a manager class that can be subscribed t

Combine bind Publisher to PassthroughSubject

This question has effectively been asked before (Combine assign publisher to PassthroughSubject) but the answer assumed the architecture of the question's examp

EXC_BAD_ACCESS when initializing Dictionary of CurrentValueSubject in Swift

I am trying to create a class that executes data loading once and returns the data to all callers of the method while the data was loading to not perform the da

How do I properly test a var that changes through a publisher in my viewModel in XCTestCase

Im trying to test a simple publisher within the Combine framework and SwiftUI. My test tests a published bool named isValid in my view model. My view model al

Passing an ObservableObject model through another ObObject?

I feel like I can sort of understand why what I'm doing isn't working but I'm still trying to wrap my head around Combine and SwiftUI so any help here would be

Binding ViewModel and TextFields with SwiftUI

I'm looking for the best way to create a bind between textfields and ViewModel. At the moment I'm creating a @State for each textfield and I'm manually sending

Binding value from an ObservableObject

Aim: I have a model which is an ObservableObject. It has a Bool property, I would like to use this Bool property to initialise a @Binding variable. Questions:

Swift Combine - Accessing separate lists of publishers

I have two lists of URLs that return some links to images. The lists are passed into a future like static func loadRecentEpisodeImagesFuture(request: [URL]) -&g

Swift Combine HTTP request

Trying to figure out how to make quick http requests using combine. I've mostly been looking at this doc by Apple. I haven't made any progress though and it see

How do you share a data model between a UIKit view controller and a SwiftUI view that it presents?

My data model property is declared in my table view controller, and the SwiftUI view is modally presented. I'd like the presented Form input to manipulate the d

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 seem

How to define a protocol to include a property with @Published property wrapper

When using @Published property wrapper following current SwiftUI syntax, it seems very hard to define a protocol that includes a property with @Published, or I