Skip to content
Permalink
Browse files

Deprecate Completable.merge

  • Loading branch information...
freak4pc authored and kzaher committed Apr 15, 2019
1 parent a398308 commit c8a545a687af580bf5cf14e4b596d93a61420539
@@ -540,3 +540,45 @@ extension PrimitiveSequenceType where ElementType: RxAbstractInteger
return timer(.milliseconds(Int(dueTime * 1000.0)), scheduler: scheduler)
}
}

extension Completable {
/**
Merges the completion of all Completables from a collection into a single Completable.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Collection of Completables to merge.
- returns: A Completable that merges the completion of all Completables.
*/
@available(*, deprecated, message: "Use Completable.zip instead.", renamed: "zip")
public static func merge<C: Collection>(_ sources: C) -> Completable
where C.Element == Completable {
return zip(sources)
}

/**
Merges the completion of all Completables from an array into a single Completable.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Array of observable sequences to merge.
- returns: A Completable that merges the completion of all Completables.
*/
@available(*, deprecated, message: "Use Completable.zip instead.", renamed: "zip")
public static func merge(_ sources: [Completable]) -> Completable {
return zip(sources)
}

/**
Merges the completion of all Completables into a single Completable.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Collection of observable sequences to merge.
- returns: The observable sequence that merges the elements of the observable sequences.
*/
@available(*, deprecated, message: "Use Completable.zip instead.", renamed: "zip")
public static func merge(_ sources: Completable...) -> Completable {
return zip(sources)
}
}
@@ -222,46 +222,6 @@ extension PrimitiveSequenceType where TraitType == CompletableTrait, ElementType
let source = Observable.concat(sources.map { $0.asObservable() })
return Completable(raw: source)
}

/**
Merges the completion of all Completables from a collection into a single Completable.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Collection of Completables to merge.
- returns: A Completable that merges the completion of all Completables.
*/
public static func merge<C: Collection>(_ sources: C) -> Completable
where C.Element == Completable {
let source = Observable.merge(sources.map { $0.asObservable() })
return Completable(raw: source)
}

/**
Merges the completion of all Completables from an array into a single Completable.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Array of observable sequences to merge.
- returns: A Completable that merges the completion of all Completables.
*/
public static func merge(_ sources: [Completable]) -> Completable {
let source = Observable.merge(sources.map { $0.asObservable() })
return Completable(raw: source)
}

/**
Merges the completion of all Completables into a single Completable.
- seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html)
- parameter sources: Collection of observable sequences to merge.
- returns: The observable sequence that merges the elements of the observable sequences.
*/
public static func merge(_ sources: Completable...) -> Completable {
let source = Observable.merge(sources.map { $0.asObservable() })
return Completable(raw: source)
}

/**
Merges the completion of all Completables from a collection into a single Completable.
@@ -274,7 +234,8 @@ extension PrimitiveSequenceType where TraitType == CompletableTrait, ElementType
*/
public static func zip<C: Collection>(_ sources: C) -> Completable
where C.Element == Completable {
return merge(sources)
let source = Observable.merge(sources.map { $0.asObservable() })
return Completable(raw: source)
}

/**
@@ -287,7 +248,8 @@ extension PrimitiveSequenceType where TraitType == CompletableTrait, ElementType
- returns: A Completable that merges the completion of all Completables.
*/
public static func zip(_ sources: [Completable]) -> Completable {
return merge(sources)
let source = Observable.merge(sources.map { $0.asObservable() })
return Completable(raw: source)
}

/**
@@ -300,6 +262,7 @@ extension PrimitiveSequenceType where TraitType == CompletableTrait, ElementType
- returns: The observable sequence that merges the elements of the observable sequences.
*/
public static func zip(_ sources: Completable...) -> Completable {
return merge(sources)
let source = Observable.merge(sources.map { $0.asObservable() })
return Completable(raw: source)
}
}
@@ -144,9 +144,6 @@ final class CompletableTest_ : CompletableTest, RxTestCase {
("test_concat_sequence", CompletableTest.test_concat_sequence),
("test_concat_collection", CompletableTest.test_concat_collection),
("test_concat_variadic", CompletableTest.test_concat_variadic),
("test_merge_collection", CompletableTest.test_merge_collection),
("test_merge_array", CompletableTest.test_merge_array),
("test_merge_variadic", CompletableTest.test_merge_variadic),
("test_zip_collection", CompletableTest.test_zip_collection),
("test_zip_array", CompletableTest.test_zip_array),
("test_zip_variadic", CompletableTest.test_zip_variadic),
@@ -498,42 +498,6 @@ extension CompletableTest {
])
}

func test_merge_collection() {
let scheduler = TestScheduler(initialClock: 0)

let res = scheduler.start {
(Completable.merge(AnyCollection([Completable.empty(), Completable.empty()])) as Completable).asObservable()
}

XCTAssertEqual(res.events, [
.completed(200)
])
}

func test_merge_array() {
let scheduler = TestScheduler(initialClock: 0)

let res = scheduler.start {
(Completable.merge([Completable.empty(), Completable.empty()]) as Completable).asObservable()
}

XCTAssertEqual(res.events, [
.completed(200)
])
}

func test_merge_variadic() {
let scheduler = TestScheduler(initialClock: 0)

let res = scheduler.start {
(Completable.merge(Completable.empty(), Completable.empty()) as Completable).asObservable()
}

XCTAssertEqual(res.events, [
.completed(200)
])
}

func test_zip_collection() {
let scheduler = TestScheduler(initialClock: 0)

0 comments on commit c8a545a

Please sign in to comment.
You can’t perform that action at this time.