I have a Swift publisher like the following
let item = PassthrogutSubject<String, Never>()
Upon receiving the String I want to make a network request
For that, I'm using flatMap
My network request signature looks like this:
func loadDetails(_ code: String) -> AnyPublisher<CustomType, ErrorAlert>
How can I do the following:
$item
.filter { !$0.isEmpty }
.flatMap { [unowned self] (string) in
self.viewModel.loadDetails(string) }
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: { _ in
...
}) { ... }
.store(in: &subscriptions)
error:
Instance method 'flatMap(maxPublishers:_:)' requires the types 'Published<Value>.Publisher.Failure' (aka 'Never') and 'Alert' be equivalent