From 10f82a0b2d65898e6bad79c22e119453f7533cf0 Mon Sep 17 00:00:00 2001 From: Krunoslav Zaher Date: Wed, 19 Oct 2016 22:01:47 +0200 Subject: [PATCH] Removes deprecated APIs. --- .jazzy.yml | 1 - Rx.xcodeproj/project.pbxproj | 18 --- .../Driver/Driver+Subscription.swift | 14 -- .../SharedSequence+Operators.swift | 132 +--------------- RxCocoa/Common/DelegateProxy.swift | 5 - RxCocoa/Common/DelegateProxyType.swift | 5 - RxCocoa/Common/TextInput.swift | 48 ------ RxCocoa/OSX/NSImageView+Rx.swift | 24 --- RxCocoa/iOS/UICollectionView+Rx.swift | 137 ----------------- RxCocoa/iOS/UIImageView+Rx.swift | 24 --- RxCocoa/iOS/UITableView+Rx.swift | 145 ------------------ RxSwift/Cancelable.swift | 9 -- RxSwift/DataStructures/Bag.swift | 8 - RxSwift/Disposables/AnonymousDisposable.swift | 8 +- RxSwift/Disposables/CompositeDisposable.swift | 55 ++++--- RxSwift/Disposables/Disposables.swift | 44 ------ RxSwift/Disposables/DisposeBag.swift | 10 -- RxSwift/Disposables/NopDisposable.swift | 17 +- .../StableCompositeDisposable.swift | 16 -- RxSwift/ObservableType+Extensions.swift | 54 ------- RxSwift/Observables/Observable+Creation.swift | 30 ---- RxSwift/Observables/Observable+Multiple.swift | 116 -------------- RxSwift/Observables/Observable+Single.swift | 85 ---------- Sources/AllTestz/main.swift | 1 - .../RxSwift/StableCompositeDisposable.swift | 1 - Tests/RxCocoaTests/Driver+Test.swift | 13 +- .../Observable+MultipleTest.swift | 4 +- .../RxSwiftTests/Observable+SingleTest.swift | 87 +++-------- 28 files changed, 81 insertions(+), 1030 deletions(-) delete mode 100644 RxSwift/Disposables/StableCompositeDisposable.swift delete mode 120000 Sources/RxSwift/StableCompositeDisposable.swift diff --git a/.jazzy.yml b/.jazzy.yml index fe7463fa1..aceacd8e3 100644 --- a/.jazzy.yml +++ b/.jazzy.yml @@ -47,7 +47,6 @@ custom_categories: - ScheduledDisposable - SerialDisposable - SingleAssignmentDisposable - - StableCompositeDisposable - SubscriptionDisposable - name: RxSwift/Extensions children: diff --git a/Rx.xcodeproj/project.pbxproj b/Rx.xcodeproj/project.pbxproj index c2a43e505..c60c55e8e 100644 --- a/Rx.xcodeproj/project.pbxproj +++ b/Rx.xcodeproj/project.pbxproj @@ -112,8 +112,6 @@ C8093CEC1B8A72BE0088E94D /* SerialDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */; }; C8093CED1B8A72BE0088E94D /* SingleAssignmentDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C601B8A72BE0088E94D /* SingleAssignmentDisposable.swift */; }; C8093CEE1B8A72BE0088E94D /* SingleAssignmentDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C601B8A72BE0088E94D /* SingleAssignmentDisposable.swift */; }; - C8093CEF1B8A72BE0088E94D /* StableCompositeDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C611B8A72BE0088E94D /* StableCompositeDisposable.swift */; }; - C8093CF01B8A72BE0088E94D /* StableCompositeDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C611B8A72BE0088E94D /* StableCompositeDisposable.swift */; }; C8093CF31B8A72BE0088E94D /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C631B8A72BE0088E94D /* Errors.swift */; }; C8093CF41B8A72BE0088E94D /* Errors.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C631B8A72BE0088E94D /* Errors.swift */; }; C8093CF51B8A72BE0088E94D /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C641B8A72BE0088E94D /* Event.swift */; }; @@ -782,10 +780,6 @@ C89CFA2B1DAABBE20079D23B /* HotObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89CFA131DAABBE20079D23B /* HotObservable.swift */; }; C89CFA2C1DAABBE20079D23B /* HotObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89CFA131DAABBE20079D23B /* HotObservable.swift */; }; C89CFA2D1DAABBE20079D23B /* HotObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89CFA131DAABBE20079D23B /* HotObservable.swift */; }; - C89CFA2E1DAABBE20079D23B /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C89CFA141DAABBE20079D23B /* Info.plist */; }; - C89CFA2F1DAABBE20079D23B /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C89CFA141DAABBE20079D23B /* Info.plist */; }; - C89CFA301DAABBE20079D23B /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C89CFA141DAABBE20079D23B /* Info.plist */; }; - C89CFA311DAABBE20079D23B /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = C89CFA141DAABBE20079D23B /* Info.plist */; }; C89CFA321DAABBE20079D23B /* Recorded.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89CFA151DAABBE20079D23B /* Recorded.swift */; }; C89CFA331DAABBE20079D23B /* Recorded.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89CFA151DAABBE20079D23B /* Recorded.swift */; }; C89CFA341DAABBE20079D23B /* Recorded.swift in Sources */ = {isa = PBXBuildFile; fileRef = C89CFA151DAABBE20079D23B /* Recorded.swift */; }; @@ -886,7 +880,6 @@ C8F0BF991BBBFB8B001B112F /* SchedulerServices+Emulation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093CBB1B8A72BE0088E94D /* SchedulerServices+Emulation.swift */; }; C8F0BF9A1BBBFB8B001B112F /* AnyObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093CA01B8A72BE0088E94D /* AnyObserver.swift */; }; C8F0BF9B1BBBFB8B001B112F /* Skip.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C891B8A72BE0088E94D /* Skip.swift */; }; - C8F0BF9C1BBBFB8B001B112F /* StableCompositeDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C611B8A72BE0088E94D /* StableCompositeDisposable.swift */; }; C8F0BF9D1BBBFB8B001B112F /* Zip+arity.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C921B8A72BE0088E94D /* Zip+arity.swift */; }; C8F0BF9E1BBBFB8B001B112F /* Timer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C911B8A72BE0088E94D /* Timer.swift */; }; C8F0BF9F1BBBFB8B001B112F /* Empty.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8C3DA051B9393AC004D233E /* Empty.swift */; }; @@ -1134,7 +1127,6 @@ D2EBEAF71BB9B6B2003A27DC /* ScheduledDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5D1B8A72BE0088E94D /* ScheduledDisposable.swift */; }; D2EBEAF91BB9B6B2003A27DC /* SerialDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */; }; D2EBEAFA1BB9B6B2003A27DC /* SingleAssignmentDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C601B8A72BE0088E94D /* SingleAssignmentDisposable.swift */; }; - D2EBEAFB1BB9B6B2003A27DC /* StableCompositeDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C611B8A72BE0088E94D /* StableCompositeDisposable.swift */; }; D2EBEAFC1BB9B6BA003A27DC /* Amb.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C6B1B8A72BE0088E94D /* Amb.swift */; }; D2EBEAFD1BB9B6BA003A27DC /* AnonymousObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8C3DA111B93A3EA004D233E /* AnonymousObservable.swift */; }; D2EBEAFF1BB9B6BA003A27DC /* Buffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C821DBA11BA4DCAB008F3809 /* Buffer.swift */; }; @@ -1462,7 +1454,6 @@ C8093C5D1B8A72BE0088E94D /* ScheduledDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScheduledDisposable.swift; sourceTree = ""; }; C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SerialDisposable.swift; sourceTree = ""; }; C8093C601B8A72BE0088E94D /* SingleAssignmentDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SingleAssignmentDisposable.swift; sourceTree = ""; }; - C8093C611B8A72BE0088E94D /* StableCompositeDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StableCompositeDisposable.swift; sourceTree = ""; }; C8093C631B8A72BE0088E94D /* Errors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Errors.swift; sourceTree = ""; }; C8093C641B8A72BE0088E94D /* Event.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Event.swift; sourceTree = ""; }; C8093C651B8A72BE0088E94D /* ImmediateSchedulerType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImmediateSchedulerType.swift; sourceTree = ""; }; @@ -2019,7 +2010,6 @@ C8093C5D1B8A72BE0088E94D /* ScheduledDisposable.swift */, C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */, C8093C601B8A72BE0088E94D /* SingleAssignmentDisposable.swift */, - C8093C611B8A72BE0088E94D /* StableCompositeDisposable.swift */, CDDEF1691D4FB40000CA8546 /* Disposables.swift */, ); path = Disposables; @@ -3356,7 +3346,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C89CFA2E1DAABBE20079D23B /* Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3364,7 +3353,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C89CFA2F1DAABBE20079D23B /* Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3372,7 +3360,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C89CFA301DAABBE20079D23B /* Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3380,7 +3367,6 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - C89CFA311DAABBE20079D23B /* Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3896,7 +3882,6 @@ C8093D6A1B8A72BE0088E94D /* AnyObserver.swift in Sources */, C8093D3C1B8A72BE0088E94D /* Skip.swift in Sources */, C8B144FC1BD2D44500267DCE /* ConcurrentMainScheduler.swift in Sources */, - C8093CF01B8A72BE0088E94D /* StableCompositeDisposable.swift in Sources */, C8FE72A11D84C3C100A1E297 /* Debunce.swift in Sources */, D2245A1C1BD63C4600E7146F /* WithLatestFrom.swift in Sources */, C8093D4E1B8A72BE0088E94D /* Zip+arity.swift in Sources */, @@ -4120,7 +4105,6 @@ C8093D691B8A72BE0088E94D /* AnyObserver.swift in Sources */, C8093D3B1B8A72BE0088E94D /* Skip.swift in Sources */, C8B144FB1BD2D44500267DCE /* ConcurrentMainScheduler.swift in Sources */, - C8093CEF1B8A72BE0088E94D /* StableCompositeDisposable.swift in Sources */, C8554E2A1C3051620052E67D /* PriorityQueue.swift in Sources */, C8FE72A01D84C3C100A1E297 /* Debunce.swift in Sources */, D2245A1B1BD5657300E7146F /* WithLatestFrom.swift in Sources */, @@ -4270,7 +4254,6 @@ C8F0BF9A1BBBFB8B001B112F /* AnyObserver.swift in Sources */, C8F0BF9B1BBBFB8B001B112F /* Skip.swift in Sources */, C8B144FE1BD2D44500267DCE /* ConcurrentMainScheduler.swift in Sources */, - C8F0BF9C1BBBFB8B001B112F /* StableCompositeDisposable.swift in Sources */, C8FE72A31D84C3C100A1E297 /* Debunce.swift in Sources */, D2245A1E1BD63C4A00E7146F /* WithLatestFrom.swift in Sources */, C8F0BF9D1BBBFB8B001B112F /* Zip+arity.swift in Sources */, @@ -4667,7 +4650,6 @@ D2EBEB2F1BB9B6CA003A27DC /* Observable+Debug.swift in Sources */, D2EBEAE61BB9B697003A27DC /* ObserverType.swift in Sources */, C83D73CA1C1DBAEE003DC470 /* ScheduledItemType.swift in Sources */, - D2EBEAFB1BB9B6B2003A27DC /* StableCompositeDisposable.swift in Sources */, D2EBEB011BB9B6BA003A27DC /* CombineLatest.swift in Sources */, D2EBEB021BB9B6BA003A27DC /* CombineLatest+arity.swift in Sources */, C84CC5641BDD037900E06A64 /* SynchronizedDisposeType.swift in Sources */, diff --git a/RxCocoa/CocoaUnits/Driver/Driver+Subscription.swift b/RxCocoa/CocoaUnits/Driver/Driver+Subscription.swift index 0ffa1a525..d4b59606e 100644 --- a/RxCocoa/CocoaUnits/Driver/Driver+Subscription.swift +++ b/RxCocoa/CocoaUnits/Driver/Driver+Subscription.swift @@ -127,20 +127,6 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) return self.asObservable().subscribe(onNext: onNext, onCompleted: onCompleted, onDisposed: onDisposed) } - - /** - Subscribes an element handler to an observable sequence. - This method can be only called from `MainThread`. - - - parameter onNext: Action to invoke for each element in the observable sequence. - - returns: Subscription object used to unsubscribe from the observable sequence. - */ - // @warn_unused_result(message:"http://git.io/rxs.ud") - @available(*, deprecated, renamed: "drive(onNext:)") - public func driveNext(_ onNext: @escaping (E) -> Void) -> Disposable { - MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) - return self.asObservable().subscribe(onNext: onNext) - } } diff --git a/RxCocoa/CocoaUnits/SharedSequence/SharedSequence+Operators.swift b/RxCocoa/CocoaUnits/SharedSequence/SharedSequence+Operators.swift index ae1d776b3..679bf152e 100644 --- a/RxCocoa/CocoaUnits/SharedSequence/SharedSequence+Operators.swift +++ b/RxCocoa/CocoaUnits/SharedSequence/SharedSequence+Operators.swift @@ -110,84 +110,22 @@ extension SharedSequenceConvertibleType { } } -// MARK: doOn +// MARK: do extension SharedSequenceConvertibleType { - - /** - Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. - - - parameter eventHandler: Action to invoke for each event in the observable sequence. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") - public func doOn(_ eventHandler: @escaping (Event) -> Void) - -> SharedSequence { - let source = self.asObservable() - .doOn(eventHandler) - - return SharedSequence(source) - } - - /** - Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. - - - parameter onNext: Action to invoke for each element in the observable sequence. - - parameter onError: Action to invoke upon errored termination of the observable sequence. This callback will never be invoked since driver can't error out. - - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") - public func doOn(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil) - -> SharedSequence { - let source = self.asObservable() - .doOn(onNext: onNext, onError: onError, onCompleted: onCompleted) - - return SharedSequence(source) - } - - /** - Invokes an action for each Next event in the observable sequence, and propagates all observer messages through the result sequence. - - - parameter onNext: Action to invoke for each element in the observable sequence. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onNext:)") - public func doOnNext(_ onNext: @escaping (E) -> Void) - -> SharedSequence { - return self.do(onNext: onNext) - } - - /** - Invokes an action for the Completed event in the observable sequence, and propagates all observer messages through the result sequence. - - - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onCompleted:)") - public func doOnCompleted(_ onCompleted: @escaping () -> Void) - -> SharedSequence { - return self.do(onCompleted: onCompleted) - } - /** Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. - parameter onNext: Action to invoke for each element in the observable sequence. - - parameter onError: Action to invoke upon errored termination of the observable sequence. This callback will never be invoked since driver can't error out. - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. - parameter onSubscribe: Action to invoke before subscribing to source observable sequence. - parameter onDispose: Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed. - returns: The source sequence with the side-effecting behavior applied. */ // @warn_unused_result(message:"http://git.io/rxs.uo") - public func `do`(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onSubscribe: (() -> ())? = nil, onDispose: (() -> ())? = nil) + public func `do`(onNext: ((E) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onSubscribe: (() -> ())? = nil, onDispose: (() -> ())? = nil) -> SharedSequence { let source = self.asObservable() - .do(onNext: onNext, onError: onError, onCompleted: onCompleted, onSubscribe: onSubscribe, onDispose: onDispose) + .do(onNext: onNext, onCompleted: onCompleted, onSubscribe: onSubscribe, onDispose: onDispose) return SharedSequence(source) } @@ -409,38 +347,6 @@ extension SharedSequence { } } -extension Sequence where Iterator.Element : SharedSequenceConvertibleType { - - /** - Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. - - - returns: An observable sequence that contains the elements of each given sequence, in sequential order. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "SharingSequence.concat()") - public func concat() - -> SharedSequence { - let source = self.lazy.map { $0.asSharedSequence().asObservable() }.concat() - return SharedSequence(source) - } -} - -extension Collection where Iterator.Element : SharedSequenceConvertibleType { - - /** - Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. - - - returns: An observable sequence that contains the elements of each given sequence, in sequential order. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "SharingSequence.concat()") - public func concat() - -> SharedSequence { - let source = self.map { $0.asSharedSequence().asObservable() }.concat() - return SharedSequence(source) - } -} - // MARK: zip extension SharedSequence { @@ -457,22 +363,6 @@ extension SharedSequence { } } -extension Collection where Iterator.Element : SharedSequenceConvertibleType { - - /** - Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. - - - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. - - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "SharedSequence.zip()") - public func zip(_ resultSelector: @escaping ([Generator.Element.E]) throws -> R) -> SharedSequence { - let source = self.map { $0.asSharedSequence().asObservable() }.zip(resultSelector) - return SharedSequence(source) - } -} - // MARK: combineLatest extension SharedSequence { @@ -490,22 +380,6 @@ extension SharedSequence { } } -extension Collection where Iterator.Element : SharedSequenceConvertibleType { - - /** - Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. - - - parameter resultSelector: Function to invoke whenever any of the sources produces an element. - - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "SharingSequence.combineLatest()") - public func combineLatest(_ resultSelector: @escaping ([Generator.Element.E]) throws -> R) -> SharedSequence { - let source = self.map { $0.asSharedSequence().asObservable() }.combineLatest(resultSelector) - return SharedSequence(source) - } -} - // MARK: withLatestFrom extension SharedSequenceConvertibleType { diff --git a/RxCocoa/Common/DelegateProxy.swift b/RxCocoa/Common/DelegateProxy.swift index e65fc2979..b4bc0f28c 100644 --- a/RxCocoa/Common/DelegateProxy.swift +++ b/RxCocoa/Common/DelegateProxy.swift @@ -181,11 +181,6 @@ open class DelegateProxy : _RXDelegateProxy { } } - @available(*, deprecated, renamed: "methodInvoked") - open func observe(_ selector: Selector) -> Observable<[Any]> { - return sentMessage(selector) - } - // proxy open override func _sentMessage(_ selector: Selector, withArguments arguments: [Any]) { diff --git a/RxCocoa/Common/DelegateProxyType.swift b/RxCocoa/Common/DelegateProxyType.swift index 990b349c5..abd689fe1 100644 --- a/RxCocoa/Common/DelegateProxyType.swift +++ b/RxCocoa/Common/DelegateProxyType.swift @@ -149,11 +149,6 @@ public protocol DelegateProxyType : AnyObject { func setForwardToDelegate(_ forwardToDelegate: AnyObject?, retainDelegate: Bool) } -@available(*, deprecated:2.5, renamed:"DelegateProxyType.proxyForObject", message:"You can just use normal static protocol extension. E.g. `RxScrollViewDelegateProxy.proxyForObject`") -public func proxyForObject(_ type: P.Type, _ object: AnyObject) -> P { - return P.proxyForObject(object) -} - extension DelegateProxyType { /** Returns existing proxy for object or installs new instance of delegate proxy. diff --git a/RxCocoa/Common/TextInput.swift b/RxCocoa/Common/TextInput.swift index d2a678c79..a7a75a534 100644 --- a/RxCocoa/Common/TextInput.swift +++ b/RxCocoa/Common/TextInput.swift @@ -59,30 +59,6 @@ import Foundation } } - /** - Represents text input with reactive extensions. - */ - @available(*, deprecated, renamed: "TextInput") - public protocol RxTextInput : UITextInput { - @available(*, deprecated, renamed: "rx.textInput.text") - var rx_text: ControlProperty { get } - } - - extension UITextField : RxTextInput { - @available(*, deprecated, renamed: "rx.textInput.text") - public var rx_text: ControlProperty { - return self.rx.text - } - } - - extension UITextView : RxTextInput { - @available(*, deprecated, renamed: "rx.textInput.text") - public var rx_text: ControlProperty { - return self.rx.text - } - } - - #endif #if os(OSX) @@ -123,30 +99,6 @@ import Foundation } } - /** - Represents text input with reactive extensions. - */ - @available(*, deprecated, renamed: "TextInput") - public protocol RxTextInput : NSTextInput { - - /** - Reactive wrapper for `text` property. - */ - @available(*, deprecated, renamed: "rx.textInput.text") - var rx_text: ControlProperty { get } - } - - @available(*, deprecated) - extension NSTextField : RxTextInput { - /** - Reactive wrapper for `text` property. - */ - @available(*, deprecated, renamed: "rx.textInput.text") - public var rx_text: ControlProperty { - return self.rx.text - } - } - #endif diff --git a/RxCocoa/OSX/NSImageView+Rx.swift b/RxCocoa/OSX/NSImageView+Rx.swift index f8fa31c34..9d54ca098 100644 --- a/RxCocoa/OSX/NSImageView+Rx.swift +++ b/RxCocoa/OSX/NSImageView+Rx.swift @@ -23,30 +23,6 @@ extension Reactive where Base: NSImageView { return image(transitionType: nil) } - /** - Bindable sink for `image` property. - - - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) - */ - @available(*, deprecated, renamed: "image(transitionType:)") - public func imageAnimated(_ transitionType: String?) -> UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { control, value in - if let transitionType = transitionType { - if value != nil { - let transition = CATransition() - transition.duration = 0.25 - transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) - transition.type = transitionType - control.layer?.add(transition, forKey: kCATransition) - } - } - else { - control.layer?.removeAllAnimations() - } - control.image = value - } - } - /** Bindable sink for `image` property. diff --git a/RxCocoa/iOS/UICollectionView+Rx.swift b/RxCocoa/iOS/UICollectionView+Rx.swift index b46910277..8b9f2fdc1 100644 --- a/RxCocoa/iOS/UICollectionView+Rx.swift +++ b/RxCocoa/iOS/UICollectionView+Rx.swift @@ -311,140 +311,3 @@ extension Reactive where Base: UICollectionView { } } #endif - -#if os(iOS) || os(tvOS) - -extension UICollectionView { - - /** - Binds sequences of elements to collection view items. - - - parameter cellIdentifier: Identifier used to dequeue cells. - - parameter source: Observable sequence of items. - - parameter configureCell: Transform between sequence elements and view cells. - - parameter cellType: Type of table view cell. - - returns: Disposable object that can be used to unbind. - - Example - - let items = Observable.just([ - 1, - 2, - 3 - ]) - - items - .bindTo(collectionView.rx.items(cellIdentifier: "Cell", cellType: NumberCell.self)) { (row, element, cell) in - cell.value?.text = "\(element) @ \(row)" - } - .addDisposableTo(disposeBag) - */ - @available(*, deprecated, renamed: "rx.items(cellIdentifier:cellType:_:_:)") - public func rx_itemsWithCellIdentifier - (_ cellIdentifier: String, cellType: Cell.Type = Cell.self) - -> (_ source: O) - -> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void) - -> Disposable where O.E == S { - return { source in - return { configureCell in - return self.rx.items(cellIdentifier: cellIdentifier, cellType: cellType)(source)(configureCell) - } - } - } - - - /** - Binds sequences of elements to collection view items. - - - parameter source: Observable sequence of items. - - parameter cellFactory: Transform between sequence elements and view cells. - - returns: Disposable object that can be used to unbind. - - Example - - let items = Observable.just([ - 1, - 2, - 3 - ]) - - items - .bindTo(collectionView.rx.items) { (collectionView, row, element) in - let indexPath = IndexPath(forItem: row, inSection: 0) - let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell - cell.value?.text = "\(element) @ \(row)" - return cell - } - .addDisposableTo(disposeBag) - */ - @available(*, deprecated, renamed: "rx.items(_:_:)") - public func rx_itemsWithCellFactory - (_ source: O) - -> (_ cellFactory: @escaping (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell) - -> Disposable where O.E == S { - return { cellFactory in - return self.rx.items(source)(cellFactory) - } - } - - /** - Binds sequences of elements to collection view items using a custom reactive data used to perform the transformation. - - - parameter dataSource: Data source used to transform elements to view cells. - - parameter source: Observable sequence of items. - - returns: Disposable object that can be used to unbind. - - Example - - let dataSource = RxCollectionViewSectionedReloadDataSource>() - - let items = Observable.just([ - SectionModel(model: "First section", items: [ - 1.0, - 2.0, - 3.0 - ]), - SectionModel(model: "Second section", items: [ - 1.0, - 2.0, - 3.0 - ]), - SectionModel(model: "Third section", items: [ - 1.0, - 2.0, - 3.0 - ]) - ]) - - dataSource.configureCell = { (dataSource, cv, indexPath, element) in - let cell = cv.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell - cell.value?.text = "\(element) @ row \(indexPath.row)" - return cell - } - - items - .bindTo(collectionView.rx.items(dataSource: dataSource)) - .addDisposableTo(disposeBag) - */ - @available(*, deprecated, renamed: "rx.items(dataSource:_:)") - public func rx_itemsWithDataSource< - DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource, - O: ObservableType> - (_ dataSource: DataSource) - -> (_ source: O) - -> Disposable where DataSource.Element == O.E - { - return { source in - return self.rx.items(dataSource: dataSource)(source) - } - } - - /** - Syncronous helper method for retrieving a model at indexPath through a reactive data source - */ - @available(*, deprecated, renamed: "rx.model(_:)") - public func model(_ indexPath: IndexPath) throws -> T { - return try self.rx.model(indexPath) - } -} -#endif diff --git a/RxCocoa/iOS/UIImageView+Rx.swift b/RxCocoa/iOS/UIImageView+Rx.swift index a2d509854..31a6ef9eb 100644 --- a/RxCocoa/iOS/UIImageView+Rx.swift +++ b/RxCocoa/iOS/UIImageView+Rx.swift @@ -23,30 +23,6 @@ extension Reactive where Base: UIImageView { return image(transitionType: nil) } - /** - Bindable sink for `image` property. - - - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) - */ - @available(*, deprecated, renamed: "image(transitionType:)") - public func imageAnimated(_ transitionType: String?) -> UIBindingObserver { - return UIBindingObserver(UIElement: base) { imageView, image in - if let transitionType = transitionType { - if image != nil { - let transition = CATransition() - transition.duration = 0.25 - transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) - transition.type = transitionType - imageView.layer.add(transition, forKey: kCATransition) - } - } - else { - imageView.layer.removeAllAnimations() - } - imageView.image = image - } - } - /** Bindable sink for `image` property. diff --git a/RxCocoa/iOS/UITableView+Rx.swift b/RxCocoa/iOS/UITableView+Rx.swift index 084a1159e..0c3c9057b 100644 --- a/RxCocoa/iOS/UITableView+Rx.swift +++ b/RxCocoa/iOS/UITableView+Rx.swift @@ -396,148 +396,3 @@ extension Reactive where Base: UITableView { } } #endif - -#if os(iOS) || os(tvOS) - -// deprecated APIs -extension UITableView { - - /** - Binds sequences of elements to table view rows. - - - parameter source: Observable sequence of items. - - parameter cellFactory: Transform between sequence elements and view cells. - - returns: Disposable object that can be used to unbind. - - Example: - - let items = Observable.just([ - "First Item", - "Second Item", - "Third Item" - ]) - - items - .bindTo(tableView.rx.itemsWithCellFactory) { (tableView, row, element) in - let cell = tableView.dequeueReusableCellWithIdentifier("Cell")! - cell.textLabel?.text = "\(element) @ row \(row)" - return cell - } - .addDisposableTo(disposeBag) - - */ - @available(*, deprecated, renamed: "rx.items(_:_:)") - public func rx_itemsWithCellFactory - (_ source: O) - -> (_ cellFactory: @escaping (UITableView, Int, S.Iterator.Element) -> UITableViewCell) - -> Disposable - where O.E == S { - return { cellFactory in - return self.rx.items(source)(cellFactory) - } - } - - /** - Binds sequences of elements to table view rows. - - - parameter cellIdentifier: Identifier used to dequeue cells. - - parameter source: Observable sequence of items. - - parameter configureCell: Transform between sequence elements and view cells. - - parameter cellType: Type of table view cell. - - returns: Disposable object that can be used to unbind. - - Example: - - let items = Observable.just([ - "First Item", - "Second Item", - "Third Item" - ]) - - items - .bindTo(tableView.rx.items(cellIdentifier: "Cell", cellType: UITableViewCell.self)) { (row, element, cell) in - cell.textLabel?.text = "\(element) @ row \(row)" - } - .addDisposableTo(disposeBag) - */ - @available(*, deprecated, renamed: "rx.items(cellIdentifier:cellType:_:_:)") - public func rx_itemsWithCellIdentifier - (_ cellIdentifier: String, cellType: Cell.Type = Cell.self) - -> (_ source: O) - -> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void) - -> Disposable - where O.E == S { - return { source in - return { configureCell in - return self.rx.items(cellIdentifier: cellIdentifier, cellType: cellType)(source)(configureCell) - } - } - } - - /** - Binds sequences of elements to table view rows using a custom reactive data used to perform the transformation. - This method will retain the data source for as long as the subscription isn't disposed (result `Disposable` - being disposed). - In case `source` observable sequence terminates sucessfully, the data source will present latest element - until the subscription isn't disposed. - - - parameter dataSource: Data source used to transform elements to view cells. - - parameter source: Observable sequence of items. - - returns: Disposable object that can be used to unbind. - - Example - - let dataSource = RxTableViewSectionedReloadDataSource>() - - let items = Observable.just([ - SectionModel(model: "First section", items: [ - 1.0, - 2.0, - 3.0 - ]), - SectionModel(model: "Second section", items: [ - 1.0, - 2.0, - 3.0 - ]), - SectionModel(model: "Third section", items: [ - 1.0, - 2.0, - 3.0 - ]) - ]) - - dataSource.configureCell = { (dataSource, tv, indexPath, element) in - let cell = tv.dequeueReusableCellWithIdentifier("Cell")! - cell.textLabel?.text = "\(element) @ row \(indexPath.row)" - return cell - } - - items - .bindTo(tableView.rx.items(dataSoruce: dataSource)) - .addDisposableTo(disposeBag) - */ - @available(*, deprecated, renamed: "rx.items(dataSource:_:)") - public func rx_itemsWithDataSource< - DataSource: RxTableViewDataSourceType & UITableViewDataSource, - O: ObservableType> - (_ dataSource: DataSource) - -> (_ source: O) - -> Disposable - where DataSource.Element == O.E - { - return { source in - return self.rx.items(dataSource: dataSource)(source) - } - } - - /** - Synchronous helper method for retrieving a model at indexPath through a reactive data source. - */ - @available(*, deprecated, renamed: "rx.model(_:)") - public func rx_modelAtIndexPath(_ indexPath: IndexPath) throws -> T { - return try self.rx.model(indexPath) - } - -} -#endif diff --git a/RxSwift/Cancelable.swift b/RxSwift/Cancelable.swift index 97d021a6f..54515a300 100644 --- a/RxSwift/Cancelable.swift +++ b/RxSwift/Cancelable.swift @@ -17,12 +17,3 @@ public protocol Cancelable : Disposable { */ var isDisposed: Bool { get } } - -public extension Cancelable { - - @available(*, deprecated, renamed: "isDisposed") - var disposed: Bool { - return isDisposed - } - -} diff --git a/RxSwift/DataStructures/Bag.swift b/RxSwift/DataStructures/Bag.swift index 3683bd96b..7bb89d303 100644 --- a/RxSwift/DataStructures/Bag.swift +++ b/RxSwift/DataStructures/Bag.swift @@ -251,14 +251,6 @@ extension Bag where T: ObserverType { } } -/** -Dispatches `dispose` to all disposables contained inside bag. -*/ -@available(*, deprecated, renamed: "disposeAll(in:)") -func disposeAllIn(_ bag: Bag) { - disposeAll(in: bag) -} - /** Dispatches `dispose` to all disposables contained inside bag. */ diff --git a/RxSwift/Disposables/AnonymousDisposable.swift b/RxSwift/Disposables/AnonymousDisposable.swift index 52d9973be..feb9a23f6 100644 --- a/RxSwift/Disposables/AnonymousDisposable.swift +++ b/RxSwift/Disposables/AnonymousDisposable.swift @@ -13,7 +13,8 @@ Represents an Action-based disposable. When dispose method is called, disposal action will be dereferenced. */ -public final class AnonymousDisposable : DisposeBase, Cancelable { + +fileprivate final class AnonymousDisposable : DisposeBase, Cancelable { public typealias DisposeAction = () -> Void private var _isDisposed: AtomicInt = 0 @@ -31,8 +32,7 @@ public final class AnonymousDisposable : DisposeBase, Cancelable { - parameter disposeAction: Disposal action which will be run upon calling `dispose`. */ - @available(*, deprecated, renamed: "Disposables.create") - public init(_ disposeAction: @escaping DisposeAction) { + fileprivate init(_ disposeAction: @escaping DisposeAction) { _disposeAction = disposeAction super.init() } @@ -48,7 +48,7 @@ public final class AnonymousDisposable : DisposeBase, Cancelable { After invoking disposal action, disposal action will be dereferenced. */ - public func dispose() { + fileprivate func dispose() { if AtomicCompareAndSwap(0, 1, &_isDisposed) { assert(_isDisposed == 1) diff --git a/RxSwift/Disposables/CompositeDisposable.swift b/RxSwift/Disposables/CompositeDisposable.swift index 560981375..a7d329e29 100644 --- a/RxSwift/Disposables/CompositeDisposable.swift +++ b/RxSwift/Disposables/CompositeDisposable.swift @@ -70,18 +70,6 @@ public final class CompositeDisposable : DisposeBase, Disposable, Cancelable { } } - /** - Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. - - - parameter disposable: Disposable to add. - - returns: Key that can be used to remove disposable from composite disposable. In case dispose bag was already - disposed `nil` will be returned. - */ - @available(*, deprecated, renamed: "insert(_:)") - public func addDisposable(_ disposable: Disposable) -> DisposeKey? { - return insert(disposable) - } - /** Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. @@ -113,16 +101,6 @@ public final class CompositeDisposable : DisposeBase, Disposable, Cancelable { return _disposables?.count ?? 0 } - /** - Removes and disposes the disposable identified by `disposeKey` from the CompositeDisposable. - - - parameter disposeKey: Key used to identify disposable to be removed. - */ - @available(*, deprecated, renamed: "remove(for:)") - public func removeDisposable(_ disposeKey: DisposeKey) { - remove(for: disposeKey) - } - /** Removes and disposes the disposable identified by `disposeKey` from the CompositeDisposable. @@ -155,3 +133,36 @@ public final class CompositeDisposable : DisposeBase, Disposable, Cancelable { return disposeBag } } + +public extension Disposables { + + /** + Creates a disposable with the given disposables. + */ + public static func create(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable) -> Cancelable { + return CompositeDisposable(disposable1, disposable2, disposable3) + } + + /** + Creates a disposable with the given disposables. + */ + public static func create(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable, _ disposables: Disposable ...) -> Cancelable { + var disposables = disposables + disposables.append(disposable1) + disposables.append(disposable2) + disposables.append(disposable3) + return CompositeDisposable(disposables: disposables) + } + + /** + Creates a disposable with the given disposables. + */ + public static func create(_ disposables: [Disposable]) -> Cancelable { + switch disposables.count { + case 2: + return Disposables.create(disposables[0], disposables[1]) + default: + return CompositeDisposable(disposables: disposables) + } + } +} diff --git a/RxSwift/Disposables/Disposables.swift b/RxSwift/Disposables/Disposables.swift index 70d81a7db..a3264a9a6 100644 --- a/RxSwift/Disposables/Disposables.swift +++ b/RxSwift/Disposables/Disposables.swift @@ -12,50 +12,6 @@ import Foundation A collection of utility methods for common disposable operations. */ public struct Disposables { - private init() {} - } -public extension Disposables { - - private static let noOp: Disposable = NopDisposable() - - /** - Creates a disposable that does nothing on disposal. - */ - static func create() -> Disposable { - return noOp - } - - /** - Creates a disposable with the given disposables. - */ - static func create(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable) -> Cancelable { - return CompositeDisposable(disposable1, disposable2, disposable3) - } - - /** - Creates a disposable with the given disposables. - */ - static func create(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable, _ disposables: Disposable ...) -> Cancelable { - var disposables = disposables - disposables.append(disposable1) - disposables.append(disposable2) - disposables.append(disposable3) - return CompositeDisposable(disposables: disposables) - } - - /** - Creates a disposable with the given disposables. - */ - static func create(_ disposables: [Disposable]) -> Cancelable { - switch disposables.count { - case 2: - return Disposables.create(disposables[0], disposables[1]) - default: - return CompositeDisposable(disposables: disposables) - } - } - -} diff --git a/RxSwift/Disposables/DisposeBag.swift b/RxSwift/Disposables/DisposeBag.swift index 38b47d9f8..7725a54c7 100644 --- a/RxSwift/Disposables/DisposeBag.swift +++ b/RxSwift/Disposables/DisposeBag.swift @@ -46,16 +46,6 @@ public final class DisposeBag: DisposeBase { super.init() } - /** - Adds `disposable` to be disposed when dispose bag is being deinited. - - - parameter disposable: Disposable to add. - */ - @available(*, deprecated, renamed: "insert(_:)") - public func addDisposable(_ disposable: Disposable) { - insert(disposable) - } - /** Adds `disposable` to be disposed when dispose bag is being deinited. diff --git a/RxSwift/Disposables/NopDisposable.swift b/RxSwift/Disposables/NopDisposable.swift index 76593f94d..6a36109a6 100644 --- a/RxSwift/Disposables/NopDisposable.swift +++ b/RxSwift/Disposables/NopDisposable.swift @@ -13,13 +13,9 @@ Represents a disposable that does nothing on disposal. Nop = No Operation */ -public struct NopDisposable : Disposable { +fileprivate struct NopDisposable : Disposable { - /** - Singleton instance of `NopDisposable`. - */ - @available(*, deprecated, renamed: "Disposables.create()") - public static let instance: Disposable = NopDisposable() + fileprivate static let noOp: Disposable = NopDisposable() init() { @@ -31,3 +27,12 @@ public struct NopDisposable : Disposable { public func dispose() { } } + +extension Disposables { + /** + Creates a disposable that does nothing on disposal. + */ + static public func create() -> Disposable { + return NopDisposable.noOp + } +} diff --git a/RxSwift/Disposables/StableCompositeDisposable.swift b/RxSwift/Disposables/StableCompositeDisposable.swift deleted file mode 100644 index ad10eacc1..000000000 --- a/RxSwift/Disposables/StableCompositeDisposable.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// StableCompositeDisposable.swift -// RxSwift -// -// Created by Krunoslav Zaher on 6/12/15. -// Copyright © 2015 Krunoslav Zaher. All rights reserved. -// - -import Foundation - -public final class StableCompositeDisposable { - @available(*, deprecated, renamed: "Disposables.create") - public static func create(_ disposable1: Disposable, _ disposable2: Disposable) -> Disposable { - return Disposables.create(disposable1, disposable2) - } -} diff --git a/RxSwift/ObservableType+Extensions.swift b/RxSwift/ObservableType+Extensions.swift index f2e0b19dc..be392b571 100644 --- a/RxSwift/ObservableType+Extensions.swift +++ b/RxSwift/ObservableType+Extensions.swift @@ -112,60 +112,6 @@ extension ObservableType { ) } #endif - - /** - Subscribes an element handler to an observable sequence. - - - parameter onNext: Action to invoke for each element in the observable sequence. - - returns: Subscription object used to unsubscribe from the observable sequence. - */ - // @warn_unused_result(message: "http://git.io/rxs.ud") - @available(*, deprecated, renamed: "subscribe(onNext:)") - public func subscribeNext(_ onNext: @escaping (E) -> Void) - -> Disposable { - let observer = AnonymousObserver { e in - if case .next(let value) = e { - onNext(value) - } - } - return self.subscribeSafe(observer) - } - - /** - Subscribes an error handler to an observable sequence. - - - parameter onError: Action to invoke upon errored termination of the observable sequence. - - returns: Subscription object used to unsubscribe from the observable sequence. - */ - // @warn_unused_result(message: "http://git.io/rxs.ud") - @available(*, deprecated, renamed: "subscribe(onError:)") - public func subscribeError(_ onError: @escaping (Swift.Error) -> Void) - -> Disposable { - let observer = AnonymousObserver { e in - if case .error(let error) = e { - onError(error) - } - } - return self.subscribeSafe(observer) - } - - /** - Subscribes a completion handler to an observable sequence. - - - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. - - returns: Subscription object used to unsubscribe from the observable sequence. - */ - // @warn_unused_result(message: "http://git.io/rxs.ud") - @available(*, deprecated, renamed: "subscribe(onCompleted:)") - public func subscribeCompleted(_ onCompleted: @escaping () -> Void) - -> Disposable { - let observer = AnonymousObserver { e in - if case .completed = e { - onCompleted() - } - } - return self.subscribeSafe(observer) - } } public extension ObservableType { diff --git a/RxSwift/Observables/Observable+Creation.swift b/RxSwift/Observables/Observable+Creation.swift index 1430b3870..e39106d82 100644 --- a/RxSwift/Observables/Observable+Creation.swift +++ b/RxSwift/Observables/Observable+Creation.swift @@ -190,36 +190,6 @@ extension Observable where Element : SignedInteger { } } -extension Sequence { - /** - Converts a sequence to an observable sequence. - - - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) - - - returns: The observable sequence whose elements are pulled from the given enumerable sequence. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "Observable.from()") - public func toObservable(_ scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { - return ObservableSequence(elements: Array(self), scheduler: scheduler) - } -} - -extension Array { - /** - Converts a sequence to an observable sequence. - - - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) - - - returns: The observable sequence whose elements are pulled from the given enumerable sequence. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "Observable.from()") - public func toObservable(_ scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { - return ObservableSequence(elements: self, scheduler: scheduler) - } -} - extension Observable { /** Converts an array to an observable sequence. diff --git a/RxSwift/Observables/Observable+Multiple.swift b/RxSwift/Observables/Observable+Multiple.swift index e8ef0082c..0740d861f 100644 --- a/RxSwift/Observables/Observable+Multiple.swift +++ b/RxSwift/Observables/Observable+Multiple.swift @@ -26,23 +26,6 @@ extension Observable { } } -extension Collection where Iterator.Element : ObservableType { - - /** - Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. - - - seealso: [combinelatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) - - - parameter resultSelector: Function to invoke whenever any of the sources produces an element. - - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "Observable.combineLatest()") - public func combineLatest(_ resultSelector: @escaping ([Generator.Element.E]) throws -> R) -> Observable { - return CombineLatestCollectionType(sources: self, resultSelector: resultSelector) - } -} - // MARK: zip extension Observable { @@ -61,23 +44,6 @@ extension Observable { } } -extension Collection where Iterator.Element : ObservableType { - - /** - Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. - - - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) - - - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. - - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "Observable.zip()") - public func zip(_ resultSelector: @escaping ([Generator.Element.E]) throws -> R) -> Observable { - return ZipCollectionType(sources: self, resultSelector: resultSelector) - } -} - // MARK: switch extension ObservableType where E : ObservableConvertibleType { @@ -157,53 +123,6 @@ extension Observable { } } -extension Sequence where Iterator.Element : ObservableType { - - /** - Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. - - This operator has tail recursive optimizations that will prevent stack overflow. - - Optimizations will be performed in cases equivalent to following: - - [1, [2, [3, .....].concat()].concat].concat() - - - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) - - - returns: An observable sequence that contains the elements of each given sequence, in sequential order. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "Observable.concat()") - public func concat() - -> Observable { - return Concat(sources: self, count: nil) - } -} - -extension Collection where Iterator.Element : ObservableType { - - /** - Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. - - This operator has tail recursive optimizations that will prevent stack overflow and enable generating - infinite observable sequences while using limited amount of memory during generation. - - Optimizations will be performed in cases equivalent to following: - - [1, [2, [3, .....].concat()].concat].concat() - - - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) - - - returns: An observable sequence that contains the elements of each given sequence, in sequential order. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "Observable.concat()") - public func concat() - -> Observable { - return Concat(sources: self, count: self.count.toIntMax()) - } -} - extension ObservableType where E : ObservableConvertibleType { /** @@ -299,22 +218,6 @@ extension Observable { } } -extension Sequence where Iterator.Element : ObservableType { - /** - Continues an observable sequence that is terminated by an error with the next observable sequence. - - - seealso: [catch operator on reactivex.io](http://reactivex.io/documentation/operators/catch.html) - - - returns: An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "Observable.catchError()") - public func catchError() - -> Observable { - return CatchSequence(sources: self) - } -} - // MARK: takeUntil extension ObservableType { @@ -390,25 +293,6 @@ extension Observable { } } -extension Sequence where Iterator.Element : ObservableType { - - /** - Propagates the observable sequence that reacts first. - - - seealso: [amb operator on reactivex.io](http://reactivex.io/documentation/operators/amb.html) - - - returns: An observable sequence that surfaces any of the given sequences, whichever reacted first. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "Observable.amb()") - public func amb() - -> Observable { - return self.reduce(Observable.never()) { a, o in - return a.amb(o.asObservable()) - } - } -} - // withLatestFrom extension ObservableType { diff --git a/RxSwift/Observables/Observable+Single.swift b/RxSwift/Observables/Observable+Single.swift index 5514d9579..be0127a1a 100644 --- a/RxSwift/Observables/Observable+Single.swift +++ b/RxSwift/Observables/Observable+Single.swift @@ -74,91 +74,6 @@ extension ObservableType { // MARK: doOn extension ObservableType { - - /** - Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. - - - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) - - - parameter eventHandler: Action to invoke for each event in the observable sequence. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") - public func doOn(_ eventHandler: @escaping (Event) throws -> Void) - -> Observable { - return Do(source: self.asObservable(), eventHandler: eventHandler, onSubscribe: nil, onDispose: nil) - } - - /** - Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. - - - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) - - - parameter onNext: Action to invoke for each element in the observable sequence. - - parameter onError: Action to invoke upon errored termination of the observable sequence. - - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. - - parameter onSubscribe: Action to invoke before subscribing to source observable sequence. - - parameter onDispose: Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") - public func doOn(onNext: ((E) throws -> Void)? = nil, onError: ((Swift.Error) throws -> Void)? = nil, onCompleted: (() throws -> Void)? = nil) - -> Observable { - return Do(source: self.asObservable(), eventHandler: { e in - switch e { - case .next(let element): - try onNext?(element) - case .error(let e): - try onError?(e) - case .completed: - try onCompleted?() - } - }, - onSubscribe: nil, - onDispose: nil) - } - - /** - Invokes an action for each Next event in the observable sequence, and propagates all observer messages through the result sequence. - - - parameter onNext: Action to invoke for each element in the observable sequence. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onNext:)") - public func doOnNext(onNext: @escaping (E) throws -> Void) - -> Observable { - return self.do(onNext: onNext) - } - - /** - Invokes an action for the Error event in the observable sequence, and propagates all observer messages through the result sequence. - - - parameter onError: Action to invoke upon errored termination of the observable sequence. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onError:)") - public func doOnError(onError: @escaping (Swift.Error) throws -> Void) - -> Observable { - return self.do(onError: onError) - } - - /** - Invokes an action for the Completed event in the observable sequence, and propagates all observer messages through the result sequence. - - - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. - - returns: The source sequence with the side-effecting behavior applied. - */ - // @warn_unused_result(message:"http://git.io/rxs.uo") - @available(*, deprecated, renamed: "do(onCompleted:)") - public func doOnCompleted(onCompleted: @escaping () throws -> Void) - -> Observable { - return self.do(onCompleted: onCompleted) - } - /** Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. diff --git a/Sources/AllTestz/main.swift b/Sources/AllTestz/main.swift index 9046cb354..4a6b712bf 100644 --- a/Sources/AllTestz/main.swift +++ b/Sources/AllTestz/main.swift @@ -403,7 +403,6 @@ final class ObservableSingleTest_ : ObservableSingleTest, RxTestCase { ("testDoOn_completedNever", ObservableSingleTest.testDoOn_completedNever), ("testDoOn_nextError", ObservableSingleTest.testDoOn_nextError), ("testDoOn_nextErrorNot", ObservableSingleTest.testDoOn_nextErrorNot), - ("testDoOn_Throws", ObservableSingleTest.testDoOn_Throws), ("testDoOnNext_normal", ObservableSingleTest.testDoOnNext_normal), ("testDoOnNext_throws", ObservableSingleTest.testDoOnNext_throws), ("testDoOnError_normal", ObservableSingleTest.testDoOnError_normal), diff --git a/Sources/RxSwift/StableCompositeDisposable.swift b/Sources/RxSwift/StableCompositeDisposable.swift deleted file mode 120000 index d0c9c84a9..000000000 --- a/Sources/RxSwift/StableCompositeDisposable.swift +++ /dev/null @@ -1 +0,0 @@ -../../RxSwift/Disposables/StableCompositeDisposable.swift \ No newline at end of file diff --git a/Tests/RxCocoaTests/Driver+Test.swift b/Tests/RxCocoaTests/Driver+Test.swift index a3a52c8db..83f29c242 100644 --- a/Tests/RxCocoaTests/Driver+Test.swift +++ b/Tests/RxCocoaTests/Driver+Test.swift @@ -522,11 +522,18 @@ extension DriverTest { var events = [Event]() - let driver = hotObservable.asDriver(onErrorJustReturn: -1).doOn { e in + let driver = hotObservable.asDriver(onErrorJustReturn: -1).do(onNext: { e in XCTAssertTrue(isMainThread()) - events.append(e) - } + events.append(.next(e)) + }, onCompleted: { + XCTAssertTrue(isMainThread()) + events.append(.completed) + }, onSubscribe: { + XCTAssertTrue(!isMainThread()) + }, onDispose: { + XCTAssertTrue(isMainThread()) + }) let results = subscribeTwiceOnBackgroundSchedulerAndOnlyOneSubscription(driver) { XCTAssertTrue(hotObservable.subscriptions == [SubscribedToHotObservable]) diff --git a/Tests/RxSwiftTests/Observable+MultipleTest.swift b/Tests/RxSwiftTests/Observable+MultipleTest.swift index aa44a4c98..73a084da8 100644 --- a/Tests/RxSwiftTests/Observable+MultipleTest.swift +++ b/Tests/RxSwiftTests/Observable+MultipleTest.swift @@ -2862,7 +2862,7 @@ extension ObservableMultipleTest { var sourceNotDisposed = false let res = scheduler.start { - l.doOn { _ in sourceNotDisposed = true } .takeUntil(r) + l.do(onNext: { _ in sourceNotDisposed = true }).takeUntil(r) } XCTAssertEqual(res.events, [ @@ -2890,7 +2890,7 @@ extension ObservableMultipleTest { var sourceNotDisposed = false let res = scheduler.start { - l.takeUntil(r .doOn { _ in sourceNotDisposed = true }) + l.takeUntil(r.do(onNext: { _ in sourceNotDisposed = true })) } XCTAssertEqual(res.events, [ diff --git a/Tests/RxSwiftTests/Observable+SingleTest.swift b/Tests/RxSwiftTests/Observable+SingleTest.swift index 72cacefe7..e5626341e 100644 --- a/Tests/RxSwiftTests/Observable+SingleTest.swift +++ b/Tests/RxSwiftTests/Observable+SingleTest.swift @@ -287,15 +287,10 @@ extension ObservableSingleTest { var i = 0 var sum = 2 + 3 + 4 + 5 - let res = scheduler.start { xs.doOn { e in - switch e { - case .next: - i += 1 - sum -= e.element ?? 0 - - default: break - } - } + let res = scheduler.start { xs.do(onNext: { element in + i += 1 + sum -= element ?? 0 + }) } XCTAssertEqual(i, 4) @@ -330,13 +325,9 @@ extension ObservableSingleTest { ]) var i = 0 - let res = scheduler.start { xs.doOn { e in - switch e { - case .next(_): + let res = scheduler.start { xs.do(onNext: { _ in i += 1 - default: break - } - } + }) } XCTAssertEqual(i, 4) @@ -372,16 +363,12 @@ extension ObservableSingleTest { var i = 0 var sum = 2 + 3 + 4 + 5 var completedEvaluation = false - let res = scheduler.start { xs.doOn { e in - switch e { - case .next(let value): + let res = scheduler.start { xs.do(onNext: { value in i += 1 sum -= value - case .completed: + }, onCompleted: { completedEvaluation = true - default: break - } - } + }) } XCTAssertEqual(i, 4) @@ -414,15 +401,11 @@ extension ObservableSingleTest { var i = 0 var completedEvaluation = false - let res = scheduler.start { xs.doOn { e in - switch e { - case .next(_): + let res = scheduler.start { xs.do(onNext: { e in i += 1 - case .completed: + }, onCompleted: { completedEvaluation = true - default: break - } - } + }) } XCTAssertEqual(i, 0) @@ -454,16 +437,12 @@ extension ObservableSingleTest { var i = 0 var sum = 2 + 3 + 4 + 5 var sawError = false - let res = scheduler.start { xs.doOn { e in - switch e { - case .next(let value): + let res = scheduler.start { xs.do(onNext: { value in i += 1 sum -= value - case .error: + }, onError: { _ in sawError = true - default: break - } - } + }) } XCTAssertEqual(i, 4) @@ -501,16 +480,12 @@ extension ObservableSingleTest { var i = 0 var sum = 2 + 3 + 4 + 5 var sawError = false - let res = scheduler.start { xs.doOn { e in - switch e { - case .next(let value): + let res = scheduler.start { xs.do(onNext: { value in i += 1 sum -= value - case .error: + }, onError: { e in sawError = true - default: break - } - } + }) } XCTAssertEqual(i, 4) @@ -533,32 +508,6 @@ extension ObservableSingleTest { XCTAssertEqual(xs.subscriptions, correctSubscriptions) } - func testDoOn_Throws() { - let scheduler = TestScheduler(initialClock: 0) - - let xs = scheduler.createHotObservable([ - next(150, 1), - next(210, 2), - completed(250) - ]) - - let res = scheduler.start { xs.doOn { _ in - throw testError - } - } - - let correctMessages = [ - error(210, testError, Int.self) - ] - - let correctSubscriptions = [ - Subscription(200, 210) - ] - - XCTAssertEqual(res.events, correctMessages) - XCTAssertEqual(xs.subscriptions, correctSubscriptions) - } - func testDoOnNext_normal() { let scheduler = TestScheduler(initialClock: 0)