Skip to content

Commit 123bf7b

Browse files
committed
Removes deprecation attribute from asSharedSequence.
1 parent 9c98fde commit 123bf7b

File tree

6 files changed

+146
-49
lines changed

6 files changed

+146
-49
lines changed

.jazzy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ custom_categories:
4646
- ObservableConvertibleType+Driver
4747
- name: RxCocoa/Traits/SharedSequence
4848
children:
49+
- ObservableConvertibleType+SharedSequence
4950
- SchedulerType+SharedSequence
5051
- SharedSequence+Operators+arity
5152
- SharedSequence+Operators

Rx.xcodeproj/project.pbxproj

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@
129129
C801DE4A1F6EBB84008DB060 /* Observable+PrimitiveSequenceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C801DE491F6EBB84008DB060 /* Observable+PrimitiveSequenceTest.swift */; };
130130
C801DE4B1F6EBB84008DB060 /* Observable+PrimitiveSequenceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C801DE491F6EBB84008DB060 /* Observable+PrimitiveSequenceTest.swift */; };
131131
C801DE4C1F6EBB84008DB060 /* Observable+PrimitiveSequenceTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C801DE491F6EBB84008DB060 /* Observable+PrimitiveSequenceTest.swift */; };
132+
C8091C4E1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8091C4D1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift */; };
133+
C8091C4F1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8091C4D1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift */; };
134+
C8091C501FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8091C4D1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift */; };
135+
C8091C511FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8091C4D1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift */; };
136+
C8091C531FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8091C521FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift */; };
137+
C8091C541FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8091C521FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift */; };
138+
C8091C551FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8091C521FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift */; };
132139
C8093CC51B8A72BE0088E94D /* Cancelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C491B8A72BE0088E94D /* Cancelable.swift */; };
133140
C8093CC61B8A72BE0088E94D /* Cancelable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C491B8A72BE0088E94D /* Cancelable.swift */; };
134141
C8093CC71B8A72BE0088E94D /* AsyncLock.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C4B1B8A72BE0088E94D /* AsyncLock.swift */; };
@@ -1767,6 +1774,8 @@
17671774
C801DE3D1F6EAD57008DB060 /* CompletableTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompletableTest.swift; sourceTree = "<group>"; };
17681775
C801DE411F6EBB29008DB060 /* ObservableType+PrimitiveSequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ObservableType+PrimitiveSequence.swift"; sourceTree = "<group>"; };
17691776
C801DE491F6EBB84008DB060 /* Observable+PrimitiveSequenceTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Observable+PrimitiveSequenceTest.swift"; sourceTree = "<group>"; };
1777+
C8091C4D1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ObservableConvertibleType+SharedSequence.swift"; sourceTree = "<group>"; };
1778+
C8091C521FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ObservableConvertibleType+SharedSequence.swift"; sourceTree = "<group>"; };
17701779
C809396D1B8A71760088E94D /* RxCocoa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxCocoa.framework; sourceTree = BUILT_PRODUCTS_DIR; };
17711780
C80939E71B8A71840088E94D /* RxCocoa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxCocoa.framework; sourceTree = BUILT_PRODUCTS_DIR; };
17721781
C8093BC71B8A71F00088E94D /* RxBlocking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxBlocking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -2685,6 +2694,7 @@
26852694
C8D970E11F532FD20058F2FE /* SharedSequence+Extensions.swift */,
26862695
C8D970DE1F532FD20058F2FE /* Driver+Test.swift */,
26872696
C8D970E21F532FD30058F2FE /* SharedSequence+OperatorTest.swift */,
2697+
C8091C521FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift */,
26882698
C83508DD1C38706D0027C24C /* ControlEventTests.swift */,
26892699
C83508DE1C38706D0027C24C /* ControlPropertyTests.swift */,
26902700
C83508E11C38706D0027C24C /* DelegateProxyTest.swift */,
@@ -3101,6 +3111,7 @@
31013111
C89AB1B81DAAC3350065FBE6 /* SharedSequence+Operators.swift */,
31023112
C89AB1B91DAAC3350065FBE6 /* SharedSequence.swift */,
31033113
C85E6FBD1F53025700C5681E /* SchedulerType+SharedSequence.swift */,
3114+
C8091C4D1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift */,
31043115
);
31053116
path = SharedSequence;
31063117
sourceTree = "<group>";
@@ -4138,6 +4149,7 @@
41384149
C85E6FC21F5305E300C5681E /* Signal.swift in Sources */,
41394150
C89AB2481DAAC3A60065FBE6 /* _RXKVOObserver.m in Sources */,
41404151
C88254281B8A752B00B02D69 /* UIButton+Rx.swift in Sources */,
4152+
C8091C4E1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */,
41414153
C89AB1CA1DAAC3350065FBE6 /* ControlProperty.swift in Sources */,
41424154
ECBBA59E1DF8C0D400DDDC2E /* RxTabBarControllerDelegateProxy.swift in Sources */,
41434155
C89AB1F21DAAC3350065FBE6 /* SharedSequence+Operators.swift in Sources */,
@@ -4203,6 +4215,7 @@
42034215
A520FFFD1F0D291500573734 /* RxPickerViewDataSourceProxy.swift in Sources */,
42044216
C89AB2411DAAC3A60065FBE6 /* _RXDelegateProxy.m in Sources */,
42054217
C867819C1DB823B500B2029A /* NSControl+Rx.swift in Sources */,
4218+
C8091C4F1FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */,
42064219
C89AB2391DAAC3A60065FBE6 /* _RX.m in Sources */,
42074220
C8093EFE1B8A732E0088E94D /* RxTarget.swift in Sources */,
42084221
C89AB21F1DAAC3350065FBE6 /* NSObject+Rx.swift in Sources */,
@@ -4420,6 +4433,7 @@
44204433
C81B6AAA1DB2C15C0047CF86 /* Platform.Darwin.swift in Sources */,
44214434
C81A097D1E6C27A100900B3B /* Observable+ZipTests.swift in Sources */,
44224435
C83509321C38706E0027C24C /* DelegateProxyTest.swift in Sources */,
4436+
C8091C531FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */,
44234437
0BA9496C1E224B9C0036DD06 /* AsyncSubjectTests.swift in Sources */,
44244438
C8F27DC01CE68DA600D5FB4F /* UITextView+RxTests.swift in Sources */,
44254439
C820A9B21EB507D300D431BC /* Observable+TakeWhileTests.swift in Sources */,
@@ -4546,6 +4560,7 @@
45464560
C8C4F1871DE9DF0200003FA7 /* UISwitch+RxTests.swift in Sources */,
45474561
C820AA031EB5134000D431BC /* Observable+DelaySubscriptionTests.swift in Sources */,
45484562
7EDBAEC31C89BCB9006CBE67 /* UITabBarItem+RxTests.swift in Sources */,
4563+
C8091C541FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */,
45494564
914FCD681CCDB82E0058B304 /* UIPageControl+RxTest.swift in Sources */,
45504565
C8A81CA71E05EAF70008DEF4 /* Binder+Tests.swift in Sources */,
45514566
C83509DD1C38754C0027C24C /* EquatableArray.swift in Sources */,
@@ -4626,6 +4641,7 @@
46264641
C820A9581EB4ED7C00D431BC /* Observable+MulticastTests.swift in Sources */,
46274642
C822BAD01DB424EC00F98810 /* Reactive+Tests.swift in Sources */,
46284643
C83509E21C3875580027C24C /* BackgroundThreadPrimitiveHotObservable.swift in Sources */,
4644+
C8091C551FAA3588001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */,
46294645
C8350A0E1C3875630027C24C /* Observable+ZipTests+arity.swift in Sources */,
46304646
C820AA001EB5110E00D431BC /* Observable+DematerializeTests.swift in Sources */,
46314647
C8D970F11F532FD30058F2FE /* SharedSequence+Extensions.swift in Sources */,
@@ -5352,6 +5368,7 @@
53525368
A520FFFF1F0D291500573734 /* RxPickerViewDataSourceProxy.swift in Sources */,
53535369
C8F0C0221BBBFBB9001B112F /* UIButton+Rx.swift in Sources */,
53545370
9BA1CBFE1C0F84C40044B50A /* UIActivityIndicatorView+Rx.swift in Sources */,
5371+
C8091C511FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */,
53555372
C89AB1A91DAAC25A0065FBE6 /* RxCocoaObjCRuntimeError+Extensions.swift in Sources */,
53565373
842A5A2E1C357F94003568D5 /* NSTextStorage+Rx.swift in Sources */,
53575374
C8F0C0281BBBFBB9001B112F /* RxTextViewDelegateProxy.swift in Sources */,
@@ -5513,6 +5530,7 @@
55135530
9D71C4D21BF08191006E8F59 /* UIButton+Rx.swift in Sources */,
55145531
D203C4FD1BB9C53700D02D00 /* RxSearchBarDelegateProxy.swift in Sources */,
55155532
7EDBAEBE1C89B9B7006CBE67 /* UITabBarItem+Rx.swift in Sources */,
5533+
C8091C501FAA345C001DB32A /* ObservableConvertibleType+SharedSequence.swift in Sources */,
55165534
84E4D3931C9AFD3500ADFDC9 /* UISearchController+Rx.swift in Sources */,
55175535
D203C50F1BB9C53E00D02D00 /* UIStepper+Rx.swift in Sources */,
55185536
C8E65EFD1F6E91D1004478C3 /* Binder.swift in Sources */,

RxCocoa/Deprecated.swift

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -449,55 +449,6 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt
449449
}
450450
}
451451

452-
extension ObservableConvertibleType {
453-
/**
454-
Converts anything convertible to `Observable` to `SharedSequence` unit.
455-
456-
- parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence.
457-
- returns: Driving observable sequence.
458-
*/
459-
@available(*, deprecated, message: "Please use conversion methods to some SharedSequence specialization.")
460-
public func asSharedSequence<S>(sharingStrategy: S.Type = S.self, onErrorJustReturn: E) -> SharedSequence<S, E> {
461-
let source = self
462-
.asObservable()
463-
.observeOn(S.scheduler)
464-
.catchErrorJustReturn(onErrorJustReturn)
465-
return SharedSequence(source)
466-
}
467452

468-
/**
469-
Converts anything convertible to `Observable` to `SharedSequence` unit.
470-
471-
- parameter onErrorDriveWith: SharedSequence that provides elements of the sequence in case of error.
472-
- returns: Driving observable sequence.
473-
*/
474-
@available(*, deprecated, message: "Please use conversion methods to some SharedSequence specialization.")
475-
public func asSharedSequence<S>(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence<S, E>) -> SharedSequence<S, E> {
476-
let source = self
477-
.asObservable()
478-
.observeOn(S.scheduler)
479-
.catchError { _ in
480-
onErrorDriveWith.asObservable()
481-
}
482-
return SharedSequence(source)
483-
}
484-
485-
/**
486-
Converts anything convertible to `Observable` to `SharedSequence` unit.
487-
488-
- parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error.
489-
- returns: Driving observable sequence.
490-
*/
491-
@available(*, deprecated, message: "Please use conversion methods to some SharedSequence specialization.")
492-
public func asSharedSequence<S>(sharingStrategy: S.Type = S.self, onErrorRecover: @escaping (_ error: Swift.Error) -> SharedSequence<S, E>) -> SharedSequence<S, E> {
493-
let source = self
494-
.asObservable()
495-
.observeOn(S.scheduler)
496-
.catchError { error in
497-
onErrorRecover(error).asObservable()
498-
}
499-
return SharedSequence(source)
500-
}
501-
}
502453

503454

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// ObservableConvertibleType+SharedSequence.swift
3+
// RxCocoa
4+
//
5+
// Created by Krunoslav Zaher on 11/1/17.
6+
// Copyright © 2017 Krunoslav Zaher. All rights reserved.
7+
//
8+
9+
import RxSwift
10+
11+
extension ObservableConvertibleType {
12+
/**
13+
Converts anything convertible to `Observable` to `SharedSequence` unit.
14+
15+
- parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence.
16+
- returns: Driving observable sequence.
17+
*/
18+
public func asSharedSequence<S>(sharingStrategy: S.Type = S.self, onErrorJustReturn: E) -> SharedSequence<S, E> {
19+
let source = self
20+
.asObservable()
21+
.observeOn(S.scheduler)
22+
.catchErrorJustReturn(onErrorJustReturn)
23+
return SharedSequence(source)
24+
}
25+
26+
/**
27+
Converts anything convertible to `Observable` to `SharedSequence` unit.
28+
29+
- parameter onErrorDriveWith: SharedSequence that provides elements of the sequence in case of error.
30+
- returns: Driving observable sequence.
31+
*/
32+
public func asSharedSequence<S>(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence<S, E>) -> SharedSequence<S, E> {
33+
let source = self
34+
.asObservable()
35+
.observeOn(S.scheduler)
36+
.catchError { _ in
37+
onErrorDriveWith.asObservable()
38+
}
39+
return SharedSequence(source)
40+
}
41+
42+
/**
43+
Converts anything convertible to `Observable` to `SharedSequence` unit.
44+
45+
- parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error.
46+
- returns: Driving observable sequence.
47+
*/
48+
public func asSharedSequence<S>(sharingStrategy: S.Type = S.self, onErrorRecover: @escaping (_ error: Swift.Error) -> SharedSequence<S, E>) -> SharedSequence<S, E> {
49+
let source = self
50+
.asObservable()
51+
.observeOn(S.scheduler)
52+
.catchError { error in
53+
onErrorRecover(error).asObservable()
54+
}
55+
return SharedSequence(source)
56+
}
57+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../RxCocoa/Traits/SharedSequence/ObservableConvertibleType+SharedSequence.swift
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
//
2+
// ObservableConvertibleType+SharedSequence.swift
3+
// Tests
4+
//
5+
// Created by Krunoslav Zaher on 11/1/17.
6+
// Copyright © 2017 Krunoslav Zaher. All rights reserved.
7+
//
8+
9+
import RxSwift
10+
import RxCocoa
11+
import XCTest
12+
import RxTest
13+
14+
class ObservableConvertibleSharedSequenceTests : SharedSequenceTest { }
15+
16+
extension ObservableConvertibleSharedSequenceTests {
17+
func testAsSharedSequence_onErrorJustReturn() {
18+
let hotObservable = BackgroundThreadPrimitiveHotObservable<Int>()
19+
let sharedSequence: Signal<Int> = hotObservable.asSharedSequence(onErrorJustReturn: -1)
20+
21+
let results = subscribeTwiceOnBackgroundSchedulerAndOnlyOneSubscription(sharedSequence) {
22+
XCTAssertTrue(hotObservable.subscriptions == [SubscribedToHotObservable])
23+
24+
hotObservable.on(.next(1))
25+
hotObservable.on(.next(2))
26+
hotObservable.on(.error(testError))
27+
28+
XCTAssertTrue(hotObservable.subscriptions == [UnsunscribedFromHotObservable])
29+
}
30+
31+
XCTAssertEqual(results, [1, 2, -1])
32+
}
33+
34+
func testAsSharedSequence_onErrorDriveWith() {
35+
let hotObservable = BackgroundThreadPrimitiveHotObservable<Int>()
36+
let sharedSequence: Signal<Int> = hotObservable.asSharedSequence(onErrorDriveWith: .just(-2))
37+
38+
let results = subscribeTwiceOnBackgroundSchedulerAndOnlyOneSubscription(sharedSequence) {
39+
XCTAssertTrue(hotObservable.subscriptions == [SubscribedToHotObservable])
40+
41+
hotObservable.on(.next(1))
42+
hotObservable.on(.next(2))
43+
hotObservable.on(.error(testError))
44+
45+
XCTAssertTrue(hotObservable.subscriptions == [UnsunscribedFromHotObservable])
46+
}
47+
48+
XCTAssertEqual(results, [1, 2, -2])
49+
}
50+
51+
func testAsSharedSequence_onErrorRecover() {
52+
let hotObservable = BackgroundThreadPrimitiveHotObservable<Int>()
53+
let sharedSequence: Signal<Int> = hotObservable.asSharedSequence(onErrorRecover: { (error) -> Signal<Int> in
54+
return .just(-3)
55+
})
56+
57+
let results = subscribeTwiceOnBackgroundSchedulerAndOnlyOneSubscription(sharedSequence) {
58+
XCTAssertTrue(hotObservable.subscriptions == [SubscribedToHotObservable])
59+
60+
hotObservable.on(.next(1))
61+
hotObservable.on(.next(2))
62+
hotObservable.on(.error(testError))
63+
64+
XCTAssertTrue(hotObservable.subscriptions == [UnsunscribedFromHotObservable])
65+
}
66+
67+
XCTAssertEqual(results, [1, 2, -3])
68+
}
69+
}

0 commit comments

Comments
 (0)