0

I have two methods that chained by flatMap

        return requests
            .combineLatest()
            .flatMap({ response in
                Log.warning("\(response)")
                do {
                    return try self.uploadFS(connections: response.map({ $0.connection }))
                } catch {
                    return Just([Common_Empty]()).eraseToAnyPublisher()
                }
            })
            .eraseToAnyPublisher()

upload fs method returns own publisher

func uploadFS() -> AnyPublisher<[Common_Empty], Never> {
        let requests = makeRequests()
        return requests// return requests
            .combineLatest()
//            .sink(
//                receiveCompletion: { completion in
//                    Log.info("\(completion)")
//                },
//                receiveValue: { value in
//                    Log.info("Recieved value: \(value)")
//                }
//            )
//            .store(in: &Self.retainedCancellables)
            .eraseToAnyPublisher()
}

if I change return type value and will return Void uncommented block will be executed, but I dont understand why completion not sent to downstream

I tried catch completion in upstream and it works

  • Hey, which "completion" are you talking about? Are you referring to the `flatMap` closure? Is that logging out anything when it runs? Are you storing the cancellable anywhere for that? – Fogmeister Dec 21 '22 at 10:11
  • I say about completion of makeRequest() If i add print() after combineLatest() it will print receive subscription: (CombineLatest), request unlimited, receive finished, I stored cancellable in downstream – Iskander Nizamov Dec 21 '22 at 10:21

0 Answers0