From 0b58e03c21d624bb662a37d173ba6c4e77458c73 Mon Sep 17 00:00:00 2001 From: sergdort Date: Tue, 10 Oct 2017 20:30:56 +0100 Subject: [PATCH] Update Rx to 4.0.0-rc.0 --- Cartfile | 2 +- RxAlamofire.podspec | 6 +- RxAlamofire/Podfile | 6 +- .../Local Podspecs/RxBlocking.podspec.json | 6 +- .../Pods/Local Podspecs/RxCocoa.podspec.json | 6 +- .../Pods/Local Podspecs/RxSwift.podspec.json | 4 +- RxAlamofire/Pods/RxBlocking/README.md | 3 + RxAlamofire/Pods/RxCocoa/README.md | 3 + .../Pods/RxCocoa/RxCocoa/Common/Binder.swift | 61 +++ .../RxCocoa/Common/DelegateProxy.swift | 468 +++++++++--------- .../RxCocoa/Common/DelegateProxyFactory.swift | 76 --- .../RxCocoa/Common/DelegateProxyType.swift | 291 +++++++---- .../Common/NSLayoutConstraint+Rx.swift | 8 +- .../Pods/RxCocoa/RxCocoa/Deprecated.swift | 210 ++++++++ .../RxCocoa/RxCocoa/Runtime/_RXObjCRuntime.m | 12 +- .../Runtime/include/_RXDelegateProxy.h | 2 +- .../RxCocoa/Runtime/include/_RXObjCRuntime.h | 2 +- .../Pods/RxCocoa/RxCocoa/RxCocoa.swift | 4 +- .../RxCocoa/Traits/BehaviorRelay.swift | 46 ++ .../RxCocoa/RxCocoa/Traits/ControlEvent.swift | 4 +- .../RxCocoa/Traits/ControlProperty.swift | 4 +- .../Traits/Driver/BehaviorRelay+Driver.swift | 22 + .../Traits/Driver/Driver+Subscription.swift | 27 +- .../RxCocoa/Traits/Driver/Driver.swift | 48 +- .../ObservableConvertibleType+Driver.swift | 12 +- .../Traits/Driver/Variable+Driver.swift | 22 - .../RxCocoa/RxCocoa/Traits/PublishRelay.swift | 40 ++ .../SchedulerType+SharedSequence.swift | 61 +++ .../SharedSequence+Operators.swift | 30 +- .../Variable+SharedSequence.swift | 22 - .../ObservableConvertibleType+Signal.swift | 60 +++ .../Traits/Signal/PublishRelay+Signal.swift | 22 + .../Traits/Signal/Signal+Subscription.swift | 80 +++ .../RxCocoa/Traits/Signal/Signal.swift | 47 ++ .../RxCocoa/Traits/UIBindingObserver.swift | 64 --- ...ollectionViewReactiveArrayDataSource.swift | 2 +- .../iOS/DataSources/RxPickerViewAdapter.swift | 2 +- .../RxTableViewReactiveArrayDataSource.swift | 2 +- .../RxCocoa/iOS/NSTextStorage+Rx.swift | 4 +- .../RxCollectionViewDataSourceProxy.swift | 59 +-- .../RxCollectionViewDelegateProxy.swift | 10 +- .../RxNavigationControllerDelegateProxy.swift | 41 +- .../Proxies/RxPickerViewDataSourceProxy.swift | 58 +-- .../Proxies/RxPickerViewDelegateProxy.swift | 36 +- .../Proxies/RxScrollViewDelegateProxy.swift | 66 +-- .../Proxies/RxSearchBarDelegateProxy.swift | 34 +- .../RxSearchControllerDelegateProxy.swift | 35 +- .../RxTabBarControllerDelegateProxy.swift | 38 +- .../iOS/Proxies/RxTabBarDelegateProxy.swift | 38 +- .../Proxies/RxTableViewDataSourceProxy.swift | 59 +-- .../Proxies/RxTableViewDelegateProxy.swift | 13 +- .../Proxies/RxTextStorageDelegateProxy.swift | 38 +- .../iOS/Proxies/RxTextViewDelegateProxy.swift | 14 +- .../iOS/Proxies/RxWebViewDelegateProxy.swift | 32 +- .../iOS/UIActivityIndicatorView+Rx.swift | 4 +- .../RxCocoa/iOS/UIAlertAction+Rx.swift | 4 +- .../RxCocoa/iOS/UIApplication+Rx.swift | 4 +- .../RxCocoa/iOS/UIBarButtonItem+Rx.swift | 14 +- .../RxCocoa/RxCocoa/iOS/UIButton+Rx.swift | 16 +- .../RxCocoa/iOS/UICollectionView+Rx.swift | 4 +- .../RxCocoa/RxCocoa/iOS/UIControl+Rx.swift | 10 +- .../RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift | 23 +- .../Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift | 8 +- .../iOS/UINavigationController+Rx.swift | 4 +- .../RxCocoa/iOS/UINavigationItem+Rx.swift | 4 +- .../RxCocoa/iOS/UIPageControl+Rx.swift | 8 +- .../RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift | 8 +- .../RxCocoa/iOS/UIProgressView+Rx.swift | 4 +- .../RxCocoa/iOS/UIRefreshControl+Rx.swift | 11 +- .../RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift | 14 +- .../RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift | 8 +- .../RxCocoa/iOS/UISearchController+Rx.swift | 4 +- .../RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift | 4 +- .../RxCocoa/iOS/UITabBarController+Rx.swift | 8 +- .../RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift | 4 +- .../RxCocoa/RxCocoa/iOS/UITableView+Rx.swift | 6 +- .../RxCocoa/RxCocoa/iOS/UITextField+Rx.swift | 17 + .../RxCocoa/RxCocoa/iOS/UITextView+Rx.swift | 40 +- .../Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift | 12 +- .../RxCocoa/iOS/UIViewController+Rx.swift | 4 +- .../RxCocoa/RxCocoa/iOS/UIWebView+Rx.swift | 4 +- RxAlamofire/Pods/RxSwift/README.md | 3 + .../Pods/RxSwift/RxSwift/Deprecated.swift | 117 ++++- .../RxSwift/RxSwift/Observables/Filter.swift | 7 +- .../RxSwift/Observables/Multicast.swift | 22 +- .../Observables/ShareReplayScope.swift | 42 +- .../Schedulers/CurrentThreadScheduler.swift | 6 +- .../RxSwift/RxSwift/Subjects/Variable.swift | 67 --- .../RxAlamofire.xcodeproj/project.pbxproj | 32 +- 89 files changed, 1698 insertions(+), 1211 deletions(-) create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Common/Binder.swift delete mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxyFactory.swift create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/BehaviorRelay.swift create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/BehaviorRelay+Driver.swift delete mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Variable+Driver.swift create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/PublishRelay.swift create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SchedulerType+SharedSequence.swift delete mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/Variable+SharedSequence.swift create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/ObservableConvertibleType+Signal.swift create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/PublishRelay+Signal.swift create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal+Subscription.swift create mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal.swift delete mode 100644 RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/UIBindingObserver.swift delete mode 100644 RxAlamofire/Pods/RxSwift/RxSwift/Subjects/Variable.swift diff --git a/Cartfile b/Cartfile index 31688714..fbfb57dd 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,2 @@ -github "ReactiveX/RxSwift" ~> 4.0.0 +github "ReactiveX/RxSwift" ~> 4.0.0-rc.0 github "Alamofire/Alamofire" ~> 4.5.1 diff --git a/RxAlamofire.podspec b/RxAlamofire.podspec index affe27d6..08fbc164 100644 --- a/RxAlamofire.podspec +++ b/RxAlamofire.podspec @@ -19,14 +19,14 @@ Pod::Spec.new do |s| s.subspec "Core" do |ss| ss.source_files = "Sources/*.swift" - ss.dependency "RxSwift", '~> 4.0.0-beta.0' - ss.dependency "Alamofire", '~> 4.5.1' + ss.dependency "RxSwift", '~> 4.0.0-rc.0' + ss.dependency "Alamofire", '~> 4.5' ss.framework = "Foundation" end s.subspec "RxCocoa" do |ss| ss.source_files = "Sources/Cocoa/*.swift" - ss.dependency "RxCocoa", '~> 4.0.0-alpha.1' + ss.dependency "RxCocoa", '~> 4.0.0-rc.0' ss.dependency "RxAlamofire/Core" end diff --git a/RxAlamofire/Podfile b/RxAlamofire/Podfile index 63323c8e..2612a379 100644 --- a/RxAlamofire/Podfile +++ b/RxAlamofire/Podfile @@ -4,8 +4,8 @@ use_frameworks! def common pod 'Alamofire', '~> 4.5.1' - pod 'RxSwift', :git => 'https://github.com/ReactiveX/RxSwift.git', :tag => '4.0.0-beta.0' - pod 'RxCocoa', :git => 'https://github.com/ReactiveX/RxSwift.git', :tag => '4.0.0-alpha.1' + pod 'RxSwift', :git => 'https://github.com/ReactiveX/RxSwift.git', :tag => '4.0.0-rc.0' + pod 'RxCocoa', :git => 'https://github.com/ReactiveX/RxSwift.git', :tag => '4.0.0-rc.0' end target 'RxAlamofire-iOS-Example' do @@ -26,7 +26,7 @@ target 'RxAlamofireTests' do common pod 'OHHTTPStubs', '~> 5.0' pod 'OHHTTPStubs/Swift', '~> 5.0' - pod 'RxBlocking', :git => 'https://github.com/ReactiveX/RxSwift.git', :tag => '4.0.0-beta.0' + pod 'RxBlocking', :git => 'https://github.com/ReactiveX/RxSwift.git', :tag => '4.0.0-rc.0' end target 'RxAlamofire-tvOS' do diff --git a/RxAlamofire/Pods/Local Podspecs/RxBlocking.podspec.json b/RxAlamofire/Pods/Local Podspecs/RxBlocking.podspec.json index 7292fb3a..121af7fe 100644 --- a/RxAlamofire/Pods/Local Podspecs/RxBlocking.podspec.json +++ b/RxAlamofire/Pods/Local Podspecs/RxBlocking.podspec.json @@ -1,6 +1,6 @@ { "name": "RxBlocking", - "version": "4.0.0-beta.0", + "version": "4.0.0-rc.0", "summary": "RxSwift Blocking operatos", "description": "Set of blocking operators for RxSwift. These operators are mostly intended for unit/integration tests\nwith a couple of other special scenarios where they could be useful.\n\nE.g.\n\nWaiting for observable sequence to complete before exiting command line application.", "homepage": "https://github.com/ReactiveX/RxSwift", @@ -10,7 +10,7 @@ }, "source": { "git": "https://github.com/ReactiveX/RxSwift.git", - "tag": "4.0.0-beta.0" + "tag": "4.0.0-rc.0" }, "requires_arc": true, "platforms": { @@ -26,7 +26,7 @@ "exclude_files": "RxBlocking/Platform/**/*.swift", "dependencies": { "RxSwift": [ - "~> 4.0.0-beta.0" + "~> 4.0.0-rc.0" ] } } diff --git a/RxAlamofire/Pods/Local Podspecs/RxCocoa.podspec.json b/RxAlamofire/Pods/Local Podspecs/RxCocoa.podspec.json index bd516add..3eaf4331 100644 --- a/RxAlamofire/Pods/Local Podspecs/RxCocoa.podspec.json +++ b/RxAlamofire/Pods/Local Podspecs/RxCocoa.podspec.json @@ -1,6 +1,6 @@ { "name": "RxCocoa", - "version": "4.0.0-alpha.1", + "version": "4.0.0-rc.0", "summary": "RxSwift Cocoa extensions", "description": "* UI extensions\n* NSURL extensions\n* KVO extensions", "homepage": "https://github.com/ReactiveX/RxSwift", @@ -10,7 +10,7 @@ }, "source": { "git": "https://github.com/ReactiveX/RxSwift.git", - "tag": "4.0.0-alpha.1" + "tag": "4.0.0-rc.0" }, "requires_arc": true, "platforms": { @@ -43,7 +43,7 @@ }, "dependencies": { "RxSwift": [ - "~> 4.0.0-alpha.1" + "~> 4.0.0-rc.0" ] } } diff --git a/RxAlamofire/Pods/Local Podspecs/RxSwift.podspec.json b/RxAlamofire/Pods/Local Podspecs/RxSwift.podspec.json index 3ca86b32..21146f4d 100644 --- a/RxAlamofire/Pods/Local Podspecs/RxSwift.podspec.json +++ b/RxAlamofire/Pods/Local Podspecs/RxSwift.podspec.json @@ -1,6 +1,6 @@ { "name": "RxSwift", - "version": "4.0.0-beta.0", + "version": "4.0.0-rc.0", "summary": "RxSwift is a Swift implementation of Reactive Extensions", "description": "This is a Swift port of [ReactiveX.io](https://github.com/ReactiveX)\n\nLike the original [Rx](https://github.com/Reactive-extensions/Rx.Net), its intention is to enable easy composition of asynchronous operations and event streams.\n\nIt tries to port as many concepts from the original Rx as possible, but some concepts were adapted for more pleasant and performant integration with iOS/macOS/Linux environment.\n\nProbably the best analogy for those who have never heard of Rx would be:\n\n```\ngit diff | grep bug | less # linux pipes - programs communicate by sending\n\t\t\t\t # sequences of bytes, words, lines, '\u0000' terminated strings...\n```\nwould become if written in RxSwift\n```\ngitDiff().grep(\"bug\").less // sequences of swift objects\n```", "homepage": "https://github.com/ReactiveX/RxSwift", @@ -10,7 +10,7 @@ }, "source": { "git": "https://github.com/ReactiveX/RxSwift.git", - "tag": "4.0.0-beta.0" + "tag": "4.0.0-rc.0" }, "requires_arc": true, "platforms": { diff --git a/RxAlamofire/Pods/RxBlocking/README.md b/RxAlamofire/Pods/RxBlocking/README.md index bdf8a2ba..503068d2 100644 --- a/RxAlamofire/Pods/RxBlocking/README.md +++ b/RxAlamofire/Pods/RxBlocking/README.md @@ -3,6 +3,9 @@ [![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) +* RxSwift 4.x / Swift 4.x can be found in [**rxswift4.0-swift4.0** branch](https://github.com/ReactiveX/RxSwift/tree/rxswift4.0-swift4.0). +* RxSwift 3.x / Swift 3.x can be found in [**master** branch](https://github.com/ReactiveX/RxSwift/tree/master). + Rx is a [generic abstraction of computation](https://youtu.be/looJcaeboBY) expressed through `Observable` interface. This is a Swift version of [Rx](https://github.com/Reactive-Extensions/Rx.NET). diff --git a/RxAlamofire/Pods/RxCocoa/README.md b/RxAlamofire/Pods/RxCocoa/README.md index bdf8a2ba..503068d2 100644 --- a/RxAlamofire/Pods/RxCocoa/README.md +++ b/RxAlamofire/Pods/RxCocoa/README.md @@ -3,6 +3,9 @@ [![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) +* RxSwift 4.x / Swift 4.x can be found in [**rxswift4.0-swift4.0** branch](https://github.com/ReactiveX/RxSwift/tree/rxswift4.0-swift4.0). +* RxSwift 3.x / Swift 3.x can be found in [**master** branch](https://github.com/ReactiveX/RxSwift/tree/master). + Rx is a [generic abstraction of computation](https://youtu.be/looJcaeboBY) expressed through `Observable` interface. This is a Swift version of [Rx](https://github.com/Reactive-Extensions/Rx.NET). diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/Binder.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/Binder.swift new file mode 100644 index 00000000..129af567 --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/Binder.swift @@ -0,0 +1,61 @@ +// +// Binder.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 9/17/17. +// Copyright © 2017 Krunoslav Zaher. All rights reserved. +// + +import RxSwift + +/** + Observer that enforces interface binding rules: + * can't bind errors (in debug builds binding of errors causes `fatalError` in release builds errors are being logged) + * ensures binding is performed on a specific scheduler + + `Binder` doesn't retain target and in case target is released, element isn't bound. + + By default it binds elements on main scheduler. + */ +public struct Binder: ObserverType { + public typealias E = Value + + private let _binding: (Event) -> () + + /// Initializes `Binder` + /// + /// - parameter target: Target object. + /// - parameter scheduler: Scheduler used to bind the events. + /// - parameter binding: Binding logic. + public init(_ target: Target, scheduler: ImmediateSchedulerType = MainScheduler(), binding: @escaping (Target, Value) -> ()) { + weak var weakTarget = target + + _binding = { event in + switch event { + case .next(let element): + _ = scheduler.schedule(element) { element in + if let target = weakTarget { + binding(target, element) + } + return Disposables.create() + } + case .error(let error): + bindingError(error) + case .completed: + break + } + } + } + + /// Binds next element to owner view as described in `binding`. + public func on(_ event: Event) { + _binding(event) + } + + /// Erases type of observer. + /// + /// - returns: type erased observer. + public func asObserver() -> AnyObserver { + return AnyObserver(eventHandler: on) + } +} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxy.swift index 9a40690e..f656e6b2 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxy.swift @@ -10,295 +10,269 @@ #if !RX_NO_MODULE import RxSwift - #if SWIFT_PACKAGE && !os(Linux) - import RxCocoaRuntime - #endif +#if SWIFT_PACKAGE && !os(Linux) + import RxCocoaRuntime +#endif #endif -var delegateAssociatedTag: UnsafeRawPointer = UnsafeRawPointer(UnsafeMutablePointer.allocate(capacity: 1)) -var dataSourceAssociatedTag: UnsafeRawPointer = UnsafeRawPointer(UnsafeMutablePointer.allocate(capacity: 1)) + /// Base class for `DelegateProxyType` protocol. + /// + /// This implementation is not thread safe and can be used only from one thread (Main thread). + open class DelegateProxy: _RXDelegateProxy { + public typealias ParentObject = P + public typealias Delegate = D -/// Base class for `DelegateProxyType` protocol. -/// -/// This implementation is not thread safe and can be used only from one thread (Main thread). -open class DelegateProxy : _RXDelegateProxy { + private var _sentMessageForSelector = [Selector: MessageDispatcher]() + private var _methodInvokedForSelector = [Selector: MessageDispatcher]() - private var sentMessageForSelector = [Selector: MessageDispatcher]() - private var methodInvokedForSelector = [Selector: MessageDispatcher]() + /// Parent object associated with delegate proxy. + private weak private(set) var _parentObject: ParentObject? - /// Parent object associated with delegate proxy. - weak private(set) var parentObject: AnyObject? - - /// Initializes new instance. - /// - /// - parameter parentObject: Optional parent object that owns `DelegateProxy` as associated object. - public required init(parentObject: AnyObject) { - self.parentObject = parentObject - - MainScheduler.ensureExecutingOnScheduler() -#if TRACE_RESOURCES - _ = Resources.incrementTotal() -#endif - super.init() - } + fileprivate let _currentDelegateFor: (ParentObject) -> Delegate? + fileprivate let _setCurrentDelegateTo: (Delegate?, ParentObject) -> () - /** - Returns observable sequence of invocations of delegate methods. Elements are sent *before method is invoked*. - - Only methods that have `void` return value can be observed using this method because - those methods are used as a notification mechanism. It doesn't matter if they are optional - or not. Observing is performed by installing a hidden associated `PublishSubject` that is - used to dispatch messages to observers. - - Delegate methods that have non `void` return value can't be observed directly using this method - because: - * those methods are not intended to be used as a notification mechanism, but as a behavior customization mechanism - * there is no sensible automatic way to determine a default return value - - In case observing of delegate methods that have return type is required, it can be done by - manually installing a `PublishSubject` or `BehaviorSubject` and implementing delegate method. - - e.g. - - // delegate proxy part (RxScrollViewDelegateProxy) - - let internalSubject = PublishSubject - - public func requiredDelegateMethod(scrollView: UIScrollView, arg1: CGPoint) -> Bool { - internalSubject.on(.next(arg1)) - return self._forwardToDelegate?.requiredDelegateMethod?(scrollView, arg1: arg1) ?? defaultReturnValue - } - - .... + /// Initializes new instance. + /// + /// - parameter parentObject: Optional parent object that owns `DelegateProxy` as associated object. + public init(parentObject: ParentObject, delegateProxy: Proxy.Type) + where Proxy: DelegateProxy, Proxy.ParentObject == ParentObject, Proxy.Delegate == Delegate { + self._parentObject = parentObject + self._currentDelegateFor = delegateProxy.currentDelegate(for:) + self._setCurrentDelegateTo = delegateProxy.setCurrentDelegate(_:to:) - // reactive property implementation in a real class (`UIScrollView`) - public var property: Observable { - let proxy = RxScrollViewDelegateProxy.proxyForObject(base) - return proxy.internalSubject.asObservable() - } - - **In case calling this method prints "Delegate proxy is already implementing `\(selector)`, - a more performant way of registering might exist.", that means that manual observing method - is required analog to the example above because delegate method has already been implemented.** - - - parameter selector: Selector used to filter observed invocations of delegate methods. - - returns: Observable sequence of arguments passed to `selector` method. - */ - open func sentMessage(_ selector: Selector) -> Observable<[Any]> { - MainScheduler.ensureExecutingOnScheduler() - checkSelectorIsObservable(selector) - - let subject = sentMessageForSelector[selector] - - if let subject = subject { - return subject.asObservable() - } - else { - let subject = MessageDispatcher(delegateProxy: self) - sentMessageForSelector[selector] = subject - return subject.asObservable() + MainScheduler.ensureExecutingOnScheduler() + #if TRACE_RESOURCES + _ = Resources.incrementTotal() + #endif + super.init() } - } - /** - Returns observable sequence of invoked delegate methods. Elements are sent *after method is invoked*. - - Only methods that have `void` return value can be observed using this method because - those methods are used as a notification mechanism. It doesn't matter if they are optional - or not. Observing is performed by installing a hidden associated `PublishSubject` that is - used to dispatch messages to observers. - - Delegate methods that have non `void` return value can't be observed directly using this method - because: - * those methods are not intended to be used as a notification mechanism, but as a behavior customization mechanism - * there is no sensible automatic way to determine a default return value - - In case observing of delegate methods that have return type is required, it can be done by - manually installing a `PublishSubject` or `BehaviorSubject` and implementing delegate method. - - e.g. - - // delegate proxy part (RxScrollViewDelegateProxy) - - let internalSubject = PublishSubject - - public func requiredDelegateMethod(scrollView: UIScrollView, arg1: CGPoint) -> Bool { - internalSubject.on(.next(arg1)) - return self._forwardToDelegate?.requiredDelegateMethod?(scrollView, arg1: arg1) ?? defaultReturnValue - } - - .... + /** + Returns observable sequence of invocations of delegate methods. Elements are sent *before method is invoked*. - // reactive property implementation in a real class (`UIScrollView`) - public var property: Observable { - let proxy = RxScrollViewDelegateProxy.proxyForObject(base) - return proxy.internalSubject.asObservable() - } + Only methods that have `void` return value can be observed using this method because + those methods are used as a notification mechanism. It doesn't matter if they are optional + or not. Observing is performed by installing a hidden associated `PublishSubject` that is + used to dispatch messages to observers. - **In case calling this method prints "Delegate proxy is already implementing `\(selector)`, - a more performant way of registering might exist.", that means that manual observing method - is required analog to the example above because delegate method has already been implemented.** + Delegate methods that have non `void` return value can't be observed directly using this method + because: + * those methods are not intended to be used as a notification mechanism, but as a behavior customization mechanism + * there is no sensible automatic way to determine a default return value - - parameter selector: Selector used to filter observed invocations of delegate methods. - - returns: Observable sequence of arguments passed to `selector` method. - */ - open func methodInvoked(_ selector: Selector) -> Observable<[Any]> { - MainScheduler.ensureExecutingOnScheduler() - checkSelectorIsObservable(selector) + In case observing of delegate methods that have return type is required, it can be done by + manually installing a `PublishSubject` or `BehaviorSubject` and implementing delegate method. - let subject = methodInvokedForSelector[selector] + e.g. - if let subject = subject { - return subject.asObservable() - } - else { - let subject = MessageDispatcher(delegateProxy: self) - methodInvokedForSelector[selector] = subject - return subject.asObservable() - } - } + // delegate proxy part (RxScrollViewDelegateProxy) - private func checkSelectorIsObservable(_ selector: Selector) { - MainScheduler.ensureExecutingOnScheduler() + let internalSubject = PublishSubject - if hasWiredImplementation(for: selector) { - print("Delegate proxy is already implementing `\(selector)`, a more performant way of registering might exist.") - return - } + public func requiredDelegateMethod(scrollView: UIScrollView, arg1: CGPoint) -> Bool { + internalSubject.on(.next(arg1)) + return self._forwardToDelegate?.requiredDelegateMethod?(scrollView, arg1: arg1) ?? defaultReturnValue + } + + .... + + // reactive property implementation in a real class (`UIScrollView`) + public var property: Observable { + let proxy = RxScrollViewDelegateProxy.proxy(for: base) + return proxy.internalSubject.asObservable() + } + + **In case calling this method prints "Delegate proxy is already implementing `\(selector)`, + a more performant way of registering might exist.", that means that manual observing method + is required analog to the example above because delegate method has already been implemented.** - guard (self.forwardToDelegate()?.responds(to: selector) ?? false) || voidDelegateMethodsContain(selector) else { - rxFatalError("This class doesn't respond to selector \(selector)") + - parameter selector: Selector used to filter observed invocations of delegate methods. + - returns: Observable sequence of arguments passed to `selector` method. + */ + open func sentMessage(_ selector: Selector) -> Observable<[Any]> { + MainScheduler.ensureExecutingOnScheduler() + checkSelectorIsObservable(selector) + + let subject = _sentMessageForSelector[selector] + + if let subject = subject { + return subject.asObservable() + } + else { + let subject = MessageDispatcher(delegateProxy: self) + _sentMessageForSelector[selector] = subject + return subject.asObservable() + } } - } - // proxy + /** + Returns observable sequence of invoked delegate methods. Elements are sent *after method is invoked*. - open override func _sentMessage(_ selector: Selector, withArguments arguments: [Any]) { - sentMessageForSelector[selector]?.on(.next(arguments)) - } + Only methods that have `void` return value can be observed using this method because + those methods are used as a notification mechanism. It doesn't matter if they are optional + or not. Observing is performed by installing a hidden associated `PublishSubject` that is + used to dispatch messages to observers. - open override func _methodInvoked(_ selector: Selector, withArguments arguments: [Any]) { - methodInvokedForSelector[selector]?.on(.next(arguments)) - } + Delegate methods that have non `void` return value can't be observed directly using this method + because: + * those methods are not intended to be used as a notification mechanism, but as a behavior customization mechanism + * there is no sensible automatic way to determine a default return value - /// Returns tag used to identify associated object. - /// - /// - returns: Associated object tag. - open class func delegateAssociatedObjectTag() -> UnsafeRawPointer { - return delegateAssociatedTag - } - - /// Returns assigned proxy for object. - /// - /// - parameter object: Object that can have assigned delegate proxy. - /// - returns: Assigned delegate proxy or `nil` if no delegate proxy is assigned. - open class func assignedProxyFor(_ object: AnyObject) -> AnyObject? { - let maybeDelegate = objc_getAssociatedObject(object, self.delegateAssociatedObjectTag()) - return castOptionalOrFatalError(maybeDelegate.map { $0 as AnyObject }) - } - - /// Assigns proxy to object. - /// - /// - parameter object: Object that can have assigned delegate proxy. - /// - parameter proxy: Delegate proxy object to assign to `object`. - open class func assignProxy(_ proxy: AnyObject, toObject object: AnyObject) { - precondition(proxy.isKind(of: self.classForCoder())) - - objc_setAssociatedObject(object, self.delegateAssociatedObjectTag(), proxy, .OBJC_ASSOCIATION_RETAIN) - } - - /// Sets reference of normal delegate that receives all forwarded messages - /// through `self`. - /// - /// - parameter forwardToDelegate: Reference of delegate that receives all messages through `self`. - /// - parameter retainDelegate: Should `self` retain `forwardToDelegate`. - open func setForwardToDelegate(_ delegate: AnyObject?, retainDelegate: Bool) { - #if DEBUG // 4.0 all configurations + In case observing of delegate methods that have return type is required, it can be done by + manually installing a `PublishSubject` or `BehaviorSubject` and implementing delegate method. + + e.g. + + // delegate proxy part (RxScrollViewDelegateProxy) + + let internalSubject = PublishSubject + + public func requiredDelegateMethod(scrollView: UIScrollView, arg1: CGPoint) -> Bool { + internalSubject.on(.next(arg1)) + return self._forwardToDelegate?.requiredDelegateMethod?(scrollView, arg1: arg1) ?? defaultReturnValue + } + + .... + + // reactive property implementation in a real class (`UIScrollView`) + public var property: Observable { + let proxy = RxScrollViewDelegateProxy.proxy(for: base) + return proxy.internalSubject.asObservable() + } + + **In case calling this method prints "Delegate proxy is already implementing `\(selector)`, + a more performant way of registering might exist.", that means that manual observing method + is required analog to the example above because delegate method has already been implemented.** + + - parameter selector: Selector used to filter observed invocations of delegate methods. + - returns: Observable sequence of arguments passed to `selector` method. + */ + open func methodInvoked(_ selector: Selector) -> Observable<[Any]> { MainScheduler.ensureExecutingOnScheduler() - #endif - self._setForward(toDelegate: delegate, retainDelegate: retainDelegate) - self.reset() - } - - /// Returns reference of normal delegate that receives all forwarded messages - /// through `self`. - /// - /// - returns: Value of reference if set or nil. - open func forwardToDelegate() -> AnyObject? { - return self._forwardToDelegate - } + checkSelectorIsObservable(selector) + + let subject = _methodInvokedForSelector[selector] + + if let subject = subject { + return subject.asObservable() + } + else { + let subject = MessageDispatcher(delegateProxy: self) + _methodInvokedForSelector[selector] = subject + return subject.asObservable() + } + } - private func hasObservers(selector: Selector) -> Bool { - return (sentMessageForSelector[selector]?.hasObservers ?? false) - || (methodInvokedForSelector[selector]?.hasObservers ?? false) - } - - override open func responds(to aSelector: Selector!) -> Bool { - return super.responds(to: aSelector) - || (self._forwardToDelegate?.responds(to: aSelector) ?? false) - || (self.voidDelegateMethodsContain(aSelector) && self.hasObservers(selector: aSelector)) - } + private func checkSelectorIsObservable(_ selector: Selector) { + MainScheduler.ensureExecutingOnScheduler() - internal func reset() { - guard let delegateProxySelf = self as? DelegateProxyType else { - rxFatalErrorInDebug("\(self) doesn't implement delegate proxy type.") - return + if hasWiredImplementation(for: selector) { + print("Delegate proxy is already implementing `\(selector)`, a more performant way of registering might exist.") + return + } + + guard (self.forwardToDelegate()?.responds(to: selector) ?? false) || voidDelegateMethodsContain(selector) else { + rxFatalError("This class doesn't respond to selector \(selector)") + } } - - guard let parentObject = self.parentObject else { return } - let selfType = type(of: delegateProxySelf) + // proxy - let maybeCurrentDelegate = selfType.currentDelegateFor(parentObject) + open override func _sentMessage(_ selector: Selector, withArguments arguments: [Any]) { + _sentMessageForSelector[selector]?.on(.next(arguments)) + } - if maybeCurrentDelegate === self { - selfType.setCurrentDelegate(nil, toObject: parentObject) - selfType.setCurrentDelegate(self, toObject: parentObject) + open override func _methodInvoked(_ selector: Selector, withArguments arguments: [Any]) { + _methodInvokedForSelector[selector]?.on(.next(arguments)) } - } - deinit { - for v in sentMessageForSelector.values { - v.on(.completed) + /// Returns reference of normal delegate that receives all forwarded messages + /// through `self`. + /// + /// - returns: Value of reference if set or nil. + public func forwardToDelegate() -> Delegate? { + return castOptionalOrFatalError(self._forwardToDelegate) } - for v in methodInvokedForSelector.values { - v.on(.completed) + + /// Sets reference of normal delegate that receives all forwarded messages + /// through `self`. + /// + /// - parameter forwardToDelegate: Reference of delegate that receives all messages through `self`. + /// - parameter retainDelegate: Should `self` retain `forwardToDelegate`. + public func setForwardToDelegate(_ delegate: Delegate?, retainDelegate: Bool) { + #if DEBUG // 4.0 all configurations + MainScheduler.ensureExecutingOnScheduler() + #endif + self._setForwardToDelegate(delegate, retainDelegate: retainDelegate) + self.reset() } -#if TRACE_RESOURCES - _ = Resources.decrementTotal() -#endif - } -} -fileprivate let mainScheduler = MainScheduler() + private func hasObservers(selector: Selector) -> Bool { + return (_sentMessageForSelector[selector]?.hasObservers ?? false) + || (_methodInvokedForSelector[selector]?.hasObservers ?? false) + } -fileprivate final class MessageDispatcher { - private let dispatcher: PublishSubject<[Any]> - private let result: Observable<[Any]> + override open func responds(to aSelector: Selector!) -> Bool { + return super.responds(to: aSelector) + || (self._forwardToDelegate?.responds(to: aSelector) ?? false) + || (self.voidDelegateMethodsContain(aSelector) && self.hasObservers(selector: aSelector)) + } - init(delegateProxy _delegateProxy: DelegateProxy) { - weak var weakDelegateProxy = _delegateProxy + fileprivate func reset() { + guard let parentObject = self._parentObject else { return } - let dispatcher = PublishSubject<[Any]>() - self.dispatcher = dispatcher + let maybeCurrentDelegate = _currentDelegateFor(parentObject) - self.result = dispatcher - .do(onSubscribed: { weakDelegateProxy?.reset() }, onDispose: { weakDelegateProxy?.reset() }) - .share() - .subscribeOn(mainScheduler) - } + if maybeCurrentDelegate === self { + _setCurrentDelegateTo(nil, parentObject) + _setCurrentDelegateTo(castOrFatalError(self), parentObject) + } + } - var on: (Event<[Any]>) -> () { - return self.dispatcher.on - } + deinit { + for v in _sentMessageForSelector.values { + v.on(.completed) + } + for v in _methodInvokedForSelector.values { + v.on(.completed) + } + #if TRACE_RESOURCES + _ = Resources.decrementTotal() + #endif + } + - var hasObservers: Bool { - return self.dispatcher.hasObservers } - func asObservable() -> Observable<[Any]> { - return self.result + fileprivate let mainScheduler = MainScheduler() + + fileprivate final class MessageDispatcher { + private let dispatcher: PublishSubject<[Any]> + private let result: Observable<[Any]> + + init(delegateProxy _delegateProxy: DelegateProxy) { + weak var weakDelegateProxy = _delegateProxy + + let dispatcher = PublishSubject<[Any]>() + self.dispatcher = dispatcher + + self.result = dispatcher + .do(onSubscribed: { weakDelegateProxy?.reset() }, onDispose: { weakDelegateProxy?.reset() }) + .share() + .subscribeOn(mainScheduler) + } + + var on: (Event<[Any]>) -> () { + return self.dispatcher.on + } + + var hasObservers: Bool { + return self.dispatcher.hasObservers + } + + func asObservable() -> Observable<[Any]> { + return self.result + } } -} #endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxyFactory.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxyFactory.swift deleted file mode 100644 index 7cf34eb3..00000000 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxyFactory.swift +++ /dev/null @@ -1,76 +0,0 @@ -// -// DelegateProxyFactory.swift -// RxCocoa -// -// Created by tarunon on 2017/06/17. -// Copyright © 2017 Krunoslav Zaher. All rights reserved. -// - -#if !os(Linux) - -#if !RX_NO_MODULE - import RxSwift -#endif - -/** -Define `DelegateProxy.init` for a specific object type. -For example, in RxScrollViewDelegateProxy - - - class RxScrollViewDelegateProxy: DelegateProxy { - static var factory = DelegateProxyFactory { (parentObject: UIScrollView) in - RxScrollViewDelegateProxy(parentObject: parentObject) - } - ... - - -If need to extend them, chain `extended` after DelegateProxyFactory.init - - class RxScrollViewDelegateProxy: DelegateProxy { - static var factory = DelegateProxyFactory { (parentObject: UIScrollView) in - RxScrollViewDelegateProxy(parentObject: parentObject) - } - .extended { (parentObject: UITableView) in - RxTableViewDelegateProxy(parentObject: parentObject) - } - ... - - - */ -public class DelegateProxyFactory { - private var _factories: [ObjectIdentifier: ((AnyObject) -> AnyObject)] - public init(factory: @escaping (Object) -> AnyObject) { - _factories = [ObjectIdentifier(Object.self): { factory(castOrFatalError($0)) }] - } - - /** - Extend DelegateProxyFactory for specific object class and delegate proxy. - Define object class on closure argument. - */ - public func extended(factory: @escaping (Object) -> AnyObject) -> DelegateProxyFactory { - MainScheduler.ensureExecutingOnScheduler() - guard _factories[ObjectIdentifier(Object.self)] == nil else { - rxFatalError("The factory of \(Object.self) is duplicated. DelegateProxy is not allowed of duplicated base object type.") - } - _factories[ObjectIdentifier(Object.self)] = { factory(castOrFatalError($0)) } - return self - } - - /** - Create DelegateProxy for object. - DelegateProxyFactory should have a factory of object class (or superclass). - */ - public func createProxy(for object: AnyObject) -> AnyObject { - MainScheduler.ensureExecutingOnScheduler() - var mirror: Mirror? = Mirror(reflecting: object) - while mirror != nil { - if let factory = _factories[ObjectIdentifier(mirror!.subjectType)] { - return factory(object) - } - mirror = mirror?.superclassMirror - } - rxFatalError("DelegateProxy has no factory of \(object). Call 'DelegateProxy.extend' first.") - } -} - -#endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxyType.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxyType.swift index 94623a11..5f2b7c2a 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxyType.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/DelegateProxyType.swift @@ -8,9 +8,12 @@ #if !os(Linux) -#if !RX_NO_MODULE -import RxSwift -#endif + import func Foundation.objc_getAssociatedObject + import func Foundation.objc_setAssociatedObject + + #if !RX_NO_MODULE + import RxSwift + #endif /** `DelegateProxyType` protocol enables using both normal delegates and Rx observable sequences with @@ -21,7 +24,7 @@ for specific views. Type implementing `DelegateProxyType` should never be initialized directly. -To fetch initialized instance of type implementing `DelegateProxyType`, `proxyForObject` method +To fetch initialized instance of type implementing `DelegateProxyType`, `proxy` method should be used. This is more or less how it works. @@ -55,61 +58,41 @@ This is more or less how it works. +-------------------------------------------+ -Since RxCocoa needs to automagically create those Proxys -..and because views that have delegates can be hierarchical +Since RxCocoa needs to automagically create those Proxys and because views that have delegates can be hierarchical -UITableView : UIScrollView : UIView + UITableView : UIScrollView : UIView .. and corresponding delegates are also hierarchical -UITableViewDelegate : UIScrollViewDelegate : NSObject + UITableViewDelegate : UIScrollViewDelegate : NSObject -.. and sometimes there can be only one proxy/delegate registered, -every view has a corresponding delegate virtual factory method. - -In case of UITableView / UIScrollView, there is - - class RxScrollViewDelegateProxy: DelegateProxy { - static var factory = DelegateProxyFactory { (parentObject: UIScrollView) in - RxScrollViewDelegateProxy(parentObject: parentObject) - } - } - .... - - -and extend it - - RxScrollViewDelegateProxy.extendProxy { (parentObject: UITableView) in - RxTableViewDelegateProxy(parentObject: parentObject) - } +... this mechanism can be extended by using the following snippet in `registerKnownImplementations` or in some other + part of your app that executes before using `rx.*` (e.g. appDidFinishLaunching). + RxScrollViewDelegateProxy.register { RxTableViewDelegateProxy(parentObject: $0) } */ public protocol DelegateProxyType : AnyObject { - /// DelegateProxy factory - static var factory: DelegateProxyFactory { get } - - /// Returns assigned proxy for object. - /// - /// - parameter object: Object that can have assigned delegate proxy. - /// - returns: Assigned delegate proxy or `nil` if no delegate proxy is assigned. - static func assignedProxyFor(_ object: AnyObject) -> AnyObject? - - /// Assigns proxy to object. - /// - /// - parameter object: Object that can have assigned delegate proxy. - /// - parameter proxy: Delegate proxy object to assign to `object`. - static func assignProxy(_ proxy: AnyObject, toObject object: AnyObject) + associatedtype ParentObject: AnyObject + associatedtype Delegate: AnyObject + /// It is require that enumerate call `register` of the extended DelegateProxy subclasses here. + static func registerKnownImplementations() + + /// Unique identifier for delegate + static var identifier: UnsafeRawPointer { get } + /// Returns designated delegate property for object. /// /// Objects can have multiple delegate properties. /// /// Each delegate property needs to have it's own type implementing `DelegateProxyType`. /// + /// It's abstract method. + /// /// - parameter object: Object that has delegate property. /// - returns: Value of delegate property. - static func currentDelegateFor(_ object: AnyObject) -> AnyObject? + static func currentDelegate(for object: ParentObject) -> Delegate? /// Sets designated delegate property for object. /// @@ -117,25 +100,52 @@ public protocol DelegateProxyType : AnyObject { /// /// Each delegate property needs to have it's own type implementing `DelegateProxyType`. /// + /// It's abstract method. + /// /// - parameter toObject: Object that has delegate property. /// - parameter delegate: Delegate value. - static func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) - + static func setCurrentDelegate(_ delegate: Delegate?, to object: ParentObject) + /// Returns reference of normal delegate that receives all forwarded messages /// through `self`. /// /// - returns: Value of reference if set or nil. - func forwardToDelegate() -> AnyObject? + func forwardToDelegate() -> Delegate? /// Sets reference of normal delegate that receives all forwarded messages /// through `self`. /// /// - parameter forwardToDelegate: Reference of delegate that receives all messages through `self`. /// - parameter retainDelegate: Should `self` retain `forwardToDelegate`. - func setForwardToDelegate(_ forwardToDelegate: AnyObject?, retainDelegate: Bool) + func setForwardToDelegate(_ forwardToDelegate: Delegate?, retainDelegate: Bool) } +// default implementations extension DelegateProxyType { + /// Unique identifier for delegate + public static var identifier: UnsafeRawPointer { + let delegateIdentifier = ObjectIdentifier(Delegate.self) + let integerIdentifier = Int(bitPattern: delegateIdentifier) + return UnsafeRawPointer(bitPattern: integerIdentifier)! + } +} + +extension DelegateProxyType { + + /// Store DelegateProxy subclass to factory. + /// When make 'Rx*DelegateProxy' subclass, call 'Rx*DelegateProxySubclass.register(for:_)' 1 time, or use it in DelegateProxyFactory + /// 'Rx*DelegateProxy' can have one subclass implementation per concrete ParentObject type. + /// Should call it from concrete DelegateProxy type, not generic. + public static func register(make: @escaping (Parent) -> Self) { + self.factory.extend(make: make) + } + + /// Creates new proxy for target object. + /// Should not call this function directory, use 'DelegateProxy.proxy(for:)' + public static func createProxy(for object: AnyObject) -> Self { + return castOrFatalError(factory.createProxy(for: object)) + } + /// Returns existing proxy for object or installs new instance of delegate proxy. /// /// - parameter object: Target object on which to install delegate proxy. @@ -144,8 +154,8 @@ extension DelegateProxyType { /// /// extension Reactive where Base: UISearchBar { /// - /// public var delegate: DelegateProxy { - /// return RxSearchBarDelegateProxy.proxyForObject(base) + /// public var delegate: DelegateProxy { + /// return RxSearchBarDelegateProxy.proxy(for: base) /// } /// /// public var text: ControlProperty { @@ -153,32 +163,33 @@ extension DelegateProxyType { /// ... /// } /// } - public static func proxyForObject(_ object: AnyObject) -> Self { + public static func proxy(for object: ParentObject) -> Self { MainScheduler.ensureExecutingOnScheduler() - let maybeProxy = Self.assignedProxyFor(object) as? Self + let maybeProxy = self.assignedProxy(for: object) - let proxy: Self + // Type is ideally be `(Self & Delegate)`, but Swift 3.0 doesn't support it. + let proxy: Delegate if let existingProxy = maybeProxy { proxy = existingProxy } else { - proxy = Self.createProxy(for: object) as! Self - Self.assignProxy(proxy, toObject: object) - assert(Self.assignedProxyFor(object) === proxy) + proxy = castOrFatalError(self.createProxy(for: object)) + self.assignProxy(proxy, toObject: object) + assert(self.assignedProxy(for: object) === proxy) } - - let currentDelegate: AnyObject? = Self.currentDelegateFor(object) - - if currentDelegate !== proxy { - proxy.setForwardToDelegate(currentDelegate, retainDelegate: false) - assert(proxy.forwardToDelegate() === currentDelegate) - Self.setCurrentDelegate(proxy, toObject: object) - assert(Self.currentDelegateFor(object) === proxy) - assert(proxy.forwardToDelegate() === currentDelegate) + let currentDelegate = self.currentDelegate(for: object) + let delegateProxy: Self = castOrFatalError(proxy) + + if currentDelegate !== delegateProxy { + delegateProxy.setForwardToDelegate(currentDelegate, retainDelegate: false) + assert(delegateProxy.forwardToDelegate() === currentDelegate) + self.setCurrentDelegate(proxy, to: object) + assert(self.currentDelegate(for: object) === proxy) + assert(delegateProxy.forwardToDelegate() === currentDelegate) } - return proxy + return delegateProxy } /// Sets forward delegate for `DelegateProxyType` associated with a specific object and return disposable that can be used to unset the forward to delegate. @@ -188,11 +199,10 @@ extension DelegateProxyType { /// - parameter retainDelegate: Retain `forwardDelegate` while it's being set. /// - parameter onProxyForObject: Object that has `delegate` property. /// - returns: Disposable object that can be used to clear forward delegate. - public static func installForwardDelegate(_ forwardDelegate: AnyObject, retainDelegate: Bool, onProxyForObject object: AnyObject) -> Disposable { + public static func installForwardDelegate(_ forwardDelegate: Delegate, retainDelegate: Bool, onProxyForObject object: ParentObject) -> Disposable { weak var weakForwardDelegate: AnyObject? = forwardDelegate + let proxy = self.proxy(for: object) - let proxy = Self.proxyForObject(object) - assert(proxy.forwardToDelegate() === nil, "This is a feature to warn you that there is already a delegate (or data source) set somewhere previously. The action you are trying to perform will clear that delegate (data source) and that means that some of your features that depend on that delegate (data source) being set will likely stop working.\n" + "If you are ok with this, try to set delegate (data source) to `nil` in front of this operation.\n" + " This is the source object value: \(object)\n" + @@ -200,27 +210,73 @@ extension DelegateProxyType { "Hint: Maybe delegate was already set in xib or storyboard and now it's being overwritten in code.\n") proxy.setForwardToDelegate(forwardDelegate, retainDelegate: retainDelegate) - + return Disposables.create { MainScheduler.ensureExecutingOnScheduler() - + let delegate: AnyObject? = weakForwardDelegate - + assert(delegate == nil || proxy.forwardToDelegate() === delegate, "Delegate was changed from time it was first set. Current \(String(describing: proxy.forwardToDelegate())), and it should have been \(proxy)") - + proxy.setForwardToDelegate(nil, retainDelegate: retainDelegate) } } - - /// Extend DelegateProxy for specific subclass - /// See 'DelegateProxyFactory.extendedProxy' - public static func extendProxy(with creation: @escaping ((Object) -> AnyObject)) { - _ = factory.extended(factory: creation) +} + + +// fileprivate extensions +extension DelegateProxyType +{ + fileprivate static var factory: DelegateProxyFactory { + return DelegateProxyFactory.sharedFactory(for: self) } - - /// Creates new proxy for target object. - public static func createProxy(for object: AnyObject) -> AnyObject { - return factory.createProxy(for: object) + + + fileprivate static func assignedProxy(for object: ParentObject) -> Delegate? { + let maybeDelegate = objc_getAssociatedObject(object, self.identifier) + return castOptionalOrFatalError(maybeDelegate.map { $0 as AnyObject }) + } + + fileprivate static func assignProxy(_ proxy: Delegate, toObject object: ParentObject) { + objc_setAssociatedObject(object, self.identifier, proxy, .OBJC_ASSOCIATION_RETAIN) + } +} + +/// Describes an object that has a delegate. +public protocol HasDelegate: AnyObject { + /// Delegate type + associatedtype Delegate: AnyObject + + /// Delegate + var delegate: Delegate? { get set } +} + +extension DelegateProxyType where ParentObject: HasDelegate, Self.Delegate == ParentObject.Delegate { + public static func currentDelegate(for object: ParentObject) -> Delegate? { + return object.delegate + } + + public static func setCurrentDelegate(_ delegate: Delegate?, to object: ParentObject) { + object.delegate = delegate + } +} + +/// Describes an object that has a data source. +public protocol HasDataSource: AnyObject { + /// Data source type + associatedtype DataSource: AnyObject + + /// Data source + var dataSource: DataSource? { get set } +} + +extension DelegateProxyType where ParentObject: HasDataSource, Self.Delegate == ParentObject.DataSource { + public static func currentDelegate(for object: ParentObject) -> Delegate? { + return object.dataSource + } + + public static func setCurrentDelegate(_ delegate: Delegate?, to object: ParentObject) { + object.dataSource = delegate } } @@ -228,17 +284,18 @@ extension DelegateProxyType { import UIKit extension ObservableType { - func subscribeProxyDataSource(ofObject object: UIView, dataSource: AnyObject, retainDataSource: Bool, binding: @escaping (P, Event) -> Void) - -> Disposable { - let proxy = P.proxyForObject(object) - let unregisterDelegate = P.installForwardDelegate(dataSource, retainDelegate: retainDataSource, onProxyForObject: object) + func subscribeProxyDataSource(ofObject object: DelegateProxy.ParentObject, dataSource: DelegateProxy.Delegate, retainDataSource: Bool, binding: @escaping (DelegateProxy, Event) -> Void) + -> Disposable + where DelegateProxy.ParentObject: UIView { + let proxy = DelegateProxy.proxy(for: object) + let unregisterDelegate = DelegateProxy.installForwardDelegate(dataSource, retainDelegate: retainDataSource, onProxyForObject: object) // this is needed to flush any delayed old state (https://github.com/RxSwiftCommunity/RxDataSources/pull/75) object.layoutIfNeeded() let subscription = self.asObservable() .observeOn(MainScheduler()) .catchError { error in - bindingErrorToInterface(error) + bindingError(error) return Observable.empty() } // source can never end, otherwise it would release the subscriber, and deallocate the data source @@ -247,14 +304,14 @@ extension DelegateProxyType { .subscribe { [weak object] (event: Event) in if let object = object { - assert(proxy === P.currentDelegateFor(object), "Proxy changed from the time it was first set.\nOriginal: \(proxy)\nExisting: \(String(describing: P.currentDelegateFor(object)))") + assert(proxy === DelegateProxy.currentDelegate(for: object), "Proxy changed from the time it was first set.\nOriginal: \(proxy)\nExisting: \(String(describing: DelegateProxy.currentDelegate(for: object)))") } binding(proxy, event) switch event { case .error(let error): - bindingErrorToInterface(error) + bindingError(error) unregisterDelegate.dispose() case .completed: unregisterDelegate.dispose() @@ -273,4 +330,66 @@ extension DelegateProxyType { #endif + /** + + To add delegate proxy subclasses call `DelegateProxySubclass.register()` in `registerKnownImplementations` or in some other + part of your app that executes before using `rx.*` (e.g. appDidFinishLaunching). + + class RxScrollViewDelegateProxy: DelegateProxy { + public static func registerKnownImplementations() { + self.register { RxTableViewDelegateProxy(parentObject: $0) } + } + ... + + + */ + private class DelegateProxyFactory { + private static var _sharedFactories: [UnsafeRawPointer: DelegateProxyFactory] = [:] + + fileprivate static func sharedFactory(for proxyType: DelegateProxy.Type) -> DelegateProxyFactory { + MainScheduler.ensureExecutingOnScheduler() + let identifier = DelegateProxy.identifier + if let factory = _sharedFactories[identifier] { + return factory + } + let factory = DelegateProxyFactory(for: proxyType) + _sharedFactories[identifier] = factory + DelegateProxy.registerKnownImplementations() + return factory + } + + private var _factories: [ObjectIdentifier: ((AnyObject) -> AnyObject)] + private var _delegateProxyType: Any.Type + private var _identifier: UnsafeRawPointer + + private init(for proxyType: DelegateProxy.Type) { + _factories = [:] + _delegateProxyType = proxyType + _identifier = proxyType.identifier + } + + fileprivate func extend(make: @escaping (ParentObject) -> DelegateProxy) + { + MainScheduler.ensureExecutingOnScheduler() + precondition(_identifier == DelegateProxy.identifier, "Delegate proxy has inconsistent identifier") + precondition((DelegateProxy.self as? DelegateProxy.Delegate) != nil, "DelegateProxy subclass should be as a Delegate") + guard _factories[ObjectIdentifier(ParentObject.self)] == nil else { + rxFatalError("The factory of \(ParentObject.self) is duplicated. DelegateProxy is not allowed of duplicated base object type.") + } + _factories[ObjectIdentifier(ParentObject.self)] = { make(castOrFatalError($0)) } + } + + fileprivate func createProxy(for object: AnyObject) -> AnyObject { + MainScheduler.ensureExecutingOnScheduler() + var maybeMirror: Mirror? = Mirror(reflecting: object) + while let mirror = maybeMirror { + if let factory = _factories[ObjectIdentifier(mirror.subjectType)] { + return factory(object) + } + maybeMirror = mirror.superclassMirror + } + rxFatalError("DelegateProxy has no factory of \(object). Implement DelegateProxy subclass for \(object) first.") + } + } + #endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift index 8dfa956e..da10474b 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift @@ -21,16 +21,16 @@ import RxSwift #if os(iOS) || os(macOS) || os(tvOS) extension Reactive where Base: NSLayoutConstraint { /// Bindable sink for `constant` property. - public var constant: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { constraint, constant in + public var constant: Binder { + return Binder(self.base) { constraint, constant in constraint.constant = constant } } /// Bindable sink for `active` property. @available(iOS 8, OSX 10.10, *) - public var active: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { constraint, value in + public var active: Binder { + return Binder(self.base) { constraint, value in constraint.isActive = value } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Deprecated.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Deprecated.swift index b4037bb3..f4d57a18 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Deprecated.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Deprecated.swift @@ -10,6 +10,8 @@ import RxSwift #endif +import Dispatch + extension ObservableType { /** @@ -238,3 +240,211 @@ extension ObservableType { } } #endif + +/** + This method can be used in unit tests to ensure that driver is using mock schedulers instead of + main schedulers. + + **This shouldn't be used in normal release builds.** + */ +@available(*, deprecated, renamed: "SharingScheduler.mock(scheduler:action:)") +public func driveOnScheduler(_ scheduler: SchedulerType, action: () -> ()) { + SharingScheduler.mock(scheduler: scheduler, action: action) +} + +extension Variable { + /// Converts `Variable` to `SharedSequence` unit. + /// + /// - returns: Observable sequence. + @available(*, deprecated, renamed: "asDriver()") + public func asSharedSequence(strategy: SharingStrategy.Type = SharingStrategy.self) -> SharedSequence { + let source = self.asObservable() + .observeOn(SharingStrategy.scheduler) + return SharedSequence(source) + } +} + +#if !os(Linux) + +extension DelegateProxy { + @available(*, unavailable, renamed: "assignedProxy(for:)") + public static func assignedProxyFor(_ object: ParentObject) -> Delegate? { + fatalError() + } + + @available(*, unavailable, renamed: "currentDelegate(for:)") + public static func currentDelegateFor(_ object: ParentObject) -> Delegate? { + fatalError() + } +} + +#endif + +/** +Observer that enforces interface binding rules: + * can't bind errors (in debug builds binding of errors causes `fatalError` in release builds errors are being logged) + * ensures binding is performed on main thread + +`UIBindingObserver` doesn't retain target interface and in case owned interface element is released, element isn't bound. + + In case event binding is attempted from non main dispatch queue, event binding will be dispatched async to main dispatch + queue. +*/ +@available(*, deprecated, renamed: "Binder") +public final class UIBindingObserver : ObserverType where UIElementType: AnyObject { + public typealias E = Value + + weak var UIElement: UIElementType? + + let binding: (UIElementType, Value) -> Void + + /// Initializes `ViewBindingObserver` using + @available(*, deprecated, renamed: "UIBinder.init(_:scheduler:binding:)") + public init(UIElement: UIElementType, binding: @escaping (UIElementType, Value) -> Void) { + self.UIElement = UIElement + self.binding = binding + } + + /// Binds next element to owner view as described in `binding`. + public func on(_ event: Event) { + if !DispatchQueue.isMain { + DispatchQueue.main.async { + self.on(event) + } + return + } + + switch event { + case .next(let element): + if let view = self.UIElement { + binding(view, element) + } + case .error(let error): + bindingError(error) + case .completed: + break + } + } + + /// Erases type of observer. + /// + /// - returns: type erased observer. + public func asObserver() -> AnyObserver { + return AnyObserver(eventHandler: on) + } +} + + +#if os(iOS) + extension Reactive where Base: UIRefreshControl { + + /// Bindable sink for `beginRefreshing()`, `endRefreshing()` methods. + @available(*, deprecated, renamed: "isRefreshing") + public var refreshing: Binder { + return self.isRefreshing + } + } +#endif + +#if os(iOS) || os(tvOS) +extension Reactive where Base: UIImageView { + + /// Bindable sink for `image` property. + /// - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) + @available(*, deprecated, renamed: "image") + public func image(transitionType: String? = nil) -> Binder { + return Binder(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 + } + } +} +#endif + +#if os(macOS) + + extension Reactive where Base: NSImageView { + + /// Bindable sink for `image` property. + /// + /// - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) + @available(*, deprecated, renamed: "image") + public func image(transitionType: String? = nil) -> Binder { + return Binder(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 + } + } + } +#endif + +#if !RX_NO_MODULE + import RxSwift +#endif + +extension Variable { + /// Converts `Variable` to `Driver` trait. + /// + /// - returns: Driving observable sequence. + public func asDriver() -> Driver { + let source = self.asObservable() + .observeOn(DriverSharingStrategy.scheduler) + return Driver(source) + } +} + + +private let errorMessage = "`drive*` family of methods can be only called from `MainThread`.\n" + +"This is required to ensure that the last replayed `Driver` element is delivered on `MainThread`.\n" + +extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingStrategy { + /** + Creates new subscription and sends elements to variable. + This method can be only called from `MainThread`. + + - parameter variable: Target variable for sequence elements. + - returns: Disposable object that can be used to unsubscribe the observer from the variable. + */ + public func drive(_ variable: Variable) -> Disposable { + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) + return drive(onNext: { e in + variable.value = e + }) + } + + /** + Creates new subscription and sends elements to variable. + This method can be only called from `MainThread`. + + - parameter variable: Target variable for sequence elements. + - returns: Disposable object that can be used to unsubscribe the observer from the variable. + */ + public func drive(_ variable: Variable) -> Disposable { + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) + return drive(onNext: { e in + variable.value = e + }) + } +} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/_RXObjCRuntime.m b/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/_RXObjCRuntime.m index bf218144..9cd58332 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/_RXObjCRuntime.m +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/_RXObjCRuntime.m @@ -77,7 +77,7 @@ { .encoding = @encode(void)}, { .encoding = @encode(id)}, { .encoding = @encode(Class)}, - { .encoding = @encode(void (^)())}, + { .encoding = @encode(void (^)(void))}, { .encoding = @encode(char)}, { .encoding = @encode(short)}, { .encoding = @encode(int)}, @@ -155,7 +155,7 @@ id __nonnull RX_extract_argument_at_index(NSInvocation * __nonnull invocation, N if (strcmp(argumentType, @encode(id)) == 0 || strcmp(argumentType, @encode(Class)) == 0 - || strcmp(argumentType, @encode(void (^)())) == 0 + || strcmp(argumentType, @encode(void (^)(void))) == 0 ) { __unsafe_unretained id argument = nil; [invocation getArgument:&argument atIndex:index]; @@ -277,7 +277,7 @@ -(void)performLocked:(void (^)(RXObjCRuntime* __nonnull))action; -(IMP __nullable)ensurePrepared:(id __nonnull)target forObserving:(SEL __nonnull)selector error:(NSErrorParam)error; -(BOOL)ensureSwizzledSelector:(SEL __nonnull)selector ofClass:(Class __nonnull)class - newImplementationGenerator:(IMP(^)())newImplementationGenerator + newImplementationGenerator:(IMP(^)(void))newImplementationGenerator replacementImplementationGenerator:(IMP (^)(IMP originalImplementation))replacementImplementationGenerator error:(NSErrorParam)error; @@ -315,7 +315,7 @@ IMP __nullable RX_ensure_observing(id __nonnull target, SEL __nonnull selector, return targetImplementation; } -IMP __nonnull RX_default_target_implementation() { +IMP __nonnull RX_default_target_implementation(void) { return _objc_msgForward; } @@ -420,7 +420,7 @@ +(void)load { #define SWIZZLE_METHOD(return_value, method_prototype, body, invoked_body, ...) \ method_prototype \ __unused SEL rxSelector = RX_selector(selector); \ - IMP (^newImplementationGenerator)() = ^() { \ + IMP (^newImplementationGenerator)(void) = ^() { \ __block IMP thisIMP = nil; \ id newImplementation = ^return_value(__unsafe_unretained id self DECLARE_ARGUMENTS(__VA_ARGS__)) { \ body(__VA_ARGS__) \ @@ -924,7 +924,7 @@ -(IMP)interceptorImplementationForSelector:(SEL)selector forClass:(Class)class { -(BOOL)ensureSwizzledSelector:(SEL __nonnull)selector ofClass:(Class __nonnull)class - newImplementationGenerator:(IMP(^)())newImplementationGenerator + newImplementationGenerator:(IMP(^)(void))newImplementationGenerator replacementImplementationGenerator:(IMP (^)(IMP originalImplementation))replacementImplementationGenerator error:(NSErrorParam)error { if ([self interceptorImplementationForSelector:selector forClass:class] != nil) { diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/include/_RXDelegateProxy.h b/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/include/_RXDelegateProxy.h index f82d6128..e1cc207d 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/include/_RXDelegateProxy.h +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/include/_RXDelegateProxy.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak, readonly) id _forwardToDelegate; --(void)_setForwardToDelegate:(id __nullable)forwardToDelegate retainDelegate:(BOOL)retainDelegate; +-(void)_setForwardToDelegate:(id __nullable)forwardToDelegate retainDelegate:(BOOL)retainDelegate NS_SWIFT_NAME(_setForwardToDelegate(_:retainDelegate:)) ; -(BOOL)hasWiredImplementationForSelector:(SEL)selector; -(BOOL)voidDelegateMethodsContain:(SEL)selector; diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/include/_RXObjCRuntime.h b/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/include/_RXObjCRuntime.h index 52fd3ee9..9824a3b4 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/include/_RXObjCRuntime.h +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Runtime/include/_RXObjCRuntime.h @@ -97,6 +97,6 @@ BOOL RX_is_method_with_description_void(struct objc_method_description method); BOOL RX_is_method_signature_void(NSMethodSignature * __nonnull methodSignature); /// Default value for `RXInterceptionObserver.targetImplementation`. -IMP __nonnull RX_default_target_implementation(); +IMP __nonnull RX_default_target_implementation(void); #endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/RxCocoa.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/RxCocoa.swift index 95e6dfa2..ffdc26ea 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/RxCocoa.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/RxCocoa.swift @@ -64,8 +64,8 @@ extension RxCocoaError { // MARK: Error binding policies -func bindingErrorToInterface(_ error: Swift.Error) { - let error = "Binding error to UI: \(error)" +func bindingError(_ error: Swift.Error) { + let error = "Binding error: \(error)" #if DEBUG rxFatalError(error) #else diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/BehaviorRelay.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/BehaviorRelay.swift new file mode 100644 index 00000000..26c51a24 --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/BehaviorRelay.swift @@ -0,0 +1,46 @@ +// +// BehaviorRelay.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 10/7/17. +// Copyright © 2017 Krunoslav Zaher. All rights reserved. +// + +#if !RX_NO_MODULE + import RxSwift +#endif + +/// BehaviorRelay is a wrapper for `BehaviorSubject`. +/// +/// Unlike `BehaviorSubject` it can't terminate with error or completed. +public final class BehaviorRelay: ObservableType { + public typealias E = Element + + private let _subject: BehaviorSubject + + // Accepts `event` and emits it to subscribers + public func accept(_ event: Element) { + _subject.onNext(event) + } + + /// Current value of behavior subject + public var value: Element { + // this try! is ok because subject can't error out or be disposed + return try! _subject.value() + } + + /// Initializes variable with initial value. + public init(value: Element) { + _subject = BehaviorSubject(value: value) + } + + /// Subscribes observer + public func subscribe(_ observer: O) -> Disposable where O.E == E { + return _subject.subscribe(observer) + } + + /// - returns: Canonical interface for push style sequence + public func asObservable() -> Observable { + return _subject.asObservable() + } +} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/ControlEvent.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/ControlEvent.swift index e8d3d7cc..d90ad42a 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/ControlEvent.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/ControlEvent.swift @@ -7,7 +7,7 @@ // #if !RX_NO_MODULE -import RxSwift + import RxSwift #endif /// Protocol that enables extension of `ControlEvent`. @@ -36,7 +36,7 @@ public protocol ControlEventType : ObservableType { **If they aren't, then using this trait communicates wrong properties and could potentially break someone's code.** **In case `events` observable sequence that is being passed into initializer doesn't satisfy all enumerated - properties, please don't use this unit.** + properties, please don't use this trait.** */ public struct ControlEvent : ControlEventType { public typealias E = PropertyType diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/ControlProperty.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/ControlProperty.swift index cdac1ab9..a42f552f 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/ControlProperty.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/ControlProperty.swift @@ -40,7 +40,7 @@ public protocol ControlPropertyType : ObservableType, ObserverType { **If they aren't, then using this trait communicates wrong properties and could potentially break someone's code.** **In case `values` observable sequence that is being passed into initializer doesn't satisfy all enumerated - properties, please don't use this unit.** + properties, please don't use this trait.** */ public struct ControlProperty : ControlPropertyType { public typealias E = PropertyType @@ -102,7 +102,7 @@ public struct ControlProperty : ControlPropertyType { public func on(_ event: Event) { switch event { case .error(let error): - bindingErrorToInterface(error) + bindingError(error) case .next: _valueSink.on(event) case .completed: diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/BehaviorRelay+Driver.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/BehaviorRelay+Driver.swift new file mode 100644 index 00000000..0f195f32 --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/BehaviorRelay+Driver.swift @@ -0,0 +1,22 @@ +// +// BehaviorRelay+Driver.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 10/7/17. +// Copyright © 2017 Krunoslav Zaher. All rights reserved. +// + +#if !RX_NO_MODULE + import RxSwift +#endif + +extension BehaviorRelay { + /// Converts `BehaviorRelay` to `Driver`. + /// + /// - returns: Observable sequence. + public func asDriver() -> Driver { + let source = self.asObservable() + .observeOn(DriverSharingStrategy.scheduler) + return SharedSequence(source) + } +} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver+Subscription.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver+Subscription.swift index 9957ce3b..9edda009 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver+Subscription.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver+Subscription.swift @@ -10,10 +10,9 @@ import RxSwift #endif -private let driverErrorMessage = "`drive*` family of methods can be only called from `MainThread`.\n" + +private let errorMessage = "`drive*` family of methods can be only called from `MainThread`.\n" + "This is required to ensure that the last replayed `Driver` element is delivered on `MainThread`.\n" -// This would ideally be Driver, but unfortunately Driver can't be extended in Swift 3.0 extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingStrategy { /** Creates new subscription and sends elements to observer. @@ -25,7 +24,7 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt - returns: Disposable object that can be used to unsubscribe the observer from the subject. */ public func drive(_ observer: O) -> Disposable where O.E == E { - MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) return self.asSharedSequence().asObservable().subscribe(observer) } @@ -39,21 +38,21 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt - returns: Disposable object that can be used to unsubscribe the observer from the subject. */ public func drive(_ observer: O) -> Disposable where O.E == E? { - MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) return self.asSharedSequence().asObservable().map { $0 as E? }.subscribe(observer) } /** - Creates new subscription and sends elements to variable. + Creates new subscription and sends elements to `BehaviorRelay`. This method can be only called from `MainThread`. - parameter variable: Target variable for sequence elements. - returns: Disposable object that can be used to unsubscribe the observer from the variable. */ - public func drive(_ variable: Variable) -> Disposable { - MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + public func drive(_ relay: BehaviorRelay) -> Disposable { + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) return drive(onNext: { e in - variable.value = e + relay.accept(e) }) } @@ -64,10 +63,10 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt - parameter variable: Target variable for sequence elements. - returns: Disposable object that can be used to unsubscribe the observer from the variable. */ - public func drive(_ variable: Variable) -> Disposable { - MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + public func drive(_ relay: BehaviorRelay) -> Disposable { + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) return drive(onNext: { e in - variable.value = e + relay.accept(e) }) } @@ -79,7 +78,7 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt - returns: Object representing subscription. */ public func drive(_ transformation: (Observable) -> R) -> R { - MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) return transformation(self.asObservable()) } @@ -98,7 +97,7 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt - returns: Object representing subscription. */ public func drive(_ with: (Observable) -> (R1) -> R2, curriedArgument: R1) -> R2 { - MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) return with(self.asObservable())(curriedArgument) } @@ -116,7 +115,7 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt - returns: Subscription object used to unsubscribe from the observable sequence. */ public func drive(onNext: ((E) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil) -> Disposable { - MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + MainScheduler.ensureExecutingOnScheduler(errorMessage: errorMessage) return self.asObservable().subscribe(onNext: onNext, onCompleted: onCompleted, onDisposed: onDisposed) } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver.swift index fa35c9d3..41780e00 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Driver.swift @@ -16,12 +16,16 @@ - it never fails - it delivers events on `MainScheduler.instance` - - `shareReplayLatestWhileConnected()` behavior + - `share(replay: 1, scope: .whileConnected)` sharing strategy + + Additional explanation: - all observers share sequence computation resources - it's stateful, upon subscription (calling subscribe) last element is immediately replayed if it was produced - computation of elements is reference counted with respect to the number of observers - if there are no subscribers, it will release sequence computation resources + In case trait that models event bus is required, please check `Signal`. + `Driver` can be considered a builder pattern for observable sequences that drive the application. If observable sequence has produced at least one element, after new subscription is made last produced element will be @@ -37,9 +41,9 @@ public typealias Driver = SharedSequence public struct DriverSharingStrategy: SharingStrategyProtocol { - public static var scheduler: SchedulerType { return driverObserveOnScheduler() } + public static var scheduler: SchedulerType { return SharingScheduler.make() } public static func share(_ source: Observable) -> Observable { - return source.shareReplayLatestWhileConnected() + return source.share(replay: 1, scope: .whileConnected) } } @@ -50,41 +54,3 @@ extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingSt } } -/** - This method can be used in unit tests to ensure that driver is using mock schedulers instead of - main schedulers. - - **This shouldn't be used in normal release builds.** -*/ -public func driveOnScheduler(_ scheduler: SchedulerType, action: () -> ()) { - let originalObserveOnScheduler = driverObserveOnScheduler - driverObserveOnScheduler = { return scheduler } - - action() - - // If you remove this line , compiler buggy optimizations will change behavior of this code - _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(scheduler) - // Scary, I know - - driverObserveOnScheduler = originalObserveOnScheduler -} - -#if os(Linux) - import Glibc -#else - import func Foundation.arc4random -#endif - -func _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(_ scheduler: SchedulerType) { - let a: Int32 = 1 -#if os(Linux) - let b = 314 + Int32(Glibc.random() & 1) -#else - let b = 314 + Int32(arc4random() & 1) -#endif - if a == b { - print(scheduler) - } -} - -fileprivate var driverObserveOnScheduler: () -> SchedulerType = { MainScheduler() } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/ObservableConvertibleType+Driver.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/ObservableConvertibleType+Driver.swift index f5e84d80..ba661025 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/ObservableConvertibleType+Driver.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/ObservableConvertibleType+Driver.swift @@ -12,10 +12,10 @@ import RxSwift extension ObservableConvertibleType { /** - Converts anything convertible to `Observable` to `Driver` unit. + Converts observable sequence to `Driver` trait. - parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence. - - returns: Driving observable sequence. + - returns: Driver trait. */ public func asDriver(onErrorJustReturn: E) -> Driver { let source = self @@ -26,10 +26,10 @@ extension ObservableConvertibleType { } /** - Converts anything convertible to `Observable` to `Driver` unit. + Converts observable sequence to `Driver` trait. - parameter onErrorDriveWith: Driver that continues to drive the sequence in case of error. - - returns: Driving observable sequence. + - returns: Driver trait. */ public func asDriver(onErrorDriveWith: Driver) -> Driver { let source = self @@ -42,10 +42,10 @@ extension ObservableConvertibleType { } /** - Converts anything convertible to `Observable` to `Driver` unit. + Converts observable sequence to `Driver` trait. - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error. - - returns: Driving observable sequence. + - returns: Driver trait. */ public func asDriver(onErrorRecover: @escaping (_ error: Swift.Error) -> Driver) -> Driver { let source = self diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Variable+Driver.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Variable+Driver.swift deleted file mode 100644 index 7f200636..00000000 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Driver/Variable+Driver.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// Variable+Driver.swift -// RxCocoa -// -// Created by Krunoslav Zaher on 12/28/15. -// Copyright © 2015 Krunoslav Zaher. All rights reserved. -// - -#if !RX_NO_MODULE - import RxSwift -#endif - -extension Variable { - /// Converts `Variable` to `Driver` unit. - /// - /// - returns: Driving observable sequence. - public func asDriver() -> Driver { - let source = self.asObservable() - .observeOn(DriverSharingStrategy.scheduler) - return Driver(source) - } -} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/PublishRelay.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/PublishRelay.swift new file mode 100644 index 00000000..82c64424 --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/PublishRelay.swift @@ -0,0 +1,40 @@ +// +// PublishRelay.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 3/28/15. +// Copyright © 2017 Krunoslav Zaher. All rights reserved. +// + +#if !RX_NO_MODULE + import RxSwift +#endif + +/// PublishRelay is a wrapper for `PublishSubject`. +/// +/// Unlike `PublishSubject` it can't terminate with error or completed. +public final class PublishRelay: ObservableType { + public typealias E = Element + + private let _subject: PublishSubject + + // Accepts `event` and emits it to subscribers + public func accept(_ event: Element) { + _subject.onNext(event) + } + + /// Initializes variable with initial value. + public init() { + _subject = PublishSubject() + } + + /// Subscribes observer + public func subscribe(_ observer: O) -> Disposable where O.E == E { + return _subject.subscribe(observer) + } + + /// - returns: Canonical interface for push style sequence + public func asObservable() -> Observable { + return _subject.asObservable() + } +} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SchedulerType+SharedSequence.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SchedulerType+SharedSequence.swift new file mode 100644 index 00000000..b55911c5 --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SchedulerType+SharedSequence.swift @@ -0,0 +1,61 @@ +// +// SchedulerType+SharedSequence.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 8/27/17. +// Copyright © 2017 Krunoslav Zaher. All rights reserved. +// + +import RxSwift + +public enum SharingScheduler { + /// Default scheduler used in SharedSequence based traits. + public private(set) static var make: () -> SchedulerType = { MainScheduler() } + + /** + This method can be used in unit tests to ensure that built in shared sequences are using mock schedulers instead + of main schedulers. + + **This shouldn't be used in normal release builds.** + */ + static public func mock(scheduler: SchedulerType, action: () -> ()) { + return mock(makeScheduler: { scheduler }, action: action) + } + + /** + This method can be used in unit tests to ensure that built in shared sequences are using mock schedulers instead + of main schedulers. + + **This shouldn't be used in normal release builds.** + */ + static public func mock(makeScheduler: @escaping () -> SchedulerType, action: () -> ()) { + let originalMake = make + make = makeScheduler + + action() + + // If you remove this line , compiler buggy optimizations will change behavior of this code + _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(makeScheduler) + // Scary, I know + + make = originalMake + } +} + +#if os(Linux) + import Glibc +#else + import func Foundation.arc4random +#endif + +func _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(_ scheduler: () -> SchedulerType) { + let a: Int32 = 1 +#if os(Linux) + let b = 314 + Int32(Glibc.random() & 1) +#else + let b = 314 + Int32(arc4random() & 1) +#endif + if a == b { + print(scheduler()) + } +} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SharedSequence+Operators.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SharedSequence+Operators.swift index 5935dac2..2930f52c 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SharedSequence+Operators.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/SharedSequence+Operators.swift @@ -44,7 +44,7 @@ extension SharedSequenceConvertibleType { } // MARK: switchLatest -extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType, E.SharingStrategy == SharingStrategy { +extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType { /** Transforms an observable sequence of observable sequences into an observable sequence @@ -55,12 +55,12 @@ extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType, - returns: The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received. */ - public func switchLatest() -> SharedSequence { + public func switchLatest() -> SharedSequence { let source: Observable = self .asObservable() .map { $0.asSharedSequence() } .switchLatest() - return SharedSequence(source) + return SharedSequence(source) } } @@ -76,12 +76,12 @@ extension SharedSequenceConvertibleType { - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source producing an Observable of Observable sequences and that at any point in time produces the elements of the most recent inner observable sequence that has been received. */ - public func flatMapLatest(_ selector: @escaping (E) -> SharedSequence) - -> SharedSequence { + public func flatMapLatest(_ selector: @escaping (E) -> SharedSequence) + -> SharedSequence { let source: Observable = self .asObservable() .flatMapLatest(selector) - return SharedSequence(source) + return SharedSequence(source) } } @@ -95,12 +95,12 @@ extension SharedSequenceConvertibleType { - parameter selector: A transform function to apply to element that was observed while no observable is executing in parallel. - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence that was received while no other sequence was being calculated. */ - public func flatMapFirst(_ selector: @escaping (E) -> SharedSequence) - -> SharedSequence { + public func flatMapFirst(_ selector: @escaping (E) -> SharedSequence) + -> SharedSequence { let source: Observable = self .asObservable() .flatMapFirst(selector) - return SharedSequence(source) + return SharedSequence(source) } } @@ -208,7 +208,7 @@ extension SharedSequenceConvertibleType { - parameter selector: A transform function to apply to each element. - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. */ - public func flatMap(_ selector: @escaping (E) -> SharedSequence) -> SharedSequence { + public func flatMap(_ selector: @escaping (E) -> SharedSequence) -> SharedSequence { let source = self.asObservable() .flatMap(selector) @@ -261,17 +261,17 @@ extension SharedSequenceConvertibleType { } // MARK: merge -extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType, E.SharingStrategy == SharingStrategy { +extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType { /** Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence. - returns: The observable sequence that merges the elements of the observable sequences. */ - public func merge() -> SharedSequence { + public func merge() -> SharedSequence { let source = self.asObservable() .map { $0.asSharedSequence() } .merge() - return SharedSequence(source) + return SharedSequence(source) } /** @@ -281,11 +281,11 @@ extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType, - returns: The observable sequence that merges the elements of the inner sequences. */ public func merge(maxConcurrent: Int) - -> SharedSequence { + -> SharedSequence { let source = self.asObservable() .map { $0.asSharedSequence() } .merge(maxConcurrent: maxConcurrent) - return SharedSequence(source) + return SharedSequence(source) } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/Variable+SharedSequence.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/Variable+SharedSequence.swift deleted file mode 100644 index 3bf580d7..00000000 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/SharedSequence/Variable+SharedSequence.swift +++ /dev/null @@ -1,22 +0,0 @@ -// -// Variable+SharedSequence.swift -// RxCocoa -// -// Created by Krunoslav Zaher on 12/28/15. -// Copyright © 2015 Krunoslav Zaher. All rights reserved. -// - -#if !RX_NO_MODULE - import RxSwift -#endif - -extension Variable { - /// Converts `Variable` to `SharedSequence` unit. - /// - /// - returns: Observable sequence. - public func asSharedSequence(strategy: SharingStrategy.Type = SharingStrategy.self) -> SharedSequence { - let source = self.asObservable() - .observeOn(SharingStrategy.scheduler) - return SharedSequence(source) - } -} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/ObservableConvertibleType+Signal.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/ObservableConvertibleType+Signal.swift new file mode 100644 index 00000000..0e0823e1 --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/ObservableConvertibleType+Signal.swift @@ -0,0 +1,60 @@ +// +// ObservableConvertibleType+Signal.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 9/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if !RX_NO_MODULE + import RxSwift +#endif + +extension ObservableConvertibleType { + /** + Converts observable sequence to `Signal` trait. + + - parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence. + - returns: Signal trait. + */ + public func asSignal(onErrorJustReturn: E) -> Signal { + let source = self + .asObservable() + .observeOn(SignalSharingStrategy.scheduler) + .catchErrorJustReturn(onErrorJustReturn) + return Signal(source) + } + + /** + Converts observable sequence to `Driver` trait. + + - parameter onErrorDriveWith: Driver that continues to drive the sequence in case of error. + - returns: Signal trait. + */ + public func asSignal(onErrorSignalWith: Signal) -> Signal { + let source = self + .asObservable() + .observeOn(SignalSharingStrategy.scheduler) + .catchError { _ in + onErrorSignalWith.asObservable() + } + return Signal(source) + } + + /** + Converts observable sequence to `Driver` trait. + + - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error. + - returns: Signal trait. + */ + public func asSignal(onErrorRecover: @escaping (_ error: Swift.Error) -> Signal) -> Signal { + let source = self + .asObservable() + .observeOn(SignalSharingStrategy.scheduler) + .catchError { error in + onErrorRecover(error).asObservable() + } + return Signal(source) + } +} + diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/PublishRelay+Signal.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/PublishRelay+Signal.swift new file mode 100644 index 00000000..a6e73dfd --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/PublishRelay+Signal.swift @@ -0,0 +1,22 @@ +// +// PublishRelay+Signal.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 12/28/15. +// Copyright © 2017 Krunoslav Zaher. All rights reserved. +// + +#if !RX_NO_MODULE + import RxSwift +#endif + +extension PublishRelay { + /// Converts `PublishRelay` to `Signal`. + /// + /// - returns: Observable sequence. + public func asSignal() -> Signal { + let source = self.asObservable() + .observeOn(SignalSharingStrategy.scheduler) + return SharedSequence(source) + } +} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal+Subscription.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal+Subscription.swift new file mode 100644 index 00000000..4946fb31 --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal+Subscription.swift @@ -0,0 +1,80 @@ +// +// Signal+Subscription.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 9/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if !RX_NO_MODULE + import RxSwift +#endif + +extension SharedSequenceConvertibleType where SharingStrategy == SignalSharingStrategy { + /** + Creates new subscription and sends elements to observer. + + In this form it's equivalent to `subscribe` method, but it communicates intent better. + + - parameter to: Observer that receives events. + - returns: Disposable object that can be used to unsubscribe the observer from the subject. + */ + public func emit(to observer: O) -> Disposable where O.E == E { + return self.asSharedSequence().asObservable().subscribe(observer) + } + + /** + Creates new subscription and sends elements to observer. + + In this form it's equivalent to `subscribe` method, but it communicates intent better. + + - parameter to: Observer that receives events. + - returns: Disposable object that can be used to unsubscribe the observer from the subject. + */ + public func emit(to observer: O) -> Disposable where O.E == E? { + return self.asSharedSequence().asObservable().map { $0 as E? }.subscribe(observer) + } + + /** + Creates new subscription and sends elements to variable. + + - parameter relay: Target relay for sequence elements. + - returns: Disposable object that can be used to unsubscribe the observer from the variable. + */ + public func emit(to relay: PublishRelay) -> Disposable { + return emit(onNext: { e in + relay.accept(e) + }) + } + + /** + Creates new subscription and sends elements to variable. + + - parameter to: Target relay for sequence elements. + - returns: Disposable object that can be used to unsubscribe the observer from the variable. + */ + public func emit(to relay: PublishRelay) -> Disposable { + return emit(onNext: { e in + relay.accept(e) + }) + } + + /** + Subscribes an element handler, a completion handler and disposed handler to an observable sequence. + + Error callback is not exposed because `Signal` can't error out. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + gracefully completed, errored, or if the generation is canceled by disposing subscription) + - parameter onDisposed: Action to invoke upon any type of termination of sequence (if the sequence has + gracefully completed, errored, or if the generation is canceled by disposing subscription) + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + public func emit(onNext: ((E) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil) -> Disposable { + return self.asObservable().subscribe(onNext: onNext, onCompleted: onCompleted, onDisposed: onDisposed) + } +} + + + diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal.swift new file mode 100644 index 00000000..0f15d3a4 --- /dev/null +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/Signal/Signal.swift @@ -0,0 +1,47 @@ +// +// Signal.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 9/26/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if !RX_NO_MODULE + import RxSwift +#endif + +/** + Trait that represents observable sequence with following properties: + + - it never fails + - it delivers events on `MainScheduler.instance` + - `share(scope: .whileConnected)` sharing strategy + + Additional explanation: + - all observers share sequence computation resources + - there is no replaying of sequence elements on new observer subscription + - computation of elements is reference counted with respect to the number of observers + - if there are no subscribers, it will release sequence computation resources + + In case trait that models state propagation is required, please check `Driver`. + + `Signal` can be considered a builder pattern for observable sequences that model imperative events part of the application. + + To find out more about units and how to use them, please visit `Documentation/Traits.md`. + */ +public typealias Signal = SharedSequence + +public struct SignalSharingStrategy : SharingStrategyProtocol { + public static var scheduler: SchedulerType { return SharingScheduler.make() } + + public static func share(_ source: Observable) -> Observable { + return source.share(scope: .whileConnected) + } +} + +extension SharedSequenceConvertibleType where SharingStrategy == SignalSharingStrategy { + /// Adds `asPublisher` to `SharingSequence` with `PublishSharingStrategy`. + public func asSignal() -> Signal { + return asSharedSequence() + } +} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/UIBindingObserver.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/UIBindingObserver.swift deleted file mode 100644 index cc711177..00000000 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/Traits/UIBindingObserver.swift +++ /dev/null @@ -1,64 +0,0 @@ -// -// UIBindingObserver.swift -// RxCocoa -// -// Created by Krunoslav Zaher on 2/7/16. -// Copyright © 2016 Krunoslav Zaher. All rights reserved. -// - -import Dispatch -#if !RX_NO_MODULE - import RxSwift -#endif - -/** -Observer that enforces interface binding rules: - * can't bind errors (in debug builds binding of errors causes `fatalError` in release builds errors are being logged) - * ensures binding is performed on main thread - -`UIBindingObserver` doesn't retain target interface and in case owned interface element is released, element isn't bound. - - In case event binding is attempted from non main dispatch queue, event binding will be dispatched async to main dispatch - queue. -*/ -public final class UIBindingObserver : ObserverType where UIElementType: AnyObject { - public typealias E = Value - - weak var UIElement: UIElementType? - - let binding: (UIElementType, Value) -> Void - - /// Initializes `ViewBindingObserver` using - public init(UIElement: UIElementType, binding: @escaping (UIElementType, Value) -> Void) { - self.UIElement = UIElement - self.binding = binding - } - - /// Binds next element to owner view as described in `binding`. - public func on(_ event: Event) { - if !DispatchQueue.isMain { - DispatchQueue.main.async { - self.on(event) - } - return - } - - switch event { - case .next(let element): - if let view = self.UIElement { - binding(view, element) - } - case .error(let error): - bindingErrorToInterface(error) - case .completed: - break - } - } - - /// Erases type of observer. - /// - /// - returns: type erased observer. - public func asObserver() -> AnyObserver { - return AnyObserver(eventHandler: on) - } -} diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift index b67a94e1..366f8e1b 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift @@ -50,7 +50,7 @@ class RxCollectionViewReactiveArrayDataSourceSequenceWrapper } func collectionView(_ collectionView: UICollectionView, observedEvent: Event) { - UIBindingObserver(UIElement: self) { collectionViewDataSource, sectionModels in + Binder(self) { collectionViewDataSource, sectionModels in let sections = Array(sectionModels) collectionViewDataSource.collectionView(collectionView, observedElements: sections) }.on(observedEvent) diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxPickerViewAdapter.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxPickerViewAdapter.swift index 97f2cdfe..39085288 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxPickerViewAdapter.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxPickerViewAdapter.swift @@ -37,7 +37,7 @@ class RxPickerViewSequenceDataSource typealias Element = S func pickerView(_ pickerView: UIPickerView, observedEvent: Event) { - UIBindingObserver(UIElement: self) { dataSource, items in + Binder(self) { dataSource, items in dataSource.items = items pickerView.reloadAllComponents() } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift index 57928287..69fb2d27 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift @@ -50,7 +50,7 @@ class RxTableViewReactiveArrayDataSourceSequenceWrapper } func tableView(_ tableView: UITableView, observedEvent: Event) { - UIBindingObserver(UIElement: self) { tableViewDataSource, sectionModels in + Binder(self) { tableViewDataSource, sectionModels in let sections = Array(sectionModels) tableViewDataSource.tableView(tableView, observedElements: sections) }.on(observedEvent) diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift index 18835d6e..b0872247 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift @@ -17,8 +17,8 @@ /// Reactive wrapper for `delegate`. /// /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxTextStorageDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxTextStorageDelegateProxy.proxy(for: base) } /// Reactive wrapper for `delegate` message. diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift index 892f7ed4..82b42fe0 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift @@ -13,6 +13,10 @@ import UIKit import RxSwift #endif +extension UICollectionView: HasDataSource { + public typealias DataSource = UICollectionViewDataSource +} + let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet() final class CollectionViewDataSourceNotSet @@ -32,28 +36,27 @@ final class CollectionViewDataSourceNotSet } /// For more information take a look at `DelegateProxyType`. -public class RxCollectionViewDataSourceProxy - : DelegateProxy - , UICollectionViewDataSource - , DelegateProxyType { - - public static var factory = DelegateProxyFactory { (parentObject: UICollectionView) in - RxCollectionViewDataSourceProxy(parentObject: parentObject) - } +open class RxCollectionViewDataSourceProxy + : DelegateProxy + , DelegateProxyType + , UICollectionViewDataSource { /// Typed parent object. public weak private(set) var collectionView: UICollectionView? - private weak var _requiredMethodsDataSource: UICollectionViewDataSource? = collectionViewDataSourceNotSet + /// - parameter collectionView: Parent object for delegate proxy. + public init(collectionView: ParentObject) { + self.collectionView = collectionView + super.init(parentObject: collectionView, delegateProxy: RxCollectionViewDataSourceProxy.self) + } - /// Initializes `RxCollectionViewDataSourceProxy` - /// - /// - parameter parentObject: Parent object for delegate proxy. - public required init(parentObject: AnyObject) { - self.collectionView = castOrFatalError(parentObject) - super.init(parentObject: parentObject) + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxCollectionViewDataSourceProxy(collectionView: $0) } } - + + private weak var _requiredMethodsDataSource: UICollectionViewDataSource? = collectionViewDataSourceNotSet + // MARK: delegate /// Required delegate method implementation. @@ -65,30 +68,10 @@ public class RxCollectionViewDataSourceProxy public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { return (_requiredMethodsDataSource ?? collectionViewDataSourceNotSet).collectionView(collectionView, cellForItemAt: indexPath) } - - // MARK: proxy - - /// For more information take a look at `DelegateProxyType`. - public override class func delegateAssociatedObjectTag() -> UnsafeRawPointer { - return dataSourceAssociatedTag - } - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let collectionView: UICollectionView = castOrFatalError(object) - collectionView.dataSource = castOptionalOrFatalError(delegate) - } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let collectionView: UICollectionView = castOrFatalError(object) - return collectionView.dataSource - } /// For more information take a look at `DelegateProxyType`. - public override func setForwardToDelegate(_ forwardToDelegate: AnyObject?, retainDelegate: Bool) { - let requiredMethodsDataSource: UICollectionViewDataSource? = castOptionalOrFatalError(forwardToDelegate) - _requiredMethodsDataSource = requiredMethodsDataSource ?? collectionViewDataSourceNotSet + open override func setForwardToDelegate(_ forwardToDelegate: UICollectionViewDataSource?, retainDelegate: Bool) { + _requiredMethodsDataSource = forwardToDelegate ?? collectionViewDataSourceNotSet super.setForwardToDelegate(forwardToDelegate, retainDelegate: retainDelegate) } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift index 27460777..4fd82f1d 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift @@ -14,7 +14,7 @@ import RxSwift #endif /// For more information take a look at `DelegateProxyType`. -public class RxCollectionViewDelegateProxy +open class RxCollectionViewDelegateProxy : RxScrollViewDelegateProxy , UICollectionViewDelegate , UICollectionViewDelegateFlowLayout { @@ -24,10 +24,10 @@ public class RxCollectionViewDelegateProxy /// Initializes `RxCollectionViewDelegateProxy` /// - /// - parameter parentObject: Parent object for delegate proxy. - public required init(parentObject: AnyObject) { - self.collectionView = castOrFatalError(parentObject) - super.init(parentObject: parentObject) + /// - parameter collectionView: Parent object for delegate proxy. + public init(collectionView: UICollectionView) { + self.collectionView = collectionView + super.init(scrollView: collectionView) } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxNavigationControllerDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxNavigationControllerDelegateProxy.swift index 8a62d04b..59940e0d 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxNavigationControllerDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxNavigationControllerDelegateProxy.swift @@ -13,33 +13,28 @@ import RxSwift #endif + extension UINavigationController: HasDelegate { + public typealias Delegate = UINavigationControllerDelegate + } + /// For more information take a look at `DelegateProxyType`. open class RxNavigationControllerDelegateProxy - : DelegateProxy - , UINavigationControllerDelegate - , DelegateProxyType { - - public static var factory = DelegateProxyFactory { (parentObject: UINavigationController) in - RxNavigationControllerDelegateProxy(parentObject: parentObject) - } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let navigationController: UINavigationController = castOrFatalError(object) - return navigationController.delegate - } - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let navigationController: UINavigationController = castOrFatalError(object) - navigationController.delegate = castOptionalOrFatalError(delegate) - } - } + : DelegateProxy + , DelegateProxyType + , UINavigationControllerDelegate { - #if os(iOS) - extension RxNavigationControllerDelegateProxy: UIImagePickerControllerDelegate { + /// Typed parent object. + public weak private(set) var navigationController: UINavigationController? + /// - parameter navigationController: Parent object for delegate proxy. + public init(navigationController: ParentObject) { + self.navigationController = navigationController + super.init(parentObject: navigationController, delegateProxy: RxNavigationControllerDelegateProxy.self) } - #endif + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxNavigationControllerDelegateProxy(navigationController: $0) } + } + } #endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDataSourceProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDataSourceProxy.swift index 66e99dc1..745a1846 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDataSourceProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDataSourceProxy.swift @@ -13,6 +13,10 @@ import RxSwift #endif +extension UIPickerView: HasDataSource { + public typealias DataSource = UIPickerViewDataSource +} + fileprivate let pickerViewDataSourceNotSet = PickerViewDataSourceNotSet() final fileprivate class PickerViewDataSourceNotSet: NSObject, UIPickerViewDataSource { @@ -27,26 +31,26 @@ final fileprivate class PickerViewDataSourceNotSet: NSObject, UIPickerViewDataSo /// For more information take a look at `DelegateProxyType`. public class RxPickerViewDataSourceProxy - : DelegateProxy - , UIPickerViewDataSource - , DelegateProxyType { - - public static var factory = DelegateProxyFactory { (parentObject: UIPickerView) in - RxPickerViewDataSourceProxy(parentObject: parentObject) - } + : DelegateProxy + , DelegateProxyType + , UIPickerViewDataSource { /// Typed parent object. - public weak fileprivate(set) var pickerView: UIPickerView? - private weak var _requiredMethodsDataSource: UIPickerViewDataSource? = pickerViewDataSourceNotSet + public weak private(set) var pickerView: UIPickerView? - /// Initializes `RxPickerViewDataSourceProxy` - /// - /// - parameter parentObject: Parent object for delegate proxy. - public required init(parentObject: AnyObject) { - self.pickerView = castOrFatalError(parentObject) - super.init(parentObject: parentObject) + /// - parameter pickerView: Parent object for delegate proxy. + public init(pickerView: ParentObject) { + self.pickerView = pickerView + super.init(parentObject: pickerView, delegateProxy: RxPickerViewDataSourceProxy.self) } + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxPickerViewDataSourceProxy(pickerView: $0) } + } + + private weak var _requiredMethodsDataSource: UIPickerViewDataSource? = pickerViewDataSourceNotSet + // MARK: UIPickerViewDataSource /// Required delegate method implementation. @@ -59,29 +63,9 @@ public class RxPickerViewDataSourceProxy return (_requiredMethodsDataSource ?? pickerViewDataSourceNotSet).pickerView(pickerView, numberOfRowsInComponent: component) } - // MARK: proxy - - /// For more information take a look at `DelegateProxyType`. - public override class func delegateAssociatedObjectTag() -> UnsafeRawPointer { - return dataSourceAssociatedTag - } - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let pickerView: UIPickerView = castOrFatalError(object) - pickerView.dataSource = castOptionalOrFatalError(delegate) - } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let pickerView: UIPickerView = castOrFatalError(object) - return pickerView.dataSource - } - /// For more information take a look at `DelegateProxyType`. - public override func setForwardToDelegate(_ forwardToDelegate: AnyObject?, retainDelegate: Bool) { - let requiredMethodsDataSource: UIPickerViewDataSource? = castOptionalOrFatalError(forwardToDelegate) - _requiredMethodsDataSource = requiredMethodsDataSource ?? pickerViewDataSourceNotSet + public override func setForwardToDelegate(_ forwardToDelegate: UIPickerViewDataSource?, retainDelegate: Bool) { + _requiredMethodsDataSource = forwardToDelegate ?? pickerViewDataSourceNotSet super.setForwardToDelegate(forwardToDelegate, retainDelegate: retainDelegate) } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift index 662a21f1..0252db13 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift @@ -13,25 +13,27 @@ #endif import UIKit - public class RxPickerViewDelegateProxy - : DelegateProxy - , DelegateProxyType + extension UIPickerView: HasDelegate { + public typealias Delegate = UIPickerViewDelegate + } + + open class RxPickerViewDelegateProxy + : DelegateProxy + , DelegateProxyType , UIPickerViewDelegate { - - public static var factory = DelegateProxyFactory { (parentObject: UIPickerView) in - RxPickerViewDelegateProxy(parentObject: parentObject) - } - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let pickerView: UIPickerView = castOrFatalError(object) - pickerView.delegate = castOptionalOrFatalError(delegate) + + /// Typed parent object. + public weak private(set) var pickerView: UIPickerView? + + /// - parameter pickerView: Parent object for delegate proxy. + public init(pickerView: ParentObject) { + self.pickerView = pickerView + super.init(parentObject: pickerView, delegateProxy: RxPickerViewDelegateProxy.self) } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let pickerView: UIPickerView = castOrFatalError(object) - return pickerView.delegate + + // Register known implementationss + public static func registerKnownImplementations() { + self.register { RxPickerViewDelegateProxy(pickerView: $0) } } } #endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift index 46006d35..f5911149 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift @@ -12,33 +12,37 @@ import RxSwift #endif import UIKit + +extension UIScrollView: HasDelegate { + public typealias Delegate = UIScrollViewDelegate +} /// For more information take a look at `DelegateProxyType`. -public class RxScrollViewDelegateProxy - : DelegateProxy - , UIScrollViewDelegate - , DelegateProxyType { - - public static var factory = DelegateProxyFactory { (parentObject: UIScrollView) in - RxScrollViewDelegateProxy(parentObject: parentObject) - } - .extended { (parentObject: UITableView) in - RxTableViewDelegateProxy(parentObject: parentObject) - } - .extended { (parentObject: UICollectionView) in - RxCollectionViewDelegateProxy(parentObject: parentObject) - } - .extended { (parentObject: UITextView) in - RxTextViewDelegateProxy(parentObject: parentObject) - } +open class RxScrollViewDelegateProxy + : DelegateProxy + , DelegateProxyType + , UIScrollViewDelegate { + + /// Typed parent object. + public weak private(set) var scrollView: UIScrollView? + /// - parameter scrollView: Parent object for delegate proxy. + public init(scrollView: ParentObject) { + self.scrollView = scrollView + super.init(parentObject: scrollView, delegateProxy: RxScrollViewDelegateProxy.self) + } + + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxScrollViewDelegateProxy(scrollView: $0) } + self.register { RxTableViewDelegateProxy(tableView: $0) } + self.register { RxCollectionViewDelegateProxy(collectionView: $0) } + self.register { RxTextViewDelegateProxy(textView: $0) } + } fileprivate var _contentOffsetBehaviorSubject: BehaviorSubject? fileprivate var _contentOffsetPublishSubject: PublishSubject<()>? - /// Typed parent object. - public weak fileprivate(set) var scrollView: UIScrollView? - /// Optimized version used for observing content offset changes. internal var contentOffsetBehaviorSubject: BehaviorSubject { if let subject = _contentOffsetBehaviorSubject { @@ -62,14 +66,6 @@ public class RxScrollViewDelegateProxy return subject } - - /// Initializes `RxScrollViewDelegateProxy` - /// - /// - parameter parentObject: Parent object for delegate proxy. - public required init(parentObject: AnyObject) { - self.scrollView = castOrFatalError(parentObject) - super.init(parentObject: parentObject) - } // MARK: delegate methods @@ -84,20 +80,6 @@ public class RxScrollViewDelegateProxy self._forwardToDelegate?.scrollViewDidScroll?(scrollView) } - // MARK: delegate proxy - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let scrollView: UIScrollView = castOrFatalError(object) - scrollView.delegate = castOptionalOrFatalError(delegate) - } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let scrollView: UIScrollView = castOrFatalError(object) - return scrollView.delegate - } - deinit { if let subject = _contentOffsetBehaviorSubject { subject.on(.completed) diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift index a68ab8f2..1c0c7f95 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift @@ -13,28 +13,28 @@ import UIKit import RxSwift #endif +extension UISearchBar: HasDelegate { + public typealias Delegate = UISearchBarDelegate +} + /// For more information take a look at `DelegateProxyType`. -public class RxSearchBarDelegateProxy - : DelegateProxy - , UISearchBarDelegate - , DelegateProxyType { +open class RxSearchBarDelegateProxy + : DelegateProxy + , DelegateProxyType + , UISearchBarDelegate { - // MARK: Delegate proxy methods + /// Typed parent object. + public weak private(set) var searchBar: UISearchBar? - public static var factory = DelegateProxyFactory { (parentObject: UISearchBar) in - RxSearchBarDelegateProxy(parentObject: parentObject) - } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let searchBar: UISearchBar = castOrFatalError(object) - return searchBar.delegate + /// - parameter searchBar: Parent object for delegate proxy. + public init(searchBar: ParentObject) { + self.searchBar = searchBar + super.init(parentObject: searchBar, delegateProxy: RxSearchBarDelegateProxy.self) } - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let searchBar: UISearchBar = castOrFatalError(object) - searchBar.delegate = castOptionalOrFatalError(delegate) + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxSearchBarDelegateProxy(searchBar: $0) } } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift index 01e1ddeb..0cb25881 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift @@ -13,29 +13,30 @@ #endif import UIKit +extension UISearchController: HasDelegate { + public typealias Delegate = UISearchControllerDelegate +} + /// For more information take a look at `DelegateProxyType`. @available(iOS 8.0, *) -public class RxSearchControllerDelegateProxy - : DelegateProxy - , DelegateProxyType +open class RxSearchControllerDelegateProxy + : DelegateProxy + , DelegateProxyType , UISearchControllerDelegate { - - public static var factory = DelegateProxyFactory { (parentObject: UISearchController) in - RxSearchControllerDelegateProxy(parentObject: parentObject) - } - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let searchController: UISearchController = castOrFatalError(object) - searchController.delegate = castOptionalOrFatalError(delegate) + + /// Typed parent object. + public weak private(set) var searchController: UISearchController? + + /// - parameter searchController: Parent object for delegate proxy. + public init(searchController: UISearchController) { + self.searchController = searchController + super.init(parentObject: searchController, delegateProxy: RxSearchControllerDelegateProxy.self) } - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let searchController: UISearchController = castOrFatalError(object) - return searchController.delegate + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxSearchControllerDelegateProxy(searchController: $0) } } - } #endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarControllerDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarControllerDelegateProxy.swift index 09e01e1a..232ab6a8 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarControllerDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarControllerDelegateProxy.swift @@ -13,26 +13,28 @@ import UIKit import RxSwift #endif +extension UITabBarController: HasDelegate { + public typealias Delegate = UITabBarControllerDelegate +} + /// For more information take a look at `DelegateProxyType`. -public class RxTabBarControllerDelegateProxy - : DelegateProxy - , UITabBarControllerDelegate - , DelegateProxyType { - - public static var factory = DelegateProxyFactory { (parentObject: UITabBarController) in - RxTabBarControllerDelegateProxy(parentObject: parentObject) - } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let tabBarController: UITabBarController = castOrFatalError(object) - return tabBarController.delegate +open class RxTabBarControllerDelegateProxy + : DelegateProxy + , DelegateProxyType + , UITabBarControllerDelegate { + + /// Typed parent object. + public weak private(set) var tabBar: UITabBarController? + + /// - parameter tabBar: Parent object for delegate proxy. + public init(tabBar: ParentObject) { + self.tabBar = tabBar + super.init(parentObject: tabBar, delegateProxy: RxTabBarControllerDelegateProxy.self) } - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let tabBarController: UITabBarController = castOrFatalError(object) - tabBarController.delegate = castOptionalOrFatalError(delegate) + + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxTabBarControllerDelegateProxy(tabBar: $0) } } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift index 247e1098..2b0593e0 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift @@ -13,26 +13,38 @@ import UIKit import RxSwift #endif +extension UITabBar: HasDelegate { + public typealias Delegate = UITabBarDelegate +} + /// For more information take a look at `DelegateProxyType`. -public class RxTabBarDelegateProxy - : DelegateProxy - , UITabBarDelegate - , DelegateProxyType { - - public static var factory = DelegateProxyFactory { (parentObject: UITabBar) in - RxTabBarDelegateProxy(parentObject: parentObject) +open class RxTabBarDelegateProxy + : DelegateProxy + , DelegateProxyType + , UITabBarDelegate { + + /// Typed parent object. + public weak private(set) var tabBar: UITabBar? + + /// - parameter tabBar: Parent object for delegate proxy. + public init(tabBar: ParentObject) { + self.tabBar = tabBar + super.init(parentObject: tabBar, delegateProxy: RxTabBarDelegateProxy.self) + } + + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxTabBarDelegateProxy(tabBar: $0) } } /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let tabBar: UITabBar = castOrFatalError(object) - return tabBar.delegate + open class func currentDelegate(for object: ParentObject) -> UITabBarDelegate? { + return object.delegate } /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let tabBar: UITabBar = castOrFatalError(object) - tabBar.delegate = castOptionalOrFatalError(delegate) + open class func setCurrentDelegate(_ delegate: UITabBarDelegate?, to object: ParentObject) { + object.delegate = delegate } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift index 271e11f5..144d8c63 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift @@ -12,6 +12,10 @@ import UIKit #if !RX_NO_MODULE import RxSwift #endif + +extension UITableView: HasDataSource { + public typealias DataSource = UITableViewDataSource +} let tableViewDataSourceNotSet = TableViewDataSourceNotSet() @@ -29,28 +33,27 @@ final class TableViewDataSourceNotSet } /// For more information take a look at `DelegateProxyType`. -public class RxTableViewDataSourceProxy - : DelegateProxy - , UITableViewDataSource - , DelegateProxyType { - - public static var factory = DelegateProxyFactory { (parentObject: UITableView) in - RxTableViewDataSourceProxy(parentObject: parentObject) - } +open class RxTableViewDataSourceProxy + : DelegateProxy + , DelegateProxyType + , UITableViewDataSource { /// Typed parent object. - public weak fileprivate(set) var tableView: UITableView? + public weak private(set) var tableView: UITableView? - fileprivate weak var _requiredMethodsDataSource: UITableViewDataSource? = tableViewDataSourceNotSet + /// - parameter tableView: Parent object for delegate proxy. + public init(tableView: UITableView) { + self.tableView = tableView + super.init(parentObject: tableView, delegateProxy: RxTableViewDataSourceProxy.self) + } - /// Initializes `RxTableViewDataSourceProxy` - /// - /// - parameter parentObject: Parent object for delegate proxy. - public required init(parentObject: AnyObject) { - self.tableView = castOrFatalError(parentObject) - super.init(parentObject: parentObject) + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxTableViewDataSourceProxy(tableView: $0) } } + fileprivate weak var _requiredMethodsDataSource: UITableViewDataSource? = tableViewDataSourceNotSet + // MARK: delegate /// Required delegate method implementation. @@ -62,30 +65,10 @@ public class RxTableViewDataSourceProxy public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { return (_requiredMethodsDataSource ?? tableViewDataSourceNotSet).tableView(tableView, cellForRowAt: indexPath) } - - // MARK: proxy - - /// For more information take a look at `DelegateProxyType`. - public override class func delegateAssociatedObjectTag() -> UnsafeRawPointer { - return dataSourceAssociatedTag - } - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let tableView: UITableView = castOrFatalError(object) - tableView.dataSource = castOptionalOrFatalError(delegate) - } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let tableView: UITableView = castOrFatalError(object) - return tableView.dataSource - } /// For more information take a look at `DelegateProxyType`. - public override func setForwardToDelegate(_ forwardToDelegate: AnyObject?, retainDelegate: Bool) { - let requiredMethodsDataSource: UITableViewDataSource? = castOptionalOrFatalError(forwardToDelegate) - _requiredMethodsDataSource = requiredMethodsDataSource ?? tableViewDataSourceNotSet + open override func setForwardToDelegate(_ forwardToDelegate: UITableViewDataSource?, retainDelegate: Bool) { + _requiredMethodsDataSource = forwardToDelegate ?? tableViewDataSourceNotSet super.setForwardToDelegate(forwardToDelegate, retainDelegate: retainDelegate) } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift index 59474728..d32a4a2f 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift @@ -14,20 +14,17 @@ import RxSwift #endif /// For more information take a look at `DelegateProxyType`. -public class RxTableViewDelegateProxy +open class RxTableViewDelegateProxy : RxScrollViewDelegateProxy , UITableViewDelegate { - /// Typed parent object. public weak private(set) var tableView: UITableView? - /// Initializes `RxTableViewDelegateProxy` - /// - /// - parameter parentObject: Parent object for delegate proxy. - public required init(parentObject: AnyObject) { - self.tableView = castOrFatalError(parentObject) - super.init(parentObject: parentObject) + /// - parameter tableView: Parent object for delegate proxy. + public init(tableView: UITableView) { + self.tableView = tableView + super.init(scrollView: tableView) } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift index 4c87b8c5..63194eea 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift @@ -12,26 +12,28 @@ import RxSwift #endif import UIKit - - public class RxTextStorageDelegateProxy - : DelegateProxy - , DelegateProxyType + + extension NSTextStorage: HasDelegate { + public typealias Delegate = NSTextStorageDelegate + } + + open class RxTextStorageDelegateProxy + : DelegateProxy + , DelegateProxyType , NSTextStorageDelegate { - - public static var factory = DelegateProxyFactory { (parentObject: NSTextStorage) in - RxTextStorageDelegateProxy(parentObject: parentObject) - } - - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let textStorage: NSTextStorage = castOrFatalError(object) - textStorage.delegate = castOptionalOrFatalError(delegate) + + /// Typed parent object. + public weak private(set) var textStorage: NSTextStorage? + + /// - parameter textStorage: Parent object for delegate proxy. + public init(textStorage: NSTextStorage) { + self.textStorage = textStorage + super.init(parentObject: textStorage, delegateProxy: RxTextStorageDelegateProxy.self) } - - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let textStorage: NSTextStorage = castOrFatalError(object) - return textStorage.delegate + + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxTextStorageDelegateProxy(textStorage: $0) } } } #endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift index ef8503f1..42f2d236 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift @@ -14,25 +14,23 @@ import RxSwift #endif /// For more information take a look at `DelegateProxyType`. -public class RxTextViewDelegateProxy +open class RxTextViewDelegateProxy : RxScrollViewDelegateProxy , UITextViewDelegate { /// Typed parent object. public weak private(set) var textView: UITextView? - /// Initializes `RxTextViewDelegateProxy` - /// - /// - parameter parentObject: Parent object for delegate proxy. - public required init(parentObject: AnyObject) { - self.textView = castOrFatalError(parentObject) - super.init(parentObject: parentObject) + /// - parameter textview: Parent object for delegate proxy. + public init(textView: UITextView) { + self.textView = textView + super.init(scrollView: textView) } // MARK: delegate methods /// For more information take a look at `DelegateProxyType`. - @objc public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { + @objc open func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { /** We've had some issues with observing text changes. This is here just in case we need the same hack in future and that we wouldn't need to change the public interface. diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxWebViewDelegateProxy.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxWebViewDelegateProxy.swift index 84c4a5fb..df410119 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxWebViewDelegateProxy.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxWebViewDelegateProxy.swift @@ -13,25 +13,27 @@ import UIKit import RxSwift #endif -public class RxWebViewDelegateProxy - : DelegateProxy - , DelegateProxyType +extension UIWebView: HasDelegate { + public typealias Delegate = UIWebViewDelegate +} + +open class RxWebViewDelegateProxy + : DelegateProxy + , DelegateProxyType , UIWebViewDelegate { - - public static var factory = DelegateProxyFactory { (parentObject: UIWebView) in - RxWebViewDelegateProxy(parentObject: parentObject) - } - /// For more information take a look at `DelegateProxyType`. - public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { - let webView: UIWebView = castOrFatalError(object) - webView.delegate = castOptionalOrFatalError(delegate) + /// Typed parent object. + public weak private(set) var webView: UIWebView? + + /// - parameter webView: Parent object for delegate proxy. + public init(webView: ParentObject) { + self.webView = webView + super.init(parentObject: webView, delegateProxy: RxWebViewDelegateProxy.self) } - /// For more information take a look at `DelegateProxyType`. - public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { - let webView: UIWebView = castOrFatalError(object) - return webView.delegate + // Register known implementations + public static func registerKnownImplementations() { + self.register { RxWebViewDelegateProxy(webView: $0) } } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift index 03f01685..7b11d282 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift @@ -16,8 +16,8 @@ import RxSwift extension Reactive where Base: UIActivityIndicatorView { /// Bindable sink for `startAnimating()`, `stopAnimating()` methods. - public var isAnimating: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { activityIndicator, active in + public var isAnimating: Binder { + return Binder(self.base) { activityIndicator, active in if active { activityIndicator.startAnimating() } else { diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift index 23ffd26b..d622f84d 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift @@ -17,8 +17,8 @@ import RxSwift extension Reactive where Base: UIAlertAction { /// Bindable sink for `enabled` property. - public var isEnabled: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { alertAction, value in + public var isEnabled: Binder { + return Binder(self.base) { alertAction, value in alertAction.isEnabled = value } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift index 9c643894..24d9b29c 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift @@ -16,8 +16,8 @@ extension Reactive where Base: UIApplication { /// Bindable sink for `networkActivityIndicatorVisible`. - public var isNetworkActivityIndicatorVisible: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { application, active in + public var isNetworkActivityIndicatorVisible: Binder { + return Binder(self.base) { application, active in application.isNetworkActivityIndicatorVisible = active } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIBarButtonItem+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIBarButtonItem+Rx.swift index 18beee7e..c2c1783b 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIBarButtonItem+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIBarButtonItem+Rx.swift @@ -18,21 +18,21 @@ fileprivate var rx_tap_key: UInt8 = 0 extension Reactive where Base: UIBarButtonItem { /// Bindable sink for `enabled` property. - public var isEnabled: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { UIElement, value in - UIElement.isEnabled = value + public var isEnabled: Binder { + return Binder(self.base) { element, value in + element.isEnabled = value } } /// Bindable sink for `title` property. - public var title: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { UIElement, value in - UIElement.title = value + public var title: Binder { + return Binder(self.base) { element, value in + element.title = value } } /// Reactive wrapper for target action pattern on `self`. - public var tap: ControlEvent { + public var tap: ControlEvent<()> { let source = lazyInstanceObservable(&rx_tap_key) { () -> Observable in Observable.create { [weak control = self.base] observer in guard let control = control else { diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift index e465d400..a2a7187c 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift @@ -51,22 +51,22 @@ extension Reactive where Base: UIButton { extension Reactive where Base: UIButton { /// Reactive wrapper for `setTitle(_:for:)` - public func title(for controlState: UIControlState = []) -> UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { (button, title) -> () in + public func title(for controlState: UIControlState = []) -> Binder { + return Binder(self.base) { (button, title) -> () in button.setTitle(title, for: controlState) } } /// Reactive wrapper for `setImage(_:for:)` - public func image(for controlState: UIControlState = []) -> UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { (button, image) -> () in + public func image(for controlState: UIControlState = []) -> Binder { + return Binder(self.base) { (button, image) -> () in button.setImage(image, for: controlState) } } /// Reactive wrapper for `setBackgroundImage(_:for:)` - public func backgroundImage(for controlState: UIControlState = []) -> UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { (button, image) -> () in + public func backgroundImage(for controlState: UIControlState = []) -> Binder { + return Binder(self.base) { (button, image) -> () in button.setBackgroundImage(image, for: controlState) } } @@ -84,8 +84,8 @@ extension Reactive where Base: UIButton { extension Reactive where Base: UIButton { /// Reactive wrapper for `setAttributedTitle(_:controlState:)` - public func attributedTitle(for controlState: UIControlState = []) -> UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { (button, attributedTitle) -> () in + public func attributedTitle(for controlState: UIControlState = []) -> Binder { + return Binder(self.base) { (button, attributedTitle) -> () in button.setAttributedTitle(attributedTitle, for: controlState) } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UICollectionView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UICollectionView+Rx.swift index 2611c096..d53db252 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UICollectionView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UICollectionView+Rx.swift @@ -167,8 +167,8 @@ extension Reactive where Base: UICollectionView { /// Reactive wrapper for `dataSource`. /// /// For more information take a look at `DelegateProxyType` protocol documentation. - public var dataSource: DelegateProxy { - return RxCollectionViewDataSourceProxy.proxyForObject(base) + public var dataSource: DelegateProxy { + return RxCollectionViewDataSourceProxy.proxy(for: base) } /// Installs data source as forwarding delegate on `rx.dataSource`. diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift index 90ea45d0..e5bced14 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift @@ -16,15 +16,15 @@ import UIKit extension Reactive where Base: UIControl { /// Bindable sink for `enabled` property. - public var isEnabled: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { control, value in + public var isEnabled: Binder { + return Binder(self.base) { control, value in control.isEnabled = value } } /// Bindable sink for `selected` property. - public var isSelected: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { control, selected in + public var isSelected: Binder { + return Binder(self.base) { control, selected in control.isSelected = selected } } @@ -95,7 +95,7 @@ extension Reactive where Base: UIControl { } .takeUntil((control as NSObject).rx.deallocated) - let bindingObserver = UIBindingObserver(UIElement: control, binding: setter) + let bindingObserver = Binder(control, binding: setter) return ControlProperty(values: source, valueSink: bindingObserver) } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift index e9f26abd..bc86849d 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift @@ -16,27 +16,8 @@ import UIKit extension Reactive where Base: UIImageView { /// Bindable sink for `image` property. - public var image: UIBindingObserver { - return image(transitionType: nil) - } - - /// Bindable sink for `image` property. - - /// - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) - public func image(transitionType: String? = nil) -> 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() - } + public var image: Binder { + return Binder(base) { imageView, image in imageView.image = image } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift index 879f4646..fedc73c6 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift @@ -16,15 +16,15 @@ import UIKit extension Reactive where Base: UILabel { /// Bindable sink for `text` property. - public var text: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { label, text in + public var text: Binder { + return Binder(self.base) { label, text in label.text = text } } /// Bindable sink for `attributedText` property. - public var attributedText: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { label, text in + public var attributedText: Binder { + return Binder(self.base) { label, text in label.attributedText = text } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UINavigationController+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UINavigationController+Rx.swift index 1795e75b..a3c27b2c 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UINavigationController+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UINavigationController+Rx.swift @@ -19,8 +19,8 @@ extension Reactive where Base: UINavigationController { /// Reactive wrapper for `delegate`. /// /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxNavigationControllerDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxNavigationControllerDelegateProxy.proxy(for: base) } /// Reactive wrapper for delegate method `navigationController(:willShow:animated:)`. diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift index f18342bf..1c9e0a72 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift @@ -16,8 +16,8 @@ import RxSwift extension Reactive where Base: UINavigationItem { /// Bindable sink for `title` property. - public var title: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { navigationItem, text in + public var title: Binder { + return Binder(self.base) { navigationItem, text in navigationItem.title = text } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift index ad7f496c..88713d67 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift @@ -16,15 +16,15 @@ import UIKit extension Reactive where Base: UIPageControl { /// Bindable sink for `currentPage` property. - public var currentPage: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { controller, page in + public var currentPage: Binder { + return Binder(self.base) { controller, page in controller.currentPage = page } } /// Bindable sink for `numberOfPages` property. - public var numberOfPages: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { controller, page in + public var numberOfPages: Binder { + return Binder(self.base) { controller, page in controller.numberOfPages = page } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift index cd8e285c..0b18708b 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift @@ -17,8 +17,8 @@ /// Reactive wrapper for `delegate`. /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxPickerViewDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxPickerViewDelegateProxy.proxy(for: base) } /// Installs delegate as forwarding delegate on `delegate`. @@ -38,8 +38,8 @@ For more information take a look at `DelegateProxyType` protocol documentation. */ - public var dataSource: DelegateProxy { - return RxPickerViewDataSourceProxy.proxyForObject(base) + public var dataSource: DelegateProxy { + return RxPickerViewDataSourceProxy.proxy(for: base) } /** diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift index a2ecd3c6..e683a365 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift @@ -16,8 +16,8 @@ import UIKit extension Reactive where Base: UIProgressView { /// Bindable sink for `progress` property - public var progress: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { progressView, progress in + public var progress: Binder { + return Binder(self.base) { progressView, progress in progressView.progress = progress } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift index 9a38cb93..935a3b57 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift @@ -14,16 +14,9 @@ import RxSwift #endif extension Reactive where Base: UIRefreshControl { - - /// Bindable sink for `beginRefreshing()`, `endRefreshing()` methods. - @available(*, deprecated, renamed: "isRefreshing") - public var refreshing: UIBindingObserver { - return self.isRefreshing - } - /// Bindable sink for `beginRefreshing()`, `endRefreshing()` methods. - public var isRefreshing: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { refreshControl, refresh in + public var isRefreshing: Binder { + return Binder(self.base) { refreshControl, refresh in if refresh { refreshControl.beginRefreshing() } else { diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift index 66a90317..83ba7301 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift @@ -21,15 +21,15 @@ /// Reactive wrapper for `delegate`. /// /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxScrollViewDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxScrollViewDelegateProxy.proxy(for: base) } /// Reactive wrapper for `contentOffset`. public var contentOffset: ControlProperty { - let proxy = RxScrollViewDelegateProxy.proxyForObject(base) + let proxy = RxScrollViewDelegateProxy.proxy(for: base) - let bindingObserver = UIBindingObserver(UIElement: self.base) { scrollView, contentOffset in + let bindingObserver = Binder(self.base) { scrollView, contentOffset in scrollView.contentOffset = contentOffset } @@ -37,15 +37,15 @@ } /// Bindable sink for `scrollEnabled` property. - public var isScrollEnabled: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { scrollView, scrollEnabled in + public var isScrollEnabled: Binder { + return Binder(self.base) { scrollView, scrollEnabled in scrollView.isScrollEnabled = scrollEnabled } } /// Reactive wrapper for delegate method `scrollViewDidScroll` public var didScroll: ControlEvent { - let source = RxScrollViewDelegateProxy.proxyForObject(base).contentOffsetPublishSubject + let source = RxScrollViewDelegateProxy.proxy(for: base).contentOffsetPublishSubject return ControlEvent(events: source) } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift index c472782e..6884bb2e 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift @@ -18,8 +18,8 @@ extension Reactive where Base: UISearchBar { /// Reactive wrapper for `delegate`. /// /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxSearchBarDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxSearchBarDelegateProxy.proxy(for: base) } /// Reactive wrapper for `text` property. @@ -39,7 +39,7 @@ extension Reactive where Base: UISearchBar { .startWith(text) } - let bindingObserver = UIBindingObserver(UIElement: self.base) { (searchBar, text: String?) in + let bindingObserver = Binder(self.base) { (searchBar, text: String?) in searchBar.text = text } @@ -58,7 +58,7 @@ extension Reactive where Base: UISearchBar { .startWith(index) } - let bindingObserver = UIBindingObserver(UIElement: self.base) { (searchBar, index: Int) in + let bindingObserver = Binder(self.base) { (searchBar, index: Int) in searchBar.selectedScopeButtonIndex = index } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift index 9c58cba8..7c35d2f1 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift @@ -17,8 +17,8 @@ extension Reactive where Base: UISearchController { /// Reactive wrapper for `delegate`. /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxSearchControllerDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxSearchControllerDelegateProxy.proxy(for: base) } /// Reactive wrapper for `delegate` message. diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift index a4ea8e38..f769b57f 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift @@ -75,8 +75,8 @@ extension Reactive where Base: UITabBar { /// Reactive wrapper for `delegate`. /// /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxTabBarDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxTabBarDelegateProxy.proxy(for: base) } /// Reactive wrapper for `delegate` message `tabBar(_:didSelect:)`. diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBarController+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBarController+Rx.swift index 47aacecd..6b7fda27 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBarController+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBarController+Rx.swift @@ -58,13 +58,13 @@ extension Reactive where Base: UITabBarController { /** iOS and tvOS */ - -extension Reactive where Base: UITabBarController { + + extension Reactive where Base: UITabBarController { /// Reactive wrapper for `delegate`. /// /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxTabBarControllerDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxTabBarControllerDelegateProxy.proxy(for: base) } /// Reactive wrapper for `delegate` message `tabBarController:didSelect:`. diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift index 0e6ee972..0ed66f64 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift @@ -16,8 +16,8 @@ extension Reactive where Base: UITabBarItem { /// Bindable sink for `badgeValue` property. - public var badgeValue: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { tabBarItem, badgeValue in + public var badgeValue: Binder { + return Binder(self.base) { tabBarItem, badgeValue in tabBarItem.badgeValue = badgeValue } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift index bcd35d75..a2f5487d 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift @@ -154,7 +154,7 @@ extension Reactive where Base: UITableView { // Therefore it's better to set delegate proxy first, just to be sure. _ = self.delegate // Strong reference is needed because data source is in use until result subscription is disposed - return source.subscribeProxyDataSource(ofObject: self.base, dataSource: dataSource, retainDataSource: true) { [weak tableView = self.base] (_: RxTableViewDataSourceProxy, event) -> Void in + return source.subscribeProxyDataSource(ofObject: self.base, dataSource: dataSource as UITableViewDataSource, retainDataSource: true) { [weak tableView = self.base] (_: RxTableViewDataSourceProxy, event) -> Void in guard let tableView = tableView else { return } @@ -171,8 +171,8 @@ extension Reactive where Base: UITableView { For more information take a look at `DelegateProxyType` protocol documentation. */ - public var dataSource: DelegateProxy { - return RxTableViewDataSourceProxy.proxyForObject(base) + public var dataSource: DelegateProxy { + return RxTableViewDataSourceProxy.proxy(for: base) } /** diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift index f4cae79a..186dd766 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift @@ -36,6 +36,23 @@ extension Reactive where Base: UITextField { ) } + /// Bindable sink for `attributedText` property. + public var attributedText: ControlProperty { + return UIControl.rx.value( + base, + getter: { textField in + textField.attributedText + }, setter: { textField, value in + // This check is important because setting text value always clears control state + // including marked text selection which is imporant for proper input + // when IME input method is used. + if textField.attributedText != value { + textField.attributedText = value + } + } + ) + } + } #endif diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift index aba4f019..4cc48a46 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift @@ -13,8 +13,6 @@ import UIKit import RxSwift #endif - - extension Reactive where Base: UITextView { /// Reactive wrapper for `text` property public var text: ControlProperty { @@ -44,7 +42,7 @@ extension Reactive where Base: UITextView { .startWith(text) } - let bindingObserver = UIBindingObserver(UIElement: self.base) { (textView, text: String?) in + let bindingObserver = Binder(self.base) { (textView, text: String?) in // This check is important because setting text value always clears control state // including marked text selection which is imporant for proper input // when IME input method is used. @@ -55,6 +53,42 @@ extension Reactive where Base: UITextView { return ControlProperty(values: source, valueSink: bindingObserver) } + + + /// Reactive wrapper for `attributedText` property. + public var attributedText: ControlProperty { + let source: Observable = Observable.deferred { [weak textView = self.base] in + let attributedText = textView?.attributedText + + let textChanged: Observable = textView?.textStorage + // This project uses text storage notifications because + // that's the only way to catch autocorrect changes + // in all cases. Other suggestions are welcome. + .rx.didProcessEditingRangeChangeInLength + // This observe on is here because attributedText storage + // will emit event while process is not completely done, + // so rebinding a value will cause an exception to be thrown. + .observeOn(MainScheduler.asyncInstance) + .map { _ in + return textView?.attributedText + } + ?? Observable.empty() + + return textChanged + .startWith(attributedText) + } + + let bindingObserver = Binder(self.base) { (textView, attributedText: NSAttributedString?) in + // This check is important because setting text value always clears control state + // including marked text selection which is imporant for proper input + // when IME input method is used. + if textView.attributedText != attributedText { + textView.attributedText = attributedText + } + } + + return ControlProperty(values: source, valueSink: bindingObserver) + } /// Reactive wrapper for `delegate` message. public var didBeginEditing: ControlEvent<()> { diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift index efa55550..ec1dd2b3 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift @@ -15,22 +15,22 @@ import RxSwift extension Reactive where Base: UIView { /// Bindable sink for `hidden` property. - public var isHidden: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { view, hidden in + public var isHidden: Binder { + return Binder(self.base) { view, hidden in view.isHidden = hidden } } /// Bindable sink for `alpha` property. - public var alpha: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { view, alpha in + public var alpha: Binder { + return Binder(self.base) { view, alpha in view.alpha = alpha } } /// Bindable sink for `isUserInteractionEnabled` property. - public var isUserInteractionEnabled: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { view, userInteractionEnabled in + public var isUserInteractionEnabled: Binder { + return Binder(self.base) { view, userInteractionEnabled in view.isUserInteractionEnabled = userInteractionEnabled } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift index 026edfba..a846c579 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift @@ -16,8 +16,8 @@ extension Reactive where Base: UIViewController { /// Bindable sink for `title`. - public var title: UIBindingObserver { - return UIBindingObserver(UIElement: self.base) { viewController, title in + public var title: Binder { + return Binder(self.base) { viewController, title in viewController.title = title } } diff --git a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIWebView+Rx.swift b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIWebView+Rx.swift index 2014272e..ef0c0d90 100644 --- a/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIWebView+Rx.swift +++ b/RxAlamofire/Pods/RxCocoa/RxCocoa/iOS/UIWebView+Rx.swift @@ -18,8 +18,8 @@ import RxSwift /// Reactive wrapper for `delegate`. /// For more information take a look at `DelegateProxyType` protocol documentation. - public var delegate: DelegateProxy { - return RxWebViewDelegateProxy.proxyForObject(base) + public var delegate: DelegateProxy { + return RxWebViewDelegateProxy.proxy(for: base) } /// Reactive wrapper for `delegate` message. diff --git a/RxAlamofire/Pods/RxSwift/README.md b/RxAlamofire/Pods/RxSwift/README.md index bdf8a2ba..503068d2 100644 --- a/RxAlamofire/Pods/RxSwift/README.md +++ b/RxAlamofire/Pods/RxSwift/README.md @@ -3,6 +3,9 @@ [![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) +* RxSwift 4.x / Swift 4.x can be found in [**rxswift4.0-swift4.0** branch](https://github.com/ReactiveX/RxSwift/tree/rxswift4.0-swift4.0). +* RxSwift 3.x / Swift 3.x can be found in [**master** branch](https://github.com/ReactiveX/RxSwift/tree/master). + Rx is a [generic abstraction of computation](https://youtu.be/looJcaeboBY) expressed through `Observable` interface. This is a Swift version of [Rx](https://github.com/Reactive-Extensions/Rx.NET). diff --git a/RxAlamofire/Pods/RxSwift/RxSwift/Deprecated.swift b/RxAlamofire/Pods/RxSwift/RxSwift/Deprecated.swift index 08a119c8..0422c163 100644 --- a/RxAlamofire/Pods/RxSwift/RxSwift/Deprecated.swift +++ b/RxAlamofire/Pods/RxSwift/RxSwift/Deprecated.swift @@ -38,15 +38,14 @@ extension Observable { extension ObservableType { /** - ** @available(*, deprecated, message: "Please use enumerated().map()", renamed: "enumerated().map()") ** - - Projects each element of an observable sequence into a new form by incorporating the element's index. + Projects each element of an observable sequence into a new form by incorporating the element's index. - seealso: [map operator on reactivex.io](http://reactivex.io/documentation/operators/map.html) - parameter selector: A transform function to apply to each source element; the second parameter of the function represents the index of the source element. - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source. */ + @available(*, deprecated, message: "Please use enumerated().map()") public func mapWithIndex(_ selector: @escaping (E, Int) throws -> R) -> Observable { return enumerated().map { try selector($0.element, $0.index) } @@ -55,8 +54,6 @@ extension ObservableType { /** - ** @available(*, deprecated, message: "Please use enumerated().flatMap()", renamed: "enumerated().flatMap()") ** - Projects each element of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence. - seealso: [flatMap operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) @@ -64,6 +61,7 @@ extension ObservableType { - parameter selector: A transform function to apply to each element; the second parameter of the function represents the index of the source element. - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. */ + @available(*, deprecated, message: "Please use enumerated().flatMap()") public func flatMapWithIndex(_ selector: @escaping (E, Int) throws -> O) -> Observable { return enumerated().flatMap { try selector($0.element, $0.index) } @@ -71,8 +69,6 @@ extension ObservableType { /** - ** @available(*, deprecated, message: "Please use enumerated().skipWhile().map()", renamed: "enumerated().skipWhile().map()") ** - Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function. @@ -81,15 +77,14 @@ extension ObservableType { - parameter predicate: A function to test each element for a condition; the second parameter of the function represents the index of the source element. - returns: An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. */ + @available(*, deprecated, message: "Please use enumerated().skipWhile().map()") public func skipWhileWithIndex(_ predicate: @escaping (E, Int) throws -> Bool) -> Observable { return enumerated().skipWhile { try predicate($0.element, $0.index) }.map { $0.element } } /** - - ** @available(*, deprecated, message: "Please use enumerated().takeWhile().map()", renamed: "enumerated().takeWhile().map()") ** - + Returns elements from an observable sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function. @@ -99,6 +94,7 @@ extension ObservableType { - parameter predicate: A function to test each element for a condition; the second parameter of the function represents the index of the source element. - returns: An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. */ + @available(*, deprecated, message: "Please use enumerated().takeWhile().map()") public func takeWhileWithIndex(_ predicate: @escaping (E, Int) throws -> Bool) -> Observable { return enumerated().takeWhile { try predicate($0.element, $0.index) }.map { $0.element } } @@ -107,12 +103,111 @@ extension ObservableType { extension Disposable { /// Deprecated in favor of `disposed(by:)` /// - /// **@available(\*, deprecated, message="use disposed(by:) instead")** /// /// Adds `self` to `bag`. /// /// - parameter bag: `DisposeBag` to add `self` to. + @available(*, deprecated, message: "use disposed(by:) instead", renamed: "disposed(by:)") public func addDisposableTo(_ bag: DisposeBag) { disposed(by: bag) } } + + +extension ObservableType { + + /** + Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays latest element in buffer. + + This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + + - seealso: [shareReplay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + @available(*, deprecated, message: "use share(replay: 1) instead", renamed: "share(replay:)") + public func shareReplayLatestWhileConnected() + -> Observable { + return share(replay: 1, scope: .whileConnected) + } +} + + +extension ObservableType { + + /** + Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays maximum number of elements in buffer. + + This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + + - seealso: [shareReplay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - parameter bufferSize: Maximum element count of the replay buffer. + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + @available(*, deprecated, message: "Suggested replacement is `share(replay: 1)`. In case old 3.x behavior of `shareReplay` is required please use `share(replay: 1, scope: .forever)` instead.", renamed: "share(replay:)") + public func shareReplay(_ bufferSize: Int) + -> Observable { + return self.share(replay: bufferSize, scope: .forever) + } +} + +/// Variable is a wrapper for `BehaviorSubject`. +/// +/// Unlike `BehaviorSubject` it can't terminate with error, and when variable is deallocated +/// it will complete its observable sequence (`asObservable`). +public final class Variable { + + public typealias E = Element + + private let _subject: BehaviorSubject + + private var _lock = SpinLock() + + // state + private var _value: E + + #if DEBUG + fileprivate let _synchronizationTracker = SynchronizationTracker() + #endif + + /// Gets or sets current value of variable. + /// + /// Whenever a new value is set, all the observers are notified of the change. + /// + /// Even if the newly set value is same as the old value, observers are still notified for change. + public var value: E { + get { + _lock.lock(); defer { _lock.unlock() } + return _value + } + set(newValue) { + #if DEBUG + _synchronizationTracker.register(synchronizationErrorMessage: .variable) + defer { _synchronizationTracker.unregister() } + #endif + _lock.lock() + _value = newValue + _lock.unlock() + + _subject.on(.next(newValue)) + } + } + + /// Initializes variable with initial value. + /// + /// - parameter value: Initial variable value. + public init(_ value: Element) { + _value = value + _subject = BehaviorSubject(value: value) + } + + /// - returns: Canonical interface for push style sequence + public func asObservable() -> Observable { + return _subject + } + + deinit { + _subject.on(.completed) + } +} diff --git a/RxAlamofire/Pods/RxSwift/RxSwift/Observables/Filter.swift b/RxAlamofire/Pods/RxSwift/RxSwift/Observables/Filter.swift index 8cf8c0d5..2a1f496a 100644 --- a/RxAlamofire/Pods/RxSwift/RxSwift/Observables/Filter.swift +++ b/RxAlamofire/Pods/RxSwift/RxSwift/Observables/Filter.swift @@ -32,10 +32,11 @@ extension ObservableType { - returns: An observable sequence that skips all elements of the source sequence. */ public func ignoreElements() - -> Observable { - return filter { _ -> Bool in - return false + -> Completable { + return flatMap { _ in + return Observable.empty() } + .asCompletable() } } diff --git a/RxAlamofire/Pods/RxSwift/RxSwift/Observables/Multicast.swift b/RxAlamofire/Pods/RxSwift/RxSwift/Observables/Multicast.swift index 856830ee..a027c4f6 100644 --- a/RxAlamofire/Pods/RxSwift/RxSwift/Observables/Multicast.swift +++ b/RxAlamofire/Pods/RxSwift/RxSwift/Observables/Multicast.swift @@ -60,7 +60,7 @@ extension ObservableType { - returns: A connectable observable sequence that shares a single subscription to the underlying sequence. */ public func publish() -> ConnectableObservable { - return self.multicast(PublishSubject()) + return self.multicast { PublishSubject() } } } @@ -78,7 +78,7 @@ extension ObservableType { */ public func replay(_ bufferSize: Int) -> ConnectableObservable { - return self.multicast(ReplaySubject.create(bufferSize: bufferSize)) + return self.multicast { ReplaySubject.create(bufferSize: bufferSize) } } /** @@ -92,7 +92,7 @@ extension ObservableType { */ public func replayAll() -> ConnectableObservable { - return self.multicast(ReplaySubject.createUnbounded()) + return self.multicast { ReplaySubject.createUnbounded() } } } @@ -110,22 +110,6 @@ extension ConnectableObservableType { } } -extension ObservableType { - - /** - Returns an observable sequence that shares a single subscription to the underlying sequence. - - This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - - - seealso: [share operator on reactivex.io](http://reactivex.io/documentation/operators/refcount.html) - - - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. - */ - public func share() -> Observable { - return self.publish().refCount() - } -} - extension ObservableType { /** diff --git a/RxAlamofire/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift b/RxAlamofire/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift index ee5e8f89..8ba2898d 100644 --- a/RxAlamofire/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift +++ b/RxAlamofire/Pods/RxSwift/RxSwift/Observables/ShareReplayScope.swift @@ -138,13 +138,13 @@ extension ObservableType { - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. */ - public func share(replay: Int = 0, scope: SubjectLifetimeScope) + public func share(replay: Int = 0, scope: SubjectLifetimeScope = .whileConnected) -> Observable { switch scope { case .forever: switch replay { case 0: return self.multicast(PublishSubject()).refCount() - default: return shareReplay(replay) + default: return self.multicast(ReplaySubject.create(bufferSize: replay)).refCount() } case .whileConnected: switch replay { @@ -156,44 +156,6 @@ extension ObservableType { } } -extension ObservableType { - - /** - Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays latest element in buffer. - - This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - - Unlike `shareReplay(bufferSize: Int)`, this operator will clear latest element from replay buffer in case number of subscribers drops from one to zero. In case sequence - completes or errors out replay buffer is also cleared. - - - seealso: [shareReplay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) - - - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. - */ - public func shareReplayLatestWhileConnected() - -> Observable { - return ShareReplay1WhileConnected(source: self.asObservable()) - } -} - -extension ObservableType { - - /** - Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays maximum number of elements in buffer. - - This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. - - - seealso: [shareReplay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) - - - parameter bufferSize: Maximum element count of the replay buffer. - - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. - */ - public func shareReplay(_ bufferSize: Int) - -> Observable { - return self.replay(bufferSize).refCount() - } -} - fileprivate final class ShareReplay1WhileConnectedConnection : ObserverType , SynchronizedUnsubscribeType { diff --git a/RxAlamofire/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift b/RxAlamofire/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift index cbdb98d9..2fe822d9 100644 --- a/RxAlamofire/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift +++ b/RxAlamofire/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift @@ -50,7 +50,11 @@ public class CurrentThreadScheduler : ImmediateSchedulerType { private static var isScheduleRequiredKey: pthread_key_t = { () -> pthread_key_t in let key = UnsafeMutablePointer.allocate(capacity: 1) - if pthread_key_create(key, nil) != 0 { + defer { + key.deallocate(capacity: 1) + } + + guard pthread_key_create(key, nil) == 0 else { rxFatalError("isScheduleRequired key creation failed") } diff --git a/RxAlamofire/Pods/RxSwift/RxSwift/Subjects/Variable.swift b/RxAlamofire/Pods/RxSwift/RxSwift/Subjects/Variable.swift deleted file mode 100644 index ba058f87..00000000 --- a/RxAlamofire/Pods/RxSwift/RxSwift/Subjects/Variable.swift +++ /dev/null @@ -1,67 +0,0 @@ -// -// Variable.swift -// RxSwift -// -// Created by Krunoslav Zaher on 3/28/15. -// Copyright © 2015 Krunoslav Zaher. All rights reserved. -// - -/// Variable is a wrapper for `BehaviorSubject`. -/// -/// Unlike `BehaviorSubject` it can't terminate with error, and when variable is deallocated -/// it will complete its observable sequence (`asObservable`). -public final class Variable { - - public typealias E = Element - - private let _subject: BehaviorSubject - - private var _lock = SpinLock() - - // state - private var _value: E - - #if DEBUG - fileprivate let _synchronizationTracker = SynchronizationTracker() - #endif - - /// Gets or sets current value of variable. - /// - /// Whenever a new value is set, all the observers are notified of the change. - /// - /// Even if the newly set value is same as the old value, observers are still notified for change. - public var value: E { - get { - _lock.lock(); defer { _lock.unlock() } - return _value - } - set(newValue) { - #if DEBUG - _synchronizationTracker.register(synchronizationErrorMessage: .variable) - defer { _synchronizationTracker.unregister() } - #endif - _lock.lock() - _value = newValue - _lock.unlock() - - _subject.on(.next(newValue)) - } - } - - /// Initializes variable with initial value. - /// - /// - parameter value: Initial variable value. - public init(_ value: Element) { - _value = value - _subject = BehaviorSubject(value: value) - } - - /// - returns: Canonical interface for push style sequence - public func asObservable() -> Observable { - return _subject - } - - deinit { - _subject.on(.completed) - } -} diff --git a/RxAlamofire/RxAlamofire.xcodeproj/project.pbxproj b/RxAlamofire/RxAlamofire.xcodeproj/project.pbxproj index 6def71d7..fe070ede 100644 --- a/RxAlamofire/RxAlamofire.xcodeproj/project.pbxproj +++ b/RxAlamofire/RxAlamofire.xcodeproj/project.pbxproj @@ -8,12 +8,12 @@ /* Begin PBXBuildFile section */ 3BBE9600C2797D13027DDAD9 /* Pods_RxAlamofireTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4B537E5740797F3F40C8B8C6 /* Pods_RxAlamofireTests.framework */; }; - 637D95951C4E37CE00F1FA67 /* BuildFile in Resources */ = {isa = PBXBuildFile; }; - 637D95961C4E37CE00F1FA67 /* BuildFile in Resources */ = {isa = PBXBuildFile; }; - 637D95991C4E37F200F1FA67 /* BuildFile in Resources */ = {isa = PBXBuildFile; }; - 637D959A1C4E37F200F1FA67 /* BuildFile in Resources */ = {isa = PBXBuildFile; }; - 637D959D1C4E380300F1FA67 /* BuildFile in Resources */ = {isa = PBXBuildFile; }; - 637D959E1C4E380300F1FA67 /* BuildFile in Resources */ = {isa = PBXBuildFile; }; + 637D95951C4E37CE00F1FA67 /* (null) in Resources */ = {isa = PBXBuildFile; }; + 637D95961C4E37CE00F1FA67 /* (null) in Resources */ = {isa = PBXBuildFile; }; + 637D95991C4E37F200F1FA67 /* (null) in Resources */ = {isa = PBXBuildFile; }; + 637D959A1C4E37F200F1FA67 /* (null) in Resources */ = {isa = PBXBuildFile; }; + 637D959D1C4E380300F1FA67 /* (null) in Resources */ = {isa = PBXBuildFile; }; + 637D959E1C4E380300F1FA67 /* (null) in Resources */ = {isa = PBXBuildFile; }; 7BA89A4899EADF5CF8018449 /* Pods_RxAlamofire_iOS_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A68A976262D78C5745424C3 /* Pods_RxAlamofire_iOS_Example.framework */; }; 83FCA92C44E8A347B0AB0207 /* Pods_RxAlamofiretvOSExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C8942AB230583C8D6C5414E /* Pods_RxAlamofiretvOSExample.framework */; }; A57A28CE1D78E8EB000D88BA /* RxAlamofireTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A57A28CD1D78E8EB000D88BA /* RxAlamofireTests.swift */; }; @@ -591,15 +591,15 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - 637D95991C4E37F200F1FA67 /* BuildFile in Resources */, + 637D95991C4E37F200F1FA67 /* (null) in Resources */, C87D2C921D8F34CF003F5936 /* LaunchScreen.storyboard in Resources */, - 637D959E1C4E380300F1FA67 /* BuildFile in Resources */, - 637D959D1C4E380300F1FA67 /* BuildFile in Resources */, - 637D95951C4E37CE00F1FA67 /* BuildFile in Resources */, + 637D959E1C4E380300F1FA67 /* (null) in Resources */, + 637D959D1C4E380300F1FA67 /* (null) in Resources */, + 637D95951C4E37CE00F1FA67 /* (null) in Resources */, C87D2C911D8F34CF003F5936 /* Assets.xcassets in Resources */, C87D2C931D8F34CF003F5936 /* Main.storyboard in Resources */, - 637D95961C4E37CE00F1FA67 /* BuildFile in Resources */, - 637D959A1C4E37F200F1FA67 /* BuildFile in Resources */, + 637D95961C4E37CE00F1FA67 /* (null) in Resources */, + 637D959A1C4E37F200F1FA67 /* (null) in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -952,6 +952,7 @@ PRODUCT_NAME = RxAlamofire; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -975,6 +976,7 @@ PRODUCT_NAME = RxAlamofire; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -993,6 +995,7 @@ PRODUCT_BUNDLE_IDENTIFIER = ch.bonto.RxAlamofire.RxAlamofiretvOSExample; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Debug; @@ -1009,6 +1012,7 @@ PRODUCT_BUNDLE_IDENTIFIER = ch.bonto.RxAlamofire.RxAlamofiretvOSExample; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Release; @@ -1066,6 +1070,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "ch.bonto.RxAlamofire.RxAlamofire-iOS"; PRODUCT_NAME = RxAlamofire; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1087,6 +1092,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "ch.bonto.RxAlamofire.RxAlamofire-iOS"; PRODUCT_NAME = RxAlamofire; SKIP_INSTALL = YES; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1193,6 +1199,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = ch.bonto.RxAlamofire.Example; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1206,6 +1213,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = ch.bonto.RxAlamofire.Example; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; }; name = Release; };