combine Questions
4
Solved
11
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 definitely need help :)
As I'm imple...
3
I wish to apply a custom property wrapper to a variable already wrapped in @Published, nesting them like
(A) @Custom @Published var myVar or
(B) @Published @Custom var myVar
(notice the application...
Terylene asked 9/2, 2021 at 12:9
1
SwiftUI 5 now uses the @Observable wrapper to observe changes in a class instead of conforming it to ObservableObject. This gets rid of @Published wrappers which I actively use in my workflow:
Old ...
2
Solved
I'm subscribing the the built-in User Defaults extension, but it seems to be firing multiple times unnecessarily.
This is the code I'm using:
import Combine
import Foundation
import PlaygroundSuppo...
2
Solved
I have a question about the subscribe(on:options:) operator. I would appreciate if anyone can help me to figure it out.
So what we have from the documentation:
Specifies the scheduler on which to ...
9
I'm trying to figure out the best way to build a simple settings screen bound to UserDefaults.
Basically, I have a Toggle and I want:
the value a UserDefault to be saved any time this Toggle is ...
7
Solved
When trying to compile the following code:
class LoginViewModel: ObservableObject, Identifiable {
@Published var mailAdress: String = ""
@Published var password: String = ""
...
4
Solved
I'm using swiftUI and combine, I'have some business logic in my VM. Some results have to dismiss my view.
I'v used this one in some views :
@Environment(\.presentationMode) var presentationMode: ...
4
Solved
I have such code
func request(request: URLRequest) -> AnyPublisher<Data, Error> {
return Just(request)
.flatMap { request in
RequestManager.request(request) // returns AnyPublisher<...
6
My app contains a resource heavy operation that populates an Array based on data pulled from an XML feed. I do not want this operation to lock up the main thread (and the UI when the array is given...
4
Solved
I'm working on an iOS application adopting the MVVM pattern, using SwiftUI for designing the Views and Swift Combine in order to glue together my Views with their respective ViewModels.
In one of m...
7
I happen to look into Apple's new Combine framework, where I see two things
PassthroughSubject<String, Failure>
CurrentValueSubject<String, Failure>
Can someone explain to me what i...
Nettlesome asked 2/3, 2020 at 4:55
2
It is the first time for me working with AppKit and a NSTableView. It is backed by a NSFetchedResultsController for Core Data. When there are changes to the dataset, a Notification is being sent:
f...
Tbar asked 15/6, 2022 at 15:48
5
Solved
I have some code that is built using RxSwift, and I'm playing around with converting it to use Apple's Combine framework.
One pattern which is very common is the use of Observable.create for one-s...
2
Solved
class ObservableFormViewModel: ObservableObject {
@Published var isSubmitAllowed: Bool = true
@Published var username: String = ""
@Published var password: String = ""
var s...
1
I am building a simple settings screen.
When then first setting is activated, the Speed Control appears. When it's turned off, the Speed Control disappears.
Based on what I know about SwiftUI, th...
9
Solved
How do I get the asynchronous pipelines that constitute the Combine framework to line up synchronously (serially)?
Suppose I have 50 URLs from which I want to download the corresponding resources,...
1
What is the expected thread on which a .collect operation in Swift's Combine will emit?
Specifically I am seeing this code crash in the second precondition, but not the first:
return Publishers.Mer...
3
Solved
I created a function that returns a custom Publisher in Swift Combine using the code below:
func customPubliher() -> AnyPublisher<Bool, Never> {
return Future<Bool, Never> { promis...
1
Solved
I try to figure out is this approach thread safe if getStream() and update(value: ...) will be called on difference thread simultaneously?
final class SomeNotifier {
static let shared = SomeNotifi...
Kappa asked 27/3, 2023 at 11:28
1
Solved
I'm trying to make a property wrapper similar to Combine's Published one(for my project needs), but with ability to modify the wrapped property by sending a value to a publisher, stored in projecte...
Strage asked 16/3, 2023 at 19:38
8
Given the following code:
enum MyError: Error {
case someError
}
myButton.publisher(for: .touchUpInside).tryMap({ _ in
if Bool.random() {
throw MyError.someError
} else {
return "we're in...
2
Solved
A typical way to chain AnyPublisher is to use Combine operators like flatMap.
class MyService {
func getUserList() -> AnyPublisher<[User], Error> {
....
}
func getPostList(user: User...
Laurelaureano asked 13/6, 2022 at 23:10
3
Solved
I have a sink that needs to be canceled as soon as I receive the first value. I don't care about future values, just the first one published. Because without storing the AnyCancelable created by th...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.