combine Questions

4

Solved

I've implemented a List with a search bar in SwiftUI. Now I want to implement paging for this list. When the user scrolls to the bottom of the list, new elements should be loaded. My problem is, ho...
Giarla asked 22/1, 2020 at 21:18

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...
Hirsutism asked 15/8, 2019 at 23:24

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 ...
Beading asked 5/10, 2023 at 13:16

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...
Spivey asked 30/1, 2021 at 7:30

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 ...
Epigenesis asked 22/1, 2021 at 18:46

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 ...
Hopping asked 30/6, 2019 at 20:22

7

Solved

When trying to compile the following code: class LoginViewModel: ObservableObject, Identifiable { @Published var mailAdress: String = "" @Published var password: String = "" ...
Kacey asked 6/8, 2020 at 11:14

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: ...
Dameron asked 29/11, 2019 at 10:35

4

Solved

I have such code func request(request: URLRequest) -> AnyPublisher<Data, Error> { return Just(request) .flatMap { request in RequestManager.request(request) // returns AnyPublisher<...
Removed asked 18/8, 2019 at 10:55

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...
Virilism asked 8/4, 2020 at 19:53

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...
Ferretti asked 22/5, 2020 at 16:31

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...

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...
Sawyers asked 14/10, 2019 at 20:49

2

Solved

class ObservableFormViewModel: ObservableObject { @Published var isSubmitAllowed: Bool = true @Published var username: String = "" @Published var password: String = "" var s...
Stifling asked 1/9, 2020 at 22:50

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...
Harpole asked 8/7, 2019 at 0:50

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,...
Disinter asked 15/1, 2020 at 1:14

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...
Fancher asked 24/5, 2023 at 4:26

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...
Atalante asked 12/11, 2019 at 8:31

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...

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...
Encarnacion asked 2/11, 2019 at 20:57

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...
Chelsae asked 9/10, 2020 at 19:39

© 2022 - 2024 — McMap. All rights reserved.