I have 3 API call, all of them are being called using Publishers. API A & API B will be called first before API C got called. But API C should be called only when the response from API A & B met some conditions.
Currently I have these functions to get the API response:
func getAPIA() -> AnyPublisher<Response<ResponseA>, Error> { ... }
func getAPIB() -> AnyPublisher<Response<ResponseB>, Error> { ... }
func getAPIC() -> AnyPublisher<Response<ResponseC>, Error> { ... }
I have these line of code, it it possible to
Publishers.Zip3(
getAPIA(),
getAPIB(),
getAPIC() // --> How to make this being called based on the response of A and B
).sink(
receiveCompletion: { print($0) },
receiveValue: { [weak self] a, b, c in
// return value
}
).store(in: &cancellable)
If the response of A and B met some conditions, then APIC will be called, otherwise not. Is it achievable using Combine? Thanks.