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...
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...
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...
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...
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...
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(&...
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...
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...
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 ...
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...
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 ...
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...
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,...
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...
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....
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...
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...
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...
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...
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...
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.