Combine 5

How to weak link Combine in macOS 10.14 and iOS 12

Issue #593

#if canImport(Combine) is not enough, need to specify in Other Linker Flags

text
OTHER_LDFLAGS = -weak_framework Combine

Read more …

How to convert from callback to Future Publisher in Combine

Issue #527

swift
import Foundation
import Combine

public typealias TaskCompletion = (Result<(), Error>) -> Void

public protocol Task: AnyObject { …

How to use objectWillChange in Combine

Issue #513

A publisher that emits before the object has changed

Use workaround DispatchQueue to wait another run loop to access newValue

swift
.onReceive(store. …

How to map error in Combine

Issue #506

When a function expects AnyPublisher<[Book], Error> but in mock, we have Just

swift
func getBooks() -> AnyPublisher<[Book], Error> { …

How to flat map publisher of publishers in Combine

Issue #451

For some services, we need to deal with separated APIs for getting ids and getting detail based on id.

To chain requests, we can use flatMap and Sequence, then collect to wait and get all elements in a single publish

FlatMap

Transforms …