From 7ed4677e33fdc963af404423cb563e133c271d2b Mon Sep 17 00:00:00 2001 From: freak4pc Date: Fri, 10 Apr 2020 17:03:46 +0300 Subject: [PATCH] CombineExt 1.1.0 --- CombineExt.podspec | 2 +- Sources/Operators/Amb.swift | 3 +-- Tests/AmbTests.swift | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CombineExt.podspec b/CombineExt.podspec index 9f875ab..c2ad57f 100644 --- a/CombineExt.podspec +++ b/CombineExt.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CombineExt" - s.version = "1.0.0" + s.version = "1.1.0" s.summary = "Combine operators and helpers not provided by Apple, and inspired by other Reactive Frameworks" s.description = <<-DESC A collection of operators for Combine adding capabilities and utilities not provided by Apple, diff --git a/Sources/Operators/Amb.swift b/Sources/Operators/Amb.swift index 294a63c..ab5c246 100644 --- a/Sources/Operators/Amb.swift +++ b/Sources/Operators/Amb.swift @@ -26,8 +26,7 @@ public extension Publisher { /// - returns: A publisher which mirrors the first publisher to emit an event func amb(with others: Other...) -> AnyPublisher where Other.Output == Output, Other.Failure == Failure { - let never = Empty(completeImmediately: false).eraseToAnyPublisher() - return others.reduce(never) { result, current in + others.reduce(self.eraseToAnyPublisher()) { result, current in result.amb(current).eraseToAnyPublisher() } } diff --git a/Tests/AmbTests.swift b/Tests/AmbTests.swift index 15d42fa..c1ee1af 100644 --- a/Tests/AmbTests.swift +++ b/Tests/AmbTests.swift @@ -139,8 +139,8 @@ class AmbTests: XCTestCase { var valuesThree = [Int]() var valuesFour = [Int]() - subject1 - .amb(with: subject2, subject3, subject4) + subject4 + .amb(with: subject2, subject3, subject1) .sink(receiveCompletion: { completionFour = $0 }, receiveValue: { valuesFour.append($0) }) .store(in: &subscriptions)