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
1 | OTHER_LDFLAGS = -weak_framework Combine |
Issue #593
#if canImport(Combine) is not enough, need to specify in Other Linker Flags
1 | OTHER_LDFLAGS = -weak_framework Combine |
Issue #527
1 | import Foundation |
Issue #513
A publisher that emits before the object has changed
Use workaround DispatchQueue to wait another run loop to access newValue
1 | .onReceive(store.objectWillChange, perform: { |
Issue #506
When a function expects AnyPublisher<[Book], Error> but in mock, we have Just
1 | func getBooks() -> AnyPublisher<[Book], Error> { |
There will be a mismatch, hence compile error
Cannot convert return expression of type ‘AnyPublisher<[Book], Just
The reason is because Just produces Never, not Error. The workaround is to introduce Error
1 | enum AppError: Error { |
1 | func getBooks() -> AnyPublisher<[Book], Error> { |
Updated at 2020-11-07 20:30:01
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
Transforms all elements from an upstream publisher into a new or existing publisher.
1 | struct FlatMap<NewPublisher, Upstream> where NewPublisher : Publisher, Upstream : Publisher, NewPublisher.Failure == Upstream.Failure |
A publisher that publishes a given sequence of elements.
1 | struct Sequence<Elements, Failure> where Elements : Sequence, Failure : Error |
1 | func fetchItems(completion: @escaping ([ItemProtocol]) -> Void) { |