combine Questions

6

The ObservableObject protocol defined by the Combine framework has an objectWillChange publisher property that lets you know when the properties of this object will change, meaning that, if subscri...
Celluloid asked 29/12, 2019 at 12:45

1

This Kodeco tutorial shows how to display an iOS live camera feed in SwiftUI using Combine. Here are the essential parts doing this (after stripping away non-essential code lines): class FrameManag...
Cide asked 24/12, 2022 at 13:45

3

Solved

I am studying and trying out a few stuff with Combine to apply on my own and came into the following situation with this contrived example.. let sequencePublisher = [70, 5, 17].publisher var cancel...
Cymric asked 19/3, 2021 at 17:42

1

Solved

I have a publisher, pipelinePublisher, which runs a combine pipeline of various operations, some of which send a state update to a statePublisher passed in as an argument. pipelinePublisher gets re...
Octavia asked 21/12, 2022 at 15:41

1

Followed refresh token strategy from this gist - https://gist.github.com/saroar/ca78de9dc798cdbaaa47791380062596 but couldn't get it working. Ideal flow - run function from NetworkAgent will make a...
Skein asked 13/4, 2021 at 13:57

3

Solved

Combine subscription sample code snippet all store the resulting subscription into the subscriptions set private var subscriptions = Set<AnyCancellable>() Why do we need to do it? future .s...
Lifeline asked 23/8, 2020 at 4:39

1

Solved

I have a model that has a myState Bool and in a controller I sink to it like this: model.$myState .dropFirst() .removeDuplicates() .receive(on: RunLoop.main) .sink { [weak self] myState in print(&...
Slumgullion asked 15/11, 2022 at 21:51

9

I'm using Swift Combine for my API requests. Now I'm facing a situation where I want to have more than 4 parallel requests that I want to zip together. Before I had exactly 4 requests that I zipped...
Vortex asked 21/2, 2020 at 20:27

3

iOS13's Combine streams of publishers don't appear to be flowing after operator using schedulers. Here's my code: import Foundation import Combine struct MyPublisher: Publisher { typealias Outp...
Sciential asked 12/7, 2019 at 16:7

2

Solved

I have a LoginView that shows a RegisterView if the user is not logged in, and a ContentView if he is logged in: struct LoginView: View { @EnvironmentObject var userManager: UserManager var body:...
Eddins asked 1/2, 2020 at 13:59

5

Solved

I'm starting to experiment with SwiftUI and I have a situation where I want the latest combination of 5 sliders. I had everything working with 4 sliders, using CombineLatest4, then realized I need ...
Timbuktu asked 12/5, 2020 at 1:18

3

I am learning Swift Combine now, found quite easy video tutorial, however for some reason I get error when I try to use my enum in PassthroughSubject<Int, WeatherError>() Check this code: imp...
Isacco asked 15/11, 2020 at 15:7

15

Solved

I have a SwiftUI view that takes in an EnvironmentObject called appModel. It then reads the value appModel.submodel.count in its body method. I expect this to bind my view to the property count on ...
Waddle asked 16/10, 2019 at 5:28

2

I keep the Model as a Published var in the ViewModel and Observe it from the View. When the model process goes into a background thread, if you publish the model value, the Xcode thread check...
Musketeer asked 8/1, 2022 at 4:42

1

So I want to implement a custom control as a UIViewRepresentable which correctly handles focus using an @FocusState binding. So I want to be able to manage the focus like so: struct MyControl: UIVi...
Atonic asked 18/4, 2022 at 10:55

1

Solved

I have a ProtocolName that conforms to ObservableObject. I then have ClassName that conforms to ProtocolName. However, when I try to use @ObservedObject serviceName: ProtocolName = ClassName,...
Charily asked 19/9, 2022 at 16:2

6

Solved

I don't quite understand how to properly store subscribers inside a class so that they persist but don't prevent the object from being deinitialized. Here's an example where the object won't deinit...
Contrariwise asked 17/9, 2019 at 18:58

3

Solved

Let's say that we have a following code written in Swift that uses Combine: import UIKit import Combine class Test { @Published var array: [Int] = [] { willSet { print("willSet \(newValue....
Bitterling asked 15/11, 2021 at 16:51

3

Solved

So I'm trying to learn SwiftUI and Combine. I usually start new tech by making a simple tip calculator. I seem to be getting a random "Extra argument in call." error while coding Here is my Swif...
Mayence asked 12/4, 2020 at 22:11

1

Solved

Recently, I have been learning Swift's Combine framework. In Apple's words: The Combine framework provides a declarative approach for how your app processes events. Rather than potentially impleme...
Munoz asked 1/9, 2022 at 6:14

2

Solved

I have the following code and Im getting the message error: 'wrappedValue' is unavailable: @Published is only available on properties of classes //* /** Chat Created on 29/07/2020 */ import Swif...
Parsnip asked 1/8, 2020 at 6:46

3

Solved

How can I rewrite ReactiveSwift/ReactiveCocoa code using Combine framework? I attached screenshot what combinePrevious mean from docs. let producer = SignalProducer<Int, Never>([1, 2, 3]).com...
Tenacious asked 16/9, 2020 at 18:52

6

Solved

I'm trying to execute an action every time a textField's value is changed. @Published var value: String = "" var body: some View { $value.sink { (val) in print(val) } return TextField($value...
Solarism asked 24/6, 2019 at 11:14

2

Solved

I have a model type which looks like this: enum State { case loading case loaded([String]) case failed(Error) var strings: [String]? { switch self { case .loaded(let strings): return string...
Polivy asked 7/1, 2020 at 19:42

4

Solved

I'm just learning how to use Combine. I have experience with Rx (RxSwift and RxJava) and I'm noticing that it's quite similar. However, one thing that is quite different (and kind of annoying) is ...
Lannylanolin asked 2/5, 2020 at 1:18

© 2022 - 2024 — McMap. All rights reserved.