Yeap, I managed to apply combine operators only using additional global functions, other ways were more massive
import Combine
// MARK: - SDK
struct IntervalChartTool {}
protocol ChartFacadeProtocol {
var publisher1: any Publisher<IntervalChartTool, Never> { get }
var publisher2: any Publisher<IntervalChartTool, Never> { get }
}
// MARK: - Global func
func сombineLatest<A: Publisher, B: Publisher, ResultType, FailureType>(
a: A,
b: B
) -> any Publisher<(ResultType, ResultType), FailureType> where A.Output == B.Output, A.Failure == B.Failure, ResultType == A.Output, A.Failure == FailureType {
Publishers.CombineLatest(a, b).eraseToAnyPublisher()
}
// MARK: - Usage
class Interactor {
let combinedPublisher: any Publisher<(IntervalChartTool, IntervalChartTool), Never>
init(chartFacade: any ChartFacadeProtocol) {
combinedPublisher = сombineLatest(a: chartFacade.publisher1, b: chartFacade.publisher2)
}
}