Quantcast
Browsing latest articles
Browse All 29 View Live

[Coombine][Publishers] how to use maxPublishers

not sure the following logic will create three publishers? [1,2,3].publisher [1,2,3,4].publisher .flatMap(maxPublishers: .max(1)) { result in change(result) }.sink { result in print(result)...

View Article


[Combine]subscribe method

I know publisher has a method subscribe(_ subject: Subject) let arrPublisher = [1,2,3,4].publisher let tester = PassthroughSubject<Int, Never>() arrPublisher.sink { result in print(result)...

View Article


[Combine]throttle bug?

let subject = PassthroughSubject<String, Never>() let throttled = subject.throttle(for: .seconds(10), scheduler: DispatchQueue.main, latest: false) throttled.sink(receiveValue: {print($0,...

View Article

Image may be NSFW.
Clik here to view.

Chapter 15.9 EnvironmentObject usage

Here is the moment at the end of the chapter, that describes “you need to add EnvironmentObject to ReaderView”: One as a property - @EnvironmentObject var settings: Settings Second as pass param to...

View Article

Chap 2: Understanding what's going on

Under the above heading you explain: 3. A subscriber calls subscribe(_:) on a publisher to attach to it. 4. The implementation of subscribe(_:) will call receive(subscriber:) to attach the subscriber...

View Article


Debounce unit test

Hello, Let’s suppose we have a a string as a published property in our view model. We subscribe to this published property in our view model and use different combine operators. One of these operators...

View Article

Chapter 14.3: Complexity vs easier alternative?

When I first read the task for mergedStories I initially thought about using a flatMap and wondered about the complexity used in that function (creating array, remainder, merge). So I tried a...

View Article

Chapter 15: Lots of warnings

I’m following the text, adding to the starter/HNReader.xcodeproj Looking for the first numbers to appear when adding .onAppear method, I find my debug output cluttered with lots of warnings (I’m on...

View Article


Chapter 18: Purpose of .max(1)

In chapter 18, when defining the DispatchTimerSubscription you use self.requested -= .max(1) self.timer -= .max(1) and I wonder what .max(1) actually does and why it’s needed. I imaging it creates a...

View Article


Why do publishers subscribe instead of subscribers?

Hello, Could someone please help me understand why linguistically a publisher connects to a subscriber instead of the other way around? For example in Chapter 2: Custom Subscriber, we do: let...

View Article

Question for Combine: Asynchronous Programming with Swift

Hello I am studying Combine with the book, and I have questions on Chapter 18. There is a description like below, and I can not understand what it means. Specifically on bold text. Use the handy...

View Article

Charter 18 error: Publisher is only available in iOS 13.0

‘Publisher’ is only available in iOS 13.0 or newer extension Publisher { help me please 3 posts - 3 participants Read full topic

View Article

Child view-models state management with SwiftUI and Combine

This is more of an opinion/architecture question, with questions that arose out of chapter 15 from the Combine + SwiftUI book. I have a rather larger screen that I am building with SwiftUI and...

View Article


What is different between Async/Await, Combine, Closures?

Hello Kodeco team, Like the question in the title, I really wonder why apple built so many solutions for concurrency? difference between them? When should it apply? nghiaphamsg 3 posts - 2...

View Article

How KVO options really works (.old and .new)?

I don’t understand how .old and .new options work. Would anyone have an example to show? 1 post - 1 participant Read full topic

View Article


Errata for Combine: Asynchronous Programming With Swift 4th Edition

Creating this topic to catch any typos and bugs in the 4th Edition of Combine: Asynchronous Programming With Swift. 2 posts - 1 participant Read full topic

View Article

Chapter 18, Custom Publisher & Ownership

When creating a custom publisher, you also create a custom subscription. In the book ShareReplay example, the ShareReplay subscription owns a reference to the subscriber, but I don’t see that it holds...

View Article


How do i observe an Array when append or remove element with Combine?

When I adding or removing element in names array, no any result. following the code. Could you give and advice? class SomeClass: NSObject { @objc var names = ["A", "B", "C"] var cancellable:...

View Article

Chapter 2: Question about notification

I do a simple notification test with combine. Click postNotification button in ViewController that received notification successful. Click removeReceiver button (set _receive to nil) in ViewController...

View Article

Chapter 2: error when I try to run playground

I see the following error at the top of xcode when I try to run the playground: Failed to launch process. Failed to compile sandbox profile: sandbox_extension_issue_file: Operation not permitted I get...

View Article

Image may be NSFW.
Clik here to view.

Spelling Error Chapter 20

Hi There - Noticed that SwiftUI is missing an ‘I’ character in this note. 3 posts - 2 participants Read full topic

View Article


Are there more book updates coming?

Hi, The last version of this book was Jul 19, 2023 · iOS 16, Swift 5.8, Xcode 14. Just wondering if this will be updated for iOS 17 / 18 or is another book being created? Thanks. 2 posts - 2...

View Article


How to use @Observable to publish a class' properties

I have tried to modify ColorCalc in chapter 19 to use @Observable for the CalculatorViewModel. There were several issues which I could not solve. Can no longer use @Published for properties. Cannot...

View Article

Chapter 2: Bridging Combine Publishers to async/await

Why does this code snippet produces different results? example(of: "async/await") { let subject = CurrentValueSubject<Int, Never>(0) Task { for await element in subject.values { print("Element:...

View Article

Chapter 4. Finding Values `last(where:)`

example(of: "last(where:)") { enum MyError: Error { case test } let subject = PassthroughSubject<Int, MyError>() subject .eraseToAnyPublisher() .last(where: { $0 % 2 == 0 })...

View Article

Browsing latest articles
Browse All 29 View Live