Skip to content

Instantly share code, notes, and snippets.

View JoshuaSullivan's full-sized avatar

Joshua Sullivan JoshuaSullivan

View GitHub Profile
@kshivang
kshivang / CombineLatestArray.swift
Last active August 2, 2024 12:55
CombineLatest extension for publisher array
// [publisher1, publisher2].combineLatest()
extension Array where Element: Publisher {
func combineLatest() -> AnyPublisher<[Element.Output], Element.Failure> {
Publishers.CombineLatestArray(self)
}
}
// Publishers.CombineLatestArray([publisher1, publisher2])
extension Publishers {
static func CombineLatestArray<P>(_ array: [P]) -> AnyPublisher<[P.Output], P.Failure> where P : Publisher {