From 2aeca9b8771186a8f6eda48c3e1a3e4723e7091a Mon Sep 17 00:00:00 2001 From: Jan Misar Date: Wed, 12 Apr 2017 10:17:17 +0200 Subject: [PATCH] Update Pods. --- .../project.pbxproj | 8 +- Example/Podfile.lock | 54 +- .../ACKReactiveExtensions.podspec.json | 112 -- Example/Pods/ReactiveCocoa/README.md | 168 --- .../ReactiveCocoa/DelegateProxy.swift | 124 --- .../ReactiveCocoa/Deprecations+Removals.swift | 6 - .../ReactiveCocoa/DynamicProperty.swift | 66 -- .../ReactiveCocoa/NSObject+Association.swift | 132 --- .../NSObject+BindingTarget.swift | 23 - .../ReactiveCocoa/NSObject+Intercepting.swift | 432 -------- .../NSObject+KeyValueObserving.swift | 356 ------- .../ReactiveCocoa/NSObject+Lifetime.swift | 84 -- .../ReactiveCocoa/ObjC+Runtime.swift | 24 - .../ObjC+RuntimeSubclassing.swift | 85 -- .../ReactiveCocoa/ObjC+Selector.swift | 38 - .../ReactiveCocoa/UIKit/UIControl.swift | 87 -- .../UIKit/UIGestureRecognizer.swift | 25 - .../ReactiveCocoa/UIKit/UITextField.swift | 50 - .../UIKit/iOS/UIPickerView.swift | 43 - Example/Pods/ReactiveSwift/README.md | 492 --------- .../Pods/ReactiveSwift/Sources/Action.swift | 325 ------ .../Pods/ReactiveSwift/Sources/Atomic.swift | 298 ------ .../Sources/Deprecations+Removals.swift | 620 ------------ .../ReactiveSwift/Sources/Disposable.swift | 408 -------- .../Pods/ReactiveSwift/Sources/Flatten.swift | 957 ------------------ .../Pods/ReactiveSwift/Sources/Lifetime.swift | 91 -- 26 files changed, 31 insertions(+), 5077 deletions(-) delete mode 100644 Example/Pods/Local Podspecs/ACKReactiveExtensions.podspec.json delete mode 100644 Example/Pods/ReactiveCocoa/README.md delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/DelegateProxy.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/Deprecations+Removals.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/DynamicProperty.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Association.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+BindingTarget.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Intercepting.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+KeyValueObserving.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Lifetime.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+Runtime.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+RuntimeSubclassing.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+Selector.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UIControl.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UIGestureRecognizer.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UITextField.swift delete mode 100644 Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UIPickerView.swift delete mode 100644 Example/Pods/ReactiveSwift/README.md delete mode 100644 Example/Pods/ReactiveSwift/Sources/Action.swift delete mode 100644 Example/Pods/ReactiveSwift/Sources/Atomic.swift delete mode 100644 Example/Pods/ReactiveSwift/Sources/Deprecations+Removals.swift delete mode 100644 Example/Pods/ReactiveSwift/Sources/Disposable.swift delete mode 100644 Example/Pods/ReactiveSwift/Sources/Flatten.swift delete mode 100644 Example/Pods/ReactiveSwift/Sources/Lifetime.swift diff --git a/Example/ACKReactiveExtensions.xcodeproj/project.pbxproj b/Example/ACKReactiveExtensions.xcodeproj/project.pbxproj index 87c2461..9068f96 100644 --- a/Example/ACKReactiveExtensions.xcodeproj/project.pbxproj +++ b/Example/ACKReactiveExtensions.xcodeproj/project.pbxproj @@ -13,9 +13,9 @@ 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 693402381D1296C3004F1FFB /* UIKitExtensionsThreadingSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 693402371D1296C3004F1FFB /* UIKitExtensionsThreadingSpec.swift */; }; - 69FDE6FD1E968255004FD0D7 /* MarshalMappingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69FDE6FC1E968255004FD0D7 /* MarshalMappingTests.swift */; }; 69FDE6F71E965C56004FD0D7 /* ArgoMappingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69FDE6F51E965C32004FD0D7 /* ArgoMappingTests.swift */; }; 69FDE6F91E966111004FD0D7 /* TestHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69FDE6F81E966111004FD0D7 /* TestHelpers.swift */; }; + 69FDE6FD1E968255004FD0D7 /* MarshalMappingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69FDE6FC1E968255004FD0D7 /* MarshalMappingTests.swift */; }; 93633F05A07E7E137AB05065 /* Pods_ACKReactiveExtensions_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 482304D33E40D8C0EF1F687B /* Pods_ACKReactiveExtensions_Example.framework */; }; ACF37BD01E26CED900FE04FF /* RealmTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = ACF37BCF1E26CED900FE04FF /* RealmTest.swift */; }; E7AF6B155A6030F53856FC10 /* Pods_ACKReactiveExtensions_Example_ACKReactiveExtensions_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA849E88A474C832B5FE7224 /* Pods_ACKReactiveExtensions_Example_ACKReactiveExtensions_Tests.framework */; }; @@ -47,9 +47,9 @@ 607FACE51AFB9204008FA782 /* ACKReactiveExtensions_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ACKReactiveExtensions_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 693402371D1296C3004F1FFB /* UIKitExtensionsThreadingSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIKitExtensionsThreadingSpec.swift; sourceTree = ""; }; - 69FDE6FC1E968255004FD0D7 /* MarshalMappingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarshalMappingTests.swift; sourceTree = ""; }; 69FDE6F51E965C32004FD0D7 /* ArgoMappingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ArgoMappingTests.swift; sourceTree = ""; }; 69FDE6F81E966111004FD0D7 /* TestHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestHelpers.swift; sourceTree = ""; }; + 69FDE6FC1E968255004FD0D7 /* MarshalMappingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MarshalMappingTests.swift; sourceTree = ""; }; AA849E88A474C832B5FE7224 /* Pods_ACKReactiveExtensions_Example_ACKReactiveExtensions_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ACKReactiveExtensions_Example_ACKReactiveExtensions_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; ACF37BCF1E26CED900FE04FF /* RealmTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealmTest.swift; sourceTree = ""; }; B3CB8296538D6AF90E03A00A /* Pods-ACKReactiveExtensions_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ACKReactiveExtensions_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-ACKReactiveExtensions_Example/Pods-ACKReactiveExtensions_Example.debug.xcconfig"; sourceTree = ""; }; @@ -350,7 +350,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; A42FDC134F2DBF6A72668EA4 /* [CP] Check Pods Manifest.lock */ = { @@ -365,7 +365,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 3950d0b..4a17bd0 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,33 +1,33 @@ PODS: - - ACKReactiveExtensions (2.3.0): - - ACKReactiveExtensions/Core (= 2.3.0) - - ACKReactiveExtensions/UIKit (= 2.3.0) + - ACKReactiveExtensions (2.4.0): + - ACKReactiveExtensions/Core (= 2.4.0) + - ACKReactiveExtensions/UIKit (= 2.4.0) - ReactiveCocoa (~> 5.0) - - ACKReactiveExtensions/Argo (2.3.0): + - ACKReactiveExtensions/Argo (2.4.0): - Argo (< 5.0, >= 4.1.2) - ReactiveCocoa (~> 5.0) - - ACKReactiveExtensions/Core (2.3.0): + - ACKReactiveExtensions/Core (2.4.0): - ReactiveCocoa (~> 5.0) - - ACKReactiveExtensions/Marshal (2.3.0): + - ACKReactiveExtensions/Marshal (2.4.0): - ACKReactiveExtensions/Core - Marshal (~> 1.2) - ReactiveCocoa (~> 5.0) - - ACKReactiveExtensions/Reachability (2.3.0): + - ACKReactiveExtensions/Reachability (2.4.0): - ACKReactiveExtensions/Core - Reachability - ReactiveCocoa (~> 5.0) - - ACKReactiveExtensions/Realm (2.3.0): + - ACKReactiveExtensions/Realm (2.4.0): - ACKReactiveExtensions/Core - ReactiveCocoa (~> 5.0) - RealmSwift (~> 2.1) - - ACKReactiveExtensions/SDWebImage (2.3.0): + - ACKReactiveExtensions/SDWebImage (2.4.0): - ACKReactiveExtensions/Core - ReactiveCocoa (~> 5.0) - SDWebImage (~> 4.0) - - ACKReactiveExtensions/UIKit (2.3.0): + - ACKReactiveExtensions/UIKit (2.4.0): - ACKReactiveExtensions/Core - ReactiveCocoa (~> 5.0) - - ACKReactiveExtensions/WebKit (2.3.0): + - ACKReactiveExtensions/WebKit (2.4.0): - ACKReactiveExtensions/Core - ReactiveCocoa (~> 5.0) - Argo (4.1.2): @@ -37,16 +37,16 @@ PODS: - Nimble (5.1.1) - Quick (0.10.0) - Reachability (3.2) - - ReactiveCocoa (5.0.1): + - ReactiveCocoa (5.0.3): - ReactiveSwift (~> 1.1) - - ReactiveSwift (1.1.0): - - Result (~> 3.1) - - Realm (2.1.2): - - Realm/Headers (= 2.1.2) - - Realm/Headers (2.1.2) - - RealmSwift (2.1.2): - - Realm (= 2.1.2) - - Result (3.1.0) + - ReactiveSwift (1.1.1): + - Result (~> 3.2) + - Realm (2.5.1): + - Realm/Headers (= 2.5.1) + - Realm/Headers (2.5.1) + - RealmSwift (2.5.1): + - Realm (= 2.5.1) + - Result (3.2.1) - Runes (4.0.1) - SDWebImage (4.0.0): - SDWebImage/Core (= 4.0.0) @@ -70,21 +70,21 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - ACKReactiveExtensions: f35f2afcd9e5b324d92883c94b4c3d724118781f + ACKReactiveExtensions: 7200292deb4ee34bf1381952ae2362dc23ddcfc6 Argo: 5db06502fc1222d83011f574243089dab25202ff Curry: eb3d2c75aec678b3cc7fb2729d2ad6dd121531d1 Marshal: 8e04e6624e506921db7143b0bfd83caee03f32d6 Nimble: 415e3aa3267e7bc2c96b05fa814ddea7bb686a29 Quick: 5d290df1c69d5ee2f0729956dcf0fd9a30447eaa Reachability: 33e18b67625424e47b6cde6d202dce689ad7af96 - ReactiveCocoa: f577006aa6c7b0b08020109ebaae3b77ada00adc - ReactiveSwift: 2f4e4a02e5a5c87ea63f5fe667163ce2a67cbb57 - Realm: efe855f4d977c8ce5a82d3116d9f1ff155a6550c - RealmSwift: 17d6ee30b6f9df86364408c2197492e33bfea567 - Result: 4e3ed5995ed94d0cd6a09be9a431fce3f3624bbf + ReactiveCocoa: 066a855f613fb72f68258771095805fdb10312d2 + ReactiveSwift: 2489549e3231a6ff68ec99f3d320bb264f10ba0a + Realm: 32f86104d37c8521f864d4274050b38ba6190733 + RealmSwift: f719e7511c902b8908593e8f143f59e47931bdb6 + Result: 2453a22e5c5b11c0c3a478736e82cd02f763b781 Runes: ff20f163b478ac2c0e18158d6086fd5b1997f983 SDWebImage: 76a6348bdc74eb5a55dd08a091ef298e56b55e41 PODFILE CHECKSUM: 1d0475767d76bb45cefcaceddd19be37d22fedc7 -COCOAPODS: 1.2.0 +COCOAPODS: 1.2.1 diff --git a/Example/Pods/Local Podspecs/ACKReactiveExtensions.podspec.json b/Example/Pods/Local Podspecs/ACKReactiveExtensions.podspec.json deleted file mode 100644 index c893d59..0000000 --- a/Example/Pods/Local Podspecs/ACKReactiveExtensions.podspec.json +++ /dev/null @@ -1,112 +0,0 @@ -{ - "name": "ACKReactiveExtensions", - "version": "2.3.0", - "summary": "Useful extensions for ReactiveCocoa.", - "description": "TODO: Add long description of the pod here.", - "homepage": "https://github.com/AckeeCZ/ACKReactiveExtensions", - "license": { - "type": "MIT", - "file": "LICENSE" - }, - "authors": { - "Ackee": "info@ackee.cz" - }, - "source": { - "git": "https://github.com/AckeeCZ/ACKReactiveExtensions.git", - "tag": "2.3.0" - }, - "platforms": { - "ios": "8.3" - }, - "default_subspecs": [ - "Core", - "UIKit" - ], - "dependencies": { - "ReactiveCocoa": [ - "~> 5.0" - ] - }, - "subspecs": [ - { - "name": "Core", - "source_files": "ACKReactiveExtensions/Core/**/*" - }, - { - "name": "UIKit", - "dependencies": { - "ACKReactiveExtensions/Core": [ - - ] - }, - "source_files": "ACKReactiveExtensions/UIKit/**/*" - }, - { - "name": "Argo", - "dependencies": { - "Argo": [ - ">= 4.1.2", - "< 5.0" - ] - }, - "source_files": "ACKReactiveExtensions/Argo/**/*" - }, - { - "name": "Reachability", - "dependencies": { - "ACKReactiveExtensions/Core": [ - - ], - "Reachability": [ - - ] - }, - "source_files": "ACKReactiveExtensions/Reachability/**/*" - }, - { - "name": "SDWebImage", - "dependencies": { - "ACKReactiveExtensions/Core": [ - - ], - "SDWebImage": [ - "~> 4.0" - ] - }, - "source_files": "ACKReactiveExtensions/SDWebImage/**/*" - }, - { - "name": "WebKit", - "dependencies": { - "ACKReactiveExtensions/Core": [ - - ] - }, - "source_files": "ACKReactiveExtensions/WebKit/**/*" - }, - { - "name": "Realm", - "dependencies": { - "ACKReactiveExtensions/Core": [ - - ], - "RealmSwift": [ - "~> 2.1" - ] - }, - "source_files": "ACKReactiveExtensions/Realm/**/*" - }, - { - "name": "Marshal", - "dependencies": { - "ACKReactiveExtensions/Core": [ - - ], - "Marshal": [ - "~> 1.2" - ] - }, - "source_files": "ACKReactiveExtensions/Marshal/**/*" - } - ] -} diff --git a/Example/Pods/ReactiveCocoa/README.md b/Example/Pods/ReactiveCocoa/README.md deleted file mode 100644 index 761106d..0000000 --- a/Example/Pods/ReactiveCocoa/README.md +++ /dev/null @@ -1,168 +0,0 @@ -

- ReactiveCocoa

- Reactive extensions to Cocoa frameworks, built on top of ReactiveSwift.

- Join the ReactiveSwift Slack community. -

-
-[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage) [![CocoaPods compatible](https://img.shields.io/cocoapods/v/ReactiveCocoa.svg)](#cocoapods) [![GitHub release](https://img.shields.io/github/release/ReactiveCocoa/ReactiveCocoa.svg)](https://github.com/ReactiveCocoa/ReactiveCocoa/releases) ![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.x-orange.svg) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OS%20X%20%7C%20watchOS%20%7C%20tvOS%20-lightgrey.svg) - -⚠️ [Looking for the Objective-C API?][] ⚠️ [Still using Swift 2.x?][] - -🎉 [Migrating from RAC 4.x?][CHANGELOG] - -🚄 [Release Roadmap](#release-roadmap) - -## What is ReactiveSwift? -__ReactiveSwift__ offers composable, declarative and flexible primitives that are built around the grand concept of ___streams of values over time___. These primitives can be used to uniformly represent common Cocoa and generic programming patterns that are fundamentally an act of observation. - -For more information about the core primitives, see [ReactiveSwift][]. - -## What is ReactiveCocoa? - -__ReactiveCocoa__ wraps various aspects of Cocoa frameworks with the declarative [ReactiveSwift][] primitives. - -1. **UI Bindings** - - UI components expose [`BindingTarget`][]s, which accept bindings from any - kind of streams of values via the `<~` operator. - - ```swift - // Bind the `name` property of `person` to the text value of an `UILabel`. - nameLabel.reactive.text <~ person.name - ``` - - _Note_: You'll need to import ReactiveSwift as well to make use of the `<~` operator. - -1. **Controls and User Interactions** - - Interactive UI components expose [`Signal`][]s for control events - and updates in the control value upon user interactions. - - A selected set of controls provide a convenience, expressive binding - API for [`Action`][]s. - - - ```swift - // Update `allowsCookies` whenever the toggle is flipped. - preferences.allowsCookies <~ toggle.reactive.isOnValues - - // Compute live character counts from the continuous stream of user initiated - // changes in the text. - textField.reactive.continuousTextValues.map { $0.characters.count } - - // Trigger `commit` whenever the button is pressed. - button.reactive.pressed = CocoaAction(viewModel.commit) - ``` - -1. **Declarative Objective-C Dynamism** - - Create signals that are sourced by intercepting Objective-C objects, - e.g. method call interception and object deinitialization. - - ```swift - // Notify after every time `viewWillAppear(_:)` is called. - let appearing = viewController.reactive.trigger(for: #selector(UIViewController.viewWillAppear(_:))) - - // Observe the lifetime of `object`. - object.reactive.lifetime.ended.observeCompleted(doCleanup) - ``` - -1. **Expressive, Safe Key Path Observation** - - Establish key-value observations in the form of [`SignalProducer`][]s and - `DynamicProperty`s, and enjoy the inherited composability. - - ```swift - // A producer that sends the current value of `keyPath`, followed by - // subsequent changes. - // - // Terminate the KVO observation if the lifetime of `self` ends. - let producer = object.reactive.values(forKeyPath: #keyPath(key)) - .take(during: self.reactive.lifetime) - - // A parameterized property that represents the supplied key path of the - // wrapped object. It holds a weak reference to the wrapped object. - let property = DynamicProperty(object: person, - keyPath: #keyPath(person.name)) - ``` - -But there are still more to be discovered and introduced. Read our in-code documentations and release notes to -find out more. - -## Getting started - -ReactiveCocoa supports macOS 10.9+, iOS 8.0+, watchOS 2.0+, and tvOS 9.0+. - -#### Carthage - -If you use [Carthage][] to manage your dependencies, simply add -ReactiveCocoa to your `Cartfile`: - -``` -github "ReactiveCocoa/ReactiveCocoa" ~> 5.0 -``` - -If you use Carthage to build your dependencies, make sure you have added `ReactiveCocoa.framework`, `ReactiveSwift.framework`, and `Result.framework` to the "_Linked Frameworks and Libraries_" section of your target, and have included them in your Carthage framework copying build phase. - -#### CocoaPods - -If you use [CocoaPods][] to manage your dependencies, simply add -ReactiveCocoa to your `Podfile`: - -``` -pod 'ReactiveCocoa', '~> 5.0.0' -``` - -#### Git submodule - - 1. Add the ReactiveCocoa repository as a [submodule][] of your - application’s repository. - 1. Run `git submodule update --init --recursive` from within the ReactiveCocoa folder. - 1. Drag and drop `ReactiveCocoa.xcodeproj`, - `Carthage/Checkouts/ReactiveSwift/ReactiveSwift.xcodeproj`, and - `Carthage/Checkouts/Result/Result.xcodeproj` into your application’s Xcode - project or workspace. - 1. On the “General” tab of your application target’s settings, add - `ReactiveCocoa.framework`, `ReactiveSwift.framework`, and `Result.framework` - to the “Embedded Binaries” section. - 1. If your application target does not contain Swift code at all, you should also - set the `EMBEDDED_CONTENT_CONTAINS_SWIFT` build setting to “Yes”. - -## Have a question? -If you need any help, please visit our [GitHub issues][] or [Stack Overflow][]. Feel free to file an issue if you do not manage to find any solution from the archives. - -## Release Roadmap -**Current Stable Release:**
[![GitHub release](https://img.shields.io/github/release/ReactiveCocoa/ReactiveCocoa.svg)](https://github.com/ReactiveCocoa/ReactiveCocoa/releases) - -#### ReactiveCocoa 6.0 -It targets Swift 3.1.x and ReactiveSwift 2.0. The estimated schedule is Spring 2017. - -Since ReactiveSwift 2.0 would contain breaking changes, the public API of ReactiveCocoa is considered breaking too. - -As resilience would be enforced in Swift 4.0, it is important for us to have a clean and steady API to start with. The expectation is to **have the API reviewing to be concluded in ReactiveCocoa 6.0**, before we move on to ReactiveSwift 3.0 and Swift 4.0. Any contribution to help realising this goal is welcomed. - -#### ReactiveCocoa 7.0 -It targets Swift 4.0.x and ReactiveSwift 3.0. The estimated schedule is late 2017. - -The release may contain breaking changes due to changes in ReactiveSwift 3.0. - -ReactiveCocoa 7.0 would focus on three main goals: - -1. Swift 4.0 Resilience -1. Migration to ReactiveSwift 3.0 -1. Support new features introduced to AppKit, UIKit and Swift. - -[ReactiveSwift]: https://github.com/ReactiveCocoa/ReactiveSwift -[ReactiveObjC]: https://github.com/ReactiveCocoa/ReactiveObjC -[GitHub issues]: https://github.com/ReactiveCocoa/ReactiveCocoa/issues?q=is%3Aissue+label%3Aquestion+ -[Stack Overflow]: http://stackoverflow.com/questions/tagged/reactive-cocoa -[CHANGELOG]: CHANGELOG.md -[Carthage]: https://github.com/Carthage/Carthage -[CocoaPods]: https://cocoapods.org/ -[submodule]: https://git-scm.com/book/en/v2/Git-Tools-Submodules -[Looking for the Objective-C API?]: https://github.com/ReactiveCocoa/ReactiveObjC -[Still using Swift 2.x?]: https://github.com/ReactiveCocoa/ReactiveCocoa/tree/v4.0.0 -[`Signal`]: https://github.com/ReactiveCocoa/ReactiveSwift/blob/master/Documentation/FrameworkOverview.md#signals -[`SignalProducer`]: https://github.com/ReactiveCocoa/ReactiveSwift/blob/master/Documentation/FrameworkOverview.md#signal-producers -[`Action`]: https://github.com/ReactiveCocoa/ReactiveSwift/blob/master/Documentation/FrameworkOverview.md#actions -[`BindingTarget`]: https://github.com/ReactiveCocoa/ReactiveSwift/blob/master/Documentation/FrameworkOverview.md#properties diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/DelegateProxy.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/DelegateProxy.swift deleted file mode 100644 index 21bd8b6..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/DelegateProxy.swift +++ /dev/null @@ -1,124 +0,0 @@ -import ReactiveSwift -import enum Result.NoError - -internal class DelegateProxy: NSObject { - internal weak var forwardee: Delegate? { - didSet { - originalSetter(self) - } - } - - internal var interceptedSelectors: Set = [] - - private let originalSetter: (AnyObject) -> Void - - required init(_ originalSetter: @escaping (AnyObject) -> Void) { - self.originalSetter = originalSetter - } - - override func forwardingTarget(for selector: Selector!) -> Any? { - return interceptedSelectors.contains(selector) ? nil : forwardee - } - - func intercept(_ selector: Selector) -> Signal<(), NoError> { - interceptedSelectors.insert(selector) - originalSetter(self) - return self.reactive.trigger(for: selector) - } - - func intercept(_ selector: Selector) -> Signal<[Any?], NoError> { - interceptedSelectors.insert(selector) - originalSetter(self) - return self.reactive.signal(for: selector) - } - - override func responds(to selector: Selector!) -> Bool { - if interceptedSelectors.contains(selector) { - return true - } - - return forwardee?.responds(to: selector) ?? super.responds(to: selector) - } -} - -private let hasSwizzledKey = AssociationKey(default: false) - -extension DelegateProxy { - // FIXME: This is a workaround to a compiler issue, where any use of `Self` - // through a protocol would result in the following error messages: - // 1. PHI node operands are not the same type as the result! - // 2. LLVM ERROR: Broken function found, compilation aborted! - internal static func proxy>( - for instance: NSObject, - setter: Selector, - getter: Selector, - _ key: StaticString = #function - ) -> P { - return _proxy(for: instance, setter: setter, getter: getter, key) as! P - } - - private static func _proxy( - for instance: NSObject, - setter: Selector, - getter: Selector, - _ key: StaticString = #function - ) -> AnyObject { - let key = AssociationKey?>(key) - - return instance.synchronized { - if let proxy = instance.associations.value(forKey: key) { - return proxy - } - - let subclass: AnyClass = swizzleClass(instance) - - // Hide the original setter, and redirect subsequent delegate assignment - // to the proxy. - try! ReactiveCocoa.synchronized(subclass) { - let subclassAssociations = Associations(subclass as AnyObject) - - if !subclassAssociations.value(forKey: hasSwizzledKey) { - subclassAssociations.setValue(true, forKey: hasSwizzledKey) - - let method = class_getInstanceMethod(subclass, setter) - let typeEncoding = method_getTypeEncoding(method)! - - let newSetterImpl: @convention(block) (NSObject, NSObject) -> Void = { object, delegate in - let proxy = object.associations.value(forKey: key)! - proxy.forwardee = (delegate as! Delegate) - } - - class_replaceMethod(subclass, - setter, - imp_implementationWithBlock(newSetterImpl as Any), - typeEncoding) - } - } - - // Set the proxy as the delegate. - let realClass: AnyClass = class_getSuperclass(subclass) - let originalSetterImpl: IMP = class_getMethodImplementation(realClass, setter) - let getterImpl: IMP = class_getMethodImplementation(realClass, getter) - - typealias Setter = @convention(c) (AnyObject, Selector, AnyObject) -> Void - typealias Getter = @convention(c) (AnyObject, Selector) -> NSObject? - - // As Objective-C classes may cache the information of their delegate at - // the time the delegates are set, the information has to be "flushed" - // whenever the proxy forwardee is replaced or a selector is intercepted. - let proxy = self.init { [weak instance] proxy in - guard let instance = instance else { return } - unsafeBitCast(originalSetterImpl, to: Setter.self)(instance, setter, proxy) - } - - instance.associations.setValue(proxy, forKey: key) - - let original = unsafeBitCast(getterImpl, to: Getter.self)(instance, getter) as! Delegate? - proxy.forwardee = original - - unsafeBitCast(originalSetterImpl, to: Setter.self)(instance, setter, proxy) - - return proxy - } - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/Deprecations+Removals.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/Deprecations+Removals.swift deleted file mode 100644 index 2a3e2e8..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/Deprecations+Removals.swift +++ /dev/null @@ -1,6 +0,0 @@ -import ReactiveSwift - -extension Action { - @available(*, unavailable, message:"Use the `CocoaAction` initializers instead.") - public var unsafeCocoaAction: CocoaAction { fatalError() } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/DynamicProperty.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/DynamicProperty.swift deleted file mode 100644 index ed79540..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/DynamicProperty.swift +++ /dev/null @@ -1,66 +0,0 @@ -import Foundation -import ReactiveSwift -import enum Result.NoError - -/// Wraps a `dynamic` property, or one defined in Objective-C, using Key-Value -/// Coding and Key-Value Observing. -/// -/// Use this class only as a last resort! `MutableProperty` is generally better -/// unless KVC/KVO is required by the API you're using (for example, -/// `NSOperation`). -public final class DynamicProperty: MutablePropertyProtocol { - private weak var object: NSObject? - private let keyPath: String - - /// The current value of the property, as read and written using Key-Value - /// Coding. - public var value: Value? { - get { - return object?.value(forKeyPath: keyPath) as! Value - } - - set(newValue) { - object?.setValue(newValue, forKeyPath: keyPath) - } - } - - /// The lifetime of the property. - public var lifetime: Lifetime { - return object?.reactive.lifetime ?? .empty - } - - /// A producer that will create a Key-Value Observer for the given object, - /// send its initial value then all changes over time, and then complete - /// when the observed object has deallocated. - /// - /// - important: This only works if the object given to init() is KVO-compliant. - /// Most UI controls are not! - public var producer: SignalProducer { - return (object.map { $0.reactive.values(forKeyPath: keyPath) } ?? .empty) - .map { $0 as! Value } - } - - public private(set) lazy var signal: Signal = { - var signal: Signal! - self.producer.startWithSignal { innerSignal, _ in signal = innerSignal } - return signal - }() - - /// Initializes a property that will observe and set the given key path of - /// the given object. The generic type `Value` can be any Swift type, and will - /// be bridged to Objective-C via `Any`. - /// - /// - important: `object` must support weak references! - /// - /// - parameters: - /// - object: An object to be observed. - /// - keyPath: Key path to observe on the object. - public init(object: NSObject, keyPath: String) { - self.object = object - self.keyPath = keyPath - - /// A DynamicProperty will stay alive as long as its object is alive. - /// This is made possible by strong reference cycles. - _ = object.reactive.lifetime.ended.observeCompleted { _ = self } - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Association.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Association.swift deleted file mode 100644 index 798a521..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Association.swift +++ /dev/null @@ -1,132 +0,0 @@ -import ReactiveSwift - -internal struct AssociationKey { - fileprivate let address: UnsafeRawPointer - fileprivate let `default`: Value! - - /// Create an ObjC association key. - /// - /// - warning: The key must be uniqued. - /// - /// - parameters: - /// - default: The default value, or `nil` to trap on undefined value. It is - /// ignored if `Value` is an optional. - init(default: Value? = nil) { - self.address = UnsafeRawPointer(UnsafeMutablePointer.allocate(capacity: 1)) - self.default = `default` - } - - /// Create an ObjC association key from a `StaticString`. - /// - /// - precondition: `key` has a pointer representation. - /// - /// - parameters: - /// - default: The default value, or `nil` to trap on undefined value. It is - /// ignored if `Value` is an optional. - init(_ key: StaticString, default: Value? = nil) { - assert(key.hasPointerRepresentation) - self.address = UnsafeRawPointer(key.utf8Start) - self.default = `default` - } - - /// Create an ObjC association key from a `Selector`. - /// - /// - parameters: - /// - default: The default value, or `nil` to trap on undefined value. It is - /// ignored if `Value` is an optional. - init(_ key: Selector, default: Value? = nil) { - self.address = UnsafeRawPointer(key.utf8Start) - self.default = `default` - } -} - -internal struct Associations { - fileprivate let base: Base - - init(_ base: Base) { - self.base = base - } -} - -extension Reactive where Base: NSObject { - /// Retrieve the associated value for the specified key. If the value does not - /// exist, `initial` would be called and the returned value would be - /// associated subsequently. - /// - /// - parameters: - /// - key: An optional key to differentiate different values. - /// - initial: The action that supples an initial value. - /// - /// - returns: - /// The associated value for the specified key. - internal func associatedValue(forKey key: StaticString = #function, initial: (Base) -> T) -> T { - let key = AssociationKey(key) - - if let value = base.associations.value(forKey: key) { - return value - } - - let value = initial(base) - base.associations.setValue(value, forKey: key) - - return value - } -} - -extension NSObject { - @nonobjc internal var associations: Associations { - return Associations(self) - } -} - -extension Associations { - /// Retrieve the associated value for the specified key. - /// - /// - parameters: - /// - key: The key. - /// - /// - returns: The associated value, or the default value if no value has been - /// associated with the key. - internal func value(forKey key: AssociationKey) -> Value { - return (objc_getAssociatedObject(base, key.address) as! Value?) ?? key.default - } - - /// Retrieve the associated value for the specified key. - /// - /// - parameters: - /// - key: The key. - /// - /// - returns: The associated value, or `nil` if no value is associated with - /// the key. - internal func value(forKey key: AssociationKey) -> Value? { - return objc_getAssociatedObject(base, key.address) as! Value? - } - - /// Set the associated value for the specified key. - /// - /// - parameters: - /// - value: The value to be associated. - /// - key: The key. - internal func setValue(_ value: Value, forKey key: AssociationKey) { - objc_setAssociatedObject(base, key.address, value, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) - } - - /// Set the associated value for the specified key. - /// - /// - parameters: - /// - value: The value to be associated. - /// - key: The key. - internal func setValue(_ value: Value?, forKey key: AssociationKey) { - objc_setAssociatedObject(base, key.address, value, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) - } -} - -/// Set the associated value for the specified key. -/// -/// - parameters: -/// - value: The value to be associated. -/// - key: The key. -/// - address: The address of the object. -internal func unsafeSetAssociatedValue(_ value: Value?, forKey key: AssociationKey, forObjectAt address: UnsafeRawPointer) { - _rac_objc_setAssociatedObject(address, key.address, value, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+BindingTarget.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+BindingTarget.swift deleted file mode 100644 index fdd89d5..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+BindingTarget.swift +++ /dev/null @@ -1,23 +0,0 @@ -import Foundation -import ReactiveSwift - -extension Reactive where Base: NSObject { - /// Creates a binding target which uses the lifetime of the object, and weakly - /// references the object so that the supplied `action` is triggered only if - /// the object has not deinitialized. - /// - /// - parameters: - /// - scheduler: An optional scheduler that the binding target uses. If it - /// is not specified, a UI scheduler would be used. - /// - action: The action to consume values from the bindings. - /// - /// - returns: - /// A binding target that holds no strong references to the object. - public func makeBindingTarget(on scheduler: SchedulerProtocol = UIScheduler(), _ action: @escaping (Base, U) -> Void) -> BindingTarget { - return BindingTarget(on: scheduler, lifetime: lifetime) { [weak base = self.base] value in - if let base = base { - action(base, value) - } - } - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Intercepting.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Intercepting.swift deleted file mode 100644 index 12e6579..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Intercepting.swift +++ /dev/null @@ -1,432 +0,0 @@ -import Foundation -import ReactiveSwift -import enum Result.NoError - -/// Whether the runtime subclass has already been prepared for method -/// interception. -fileprivate let interceptedKey = AssociationKey(default: false) - -/// Holds the method signature cache of the runtime subclass. -fileprivate let signatureCacheKey = AssociationKey() - -/// Holds the method selector cache of the runtime subclass. -fileprivate let selectorCacheKey = AssociationKey() - -extension Reactive where Base: NSObject { - /// Create a signal which sends a `next` event at the end of every invocation - /// of `selector` on the object. - /// - /// It completes when the object deinitializes. - /// - /// - note: Observers to the resulting signal should not call the method - /// specified by the selector. - /// - /// - parameters: - /// - selector: The selector to observe. - /// - /// - returns: - /// A trigger signal. - public func trigger(for selector: Selector) -> Signal<(), NoError> { - return base.intercept(selector).map { _ in } - } - - /// Create a signal which sends a `next` event, containing an array of bridged - /// arguments, at the end of every invocation of `selector` on the object. - /// - /// It completes when the object deinitializes. - /// - /// - note: Observers to the resulting signal should not call the method - /// specified by the selector. - /// - /// - parameters: - /// - selector: The selector to observe. - /// - /// - returns: - /// A signal that sends an array of bridged arguments. - public func signal(for selector: Selector) -> Signal<[Any?], NoError> { - return base.intercept(selector).map(unpackInvocation) - } -} - -extension NSObject { - /// Setup the method interception. - /// - /// - parameters: - /// - object: The object to be intercepted. - /// - selector: The selector of the method to be intercepted. - /// - /// - returns: - /// A signal that sends the corresponding `NSInvocation` after every - /// invocation of the method. - @nonobjc fileprivate func intercept(_ selector: Selector) -> Signal { - guard let method = class_getInstanceMethod(objcClass, selector) else { - fatalError("Selector `\(selector)` does not exist in class `\(String(describing: objcClass))`.") - } - - let typeEncoding = method_getTypeEncoding(method)! - assert(checkTypeEncoding(typeEncoding)) - - return synchronized { - let alias = selector.alias - let stateKey = AssociationKey(alias) - let interopAlias = selector.interopAlias - - if let state = associations.value(forKey: stateKey) { - return state.signal - } - - let subclass: AnyClass = swizzleClass(self) - let subclassAssociations = Associations(subclass as AnyObject) - - // FIXME: Compiler asks to handle a mysterious throw. - try! ReactiveCocoa.synchronized(subclass) { - let isSwizzled = subclassAssociations.value(forKey: interceptedKey) - - let signatureCache: SignatureCache - let selectorCache: SelectorCache - - if isSwizzled { - signatureCache = subclassAssociations.value(forKey: signatureCacheKey) - selectorCache = subclassAssociations.value(forKey: selectorCacheKey) - } else { - signatureCache = SignatureCache() - selectorCache = SelectorCache() - - subclassAssociations.setValue(signatureCache, forKey: signatureCacheKey) - subclassAssociations.setValue(selectorCache, forKey: selectorCacheKey) - subclassAssociations.setValue(true, forKey: interceptedKey) - - enableMessageForwarding(subclass, selectorCache) - setupMethodSignatureCaching(subclass, signatureCache) - } - - selectorCache.cache(selector) - - if signatureCache[selector] == nil { - let signature = NSMethodSignature.signature(withObjCTypes: typeEncoding) - signatureCache[selector] = signature - } - - // If an immediate implementation of the selector is found in the - // runtime subclass the first time the selector is intercepted, - // preserve the implementation. - // - // Example: KVO setters if the instance is swizzled by KVO before RAC - // does. - if !class_respondsToSelector(subclass, interopAlias) { - let immediateImpl = class_getImmediateMethod(subclass, selector) - .flatMap(method_getImplementation) - .flatMap { $0 != _rac_objc_msgForward ? $0 : nil } - - if let impl = immediateImpl { - class_addMethod(subclass, interopAlias, impl, typeEncoding) - } - } - } - - let state = InterceptingState(lifetime: reactive.lifetime) - associations.setValue(state, forKey: stateKey) - - // Start forwarding the messages of the selector. - _ = class_replaceMethod(subclass, selector, _rac_objc_msgForward, typeEncoding) - - return state.signal - } - } -} - -/// Swizzle `realClass` to enable message forwarding for method interception. -/// -/// - parameters: -/// - realClass: The runtime subclass to be swizzled. -private func enableMessageForwarding(_ realClass: AnyClass, _ selectorCache: SelectorCache) { - let perceivedClass: AnyClass = class_getSuperclass(realClass) - - typealias ForwardInvocationImpl = @convention(block) (Unmanaged, AnyObject) -> Void - let newForwardInvocation: ForwardInvocationImpl = { objectRef, invocation in - let selector = invocation.selector! - let alias = selectorCache.alias(for: selector) - let interopAlias = selectorCache.interopAlias(for: selector) - - defer { - let stateKey = AssociationKey(alias) - if let state = objectRef.takeUnretainedValue().associations.value(forKey: stateKey) { - state.observer.send(value: invocation) - } - } - - let method = class_getInstanceMethod(perceivedClass, selector)! - let typeEncoding = method_getTypeEncoding(method) - - if class_respondsToSelector(realClass, interopAlias) { - // RAC has preserved an immediate implementation found in the runtime - // subclass that was supplied by an external party. - // - // As the KVO setter relies on the selector to work, it has to be invoked - // by swapping in the preserved implementation and restore to the message - // forwarder afterwards. - // - // However, the IMP cache would be thrashed due to the swapping. - - let interopImpl = class_getMethodImplementation(realClass, interopAlias) - let previousImpl = class_replaceMethod(realClass, selector, interopImpl, typeEncoding) - invocation.invoke() - _ = class_replaceMethod(realClass, selector, previousImpl, typeEncoding) - - return - } - - if let impl = method_getImplementation(method), impl != _rac_objc_msgForward { - // The perceived class, or its ancestors, responds to the selector. - // - // The implementation is invoked through the selector alias, which - // reflects the latest implementation of the selector in the perceived - // class. - - if class_getMethodImplementation(realClass, alias) != impl { - // Update the alias if and only if the implementation has changed, so as - // to avoid thrashing the IMP cache. - _ = class_replaceMethod(realClass, alias, impl, typeEncoding) - } - - invocation.setSelector(alias) - invocation.invoke() - - return - } - - // Forward the invocation to the closest `forwardInvocation(_:)` in the - // inheritance hierarchy, or the default handler returned by the runtime - // if it finds no implementation. - typealias SuperForwardInvocation = @convention(c) (Unmanaged, Selector, AnyObject) -> Void - let impl = class_getMethodImplementation(perceivedClass, ObjCSelector.forwardInvocation) - let forwardInvocation = unsafeBitCast(impl, to: SuperForwardInvocation.self) - forwardInvocation(objectRef, ObjCSelector.forwardInvocation, invocation) - } - - _ = class_replaceMethod(realClass, - ObjCSelector.forwardInvocation, - imp_implementationWithBlock(newForwardInvocation as Any), - ObjCMethodEncoding.forwardInvocation) -} - -/// Swizzle `realClass` to accelerate the method signature retrieval, using a -/// signature cache that covers all known intercepted selectors of `realClass`. -/// -/// - parameters: -/// - realClass: The runtime subclass to be swizzled. -/// - signatureCache: The method signature cache. -private func setupMethodSignatureCaching(_ realClass: AnyClass, _ signatureCache: SignatureCache) { - let perceivedClass: AnyClass = class_getSuperclass(realClass) - - let newMethodSignatureForSelector: @convention(block) (Unmanaged, Selector) -> AnyObject? = { objectRef, selector in - if let signature = signatureCache[selector] { - return signature - } - - typealias SuperMethodSignatureForSelector = @convention(c) (Unmanaged, Selector, Selector) -> AnyObject? - let impl = class_getMethodImplementation(perceivedClass, ObjCSelector.methodSignatureForSelector) - let methodSignatureForSelector = unsafeBitCast(impl, to: SuperMethodSignatureForSelector.self) - return methodSignatureForSelector(objectRef, ObjCSelector.methodSignatureForSelector, selector) - } - - _ = class_replaceMethod(realClass, - ObjCSelector.methodSignatureForSelector, - imp_implementationWithBlock(newMethodSignatureForSelector as Any), - ObjCMethodEncoding.methodSignatureForSelector) -} - -/// The state of an intercepted method specific to an instance. -private final class InterceptingState { - let (signal, observer) = Signal.pipe() - - /// Initialize a state specific to an instance. - /// - /// - parameters: - /// - lifetime: The lifetime of the instance. - init(lifetime: Lifetime) { - lifetime.ended.observeCompleted(observer.sendCompleted) - } -} - -private final class SelectorCache { - private var map: [Selector: (main: Selector, interop: Selector)] = [:] - - init() {} - - /// Cache the aliases of the specified selector in the cache. - /// - /// - warning: Any invocation of this method must be synchronized against the - /// runtime subclass. - @discardableResult - func cache(_ selector: Selector) -> (main: Selector, interop: Selector) { - if let pair = map[selector] { - return pair - } - - let aliases = (selector.alias, selector.interopAlias) - map[selector] = aliases - - return aliases - } - - /// Get the alias of the specified selector. - /// - /// - parameters: - /// - selector: The selector alias. - func alias(for selector: Selector) -> Selector { - if let (main, _) = map[selector] { - return main - } - - return selector.alias - } - - /// Get the secondary alias of the specified selector. - /// - /// - parameters: - /// - selector: The selector alias. - func interopAlias(for selector: Selector) -> Selector { - if let (_, interop) = map[selector] { - return interop - } - - return selector.interopAlias - } -} - -// The signature cache for classes that have been swizzled for method -// interception. -// -// Read-copy-update is used here, since the cache has multiple readers but only -// one writer. -private final class SignatureCache { - // `Dictionary` takes 8 bytes for the reference to its storage and does CoW. - // So it should not encounter any corrupted, partially updated state. - private var map: [Selector: AnyObject] = [:] - - init() {} - - /// Get or set the signature for the specified selector. - /// - /// - warning: Any invocation of the setter must be synchronized against the - /// runtime subclass. - /// - /// - parameters: - /// - selector: The method signature. - subscript(selector: Selector) -> AnyObject? { - get { - return map[selector] - } - set { - if map[selector] == nil { - map[selector] = newValue - } - } - } -} - -/// Assert that the method does not contain types that cannot be intercepted. -/// -/// - parameters: -/// - types: The type encoding C string of the method. -/// -/// - returns: -/// `true`. -private func checkTypeEncoding(_ types: UnsafePointer) -> Bool { - // Some types, including vector types, are not encoded. In these cases the - // signature starts with the size of the argument frame. - assert(types.pointee < Int8(UInt8(ascii: "1")) || types.pointee > Int8(UInt8(ascii: "9")), - "unknown method return type not supported in type encoding: \(String(cString: types))") - - assert(types.pointee != Int8(UInt8(ascii: "(")), "union method return type not supported") - assert(types.pointee != Int8(UInt8(ascii: "{")), "struct method return type not supported") - assert(types.pointee != Int8(UInt8(ascii: "[")), "array method return type not supported") - - assert(types.pointee != Int8(UInt8(ascii: "j")), "complex method return type not supported") - - return true -} - -/// Extract the arguments of an `NSInvocation` as an array of objects. -/// -/// - parameters: -/// - invocation: The `NSInvocation` to unpack. -/// -/// - returns: -/// An array of objects. -private func unpackInvocation(_ invocation: AnyObject) -> [Any?] { - let invocation = invocation as AnyObject - let methodSignature = invocation.objcMethodSignature! - let count = UInt(methodSignature.numberOfArguments!) - - var bridged = [Any?]() - bridged.reserveCapacity(Int(count - 2)) - - // Ignore `self` and `_cmd` at index 0 and 1. - for position in 2 ..< count { - let rawEncoding = methodSignature.argumentType(at: position) - let encoding = ObjCTypeEncoding(rawValue: rawEncoding.pointee) ?? .undefined - - func extract(_ type: U.Type) -> U { - let pointer = UnsafeMutableRawPointer.allocate(bytes: MemoryLayout.size, - alignedTo: MemoryLayout.alignment) - defer { - pointer.deallocate(bytes: MemoryLayout.size, - alignedTo: MemoryLayout.alignment) - } - - invocation.copy(to: pointer, forArgumentAt: Int(position)) - return pointer.assumingMemoryBound(to: type).pointee - } - - let value: Any? - - switch encoding { - case .char: - value = NSNumber(value: extract(CChar.self)) - case .int: - value = NSNumber(value: extract(CInt.self)) - case .short: - value = NSNumber(value: extract(CShort.self)) - case .long: - value = NSNumber(value: extract(CLong.self)) - case .longLong: - value = NSNumber(value: extract(CLongLong.self)) - case .unsignedChar: - value = NSNumber(value: extract(CUnsignedChar.self)) - case .unsignedInt: - value = NSNumber(value: extract(CUnsignedInt.self)) - case .unsignedShort: - value = NSNumber(value: extract(CUnsignedShort.self)) - case .unsignedLong: - value = NSNumber(value: extract(CUnsignedLong.self)) - case .unsignedLongLong: - value = NSNumber(value: extract(CUnsignedLongLong.self)) - case .float: - value = NSNumber(value: extract(CFloat.self)) - case .double: - value = NSNumber(value: extract(CDouble.self)) - case .bool: - value = NSNumber(value: extract(CBool.self)) - case .object: - value = extract((AnyObject?).self) - case .type: - value = extract((AnyClass?).self) - case .selector: - value = extract((Selector?).self) - case .undefined: - var size = 0, alignment = 0 - NSGetSizeAndAlignment(rawEncoding, &size, &alignment) - let buffer = UnsafeMutableRawPointer.allocate(bytes: size, alignedTo: alignment) - defer { buffer.deallocate(bytes: size, alignedTo: alignment) } - - invocation.copy(to: buffer, forArgumentAt: Int(position)) - value = NSValue(bytes: buffer, objCType: rawEncoding) - } - - bridged.append(value) - } - - return bridged -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+KeyValueObserving.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+KeyValueObserving.swift deleted file mode 100644 index 47eee2c..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+KeyValueObserving.swift +++ /dev/null @@ -1,356 +0,0 @@ -import Foundation -import ReactiveSwift -import enum Result.NoError - -extension Reactive where Base: NSObject { - /// Create a producer which sends the current value and all the subsequent - /// changes of the property specified by the key path. - /// - /// The producer completes when the object deinitializes. - /// - /// - parameters: - /// - keyPath: The key path of the property to be observed. - /// - /// - returns: - /// A producer emitting values of the property specified by the key path. - public func values(forKeyPath keyPath: String) -> SignalProducer { - return SignalProducer { observer, disposable in - disposable += KeyValueObserver.observe( - self.base, - keyPath: keyPath, - options: [.initial, .new], - action: observer.send - ) - disposable += self.lifetime.ended.observeCompleted(observer.sendCompleted) - } - } -} - -internal final class KeyValueObserver: NSObject { - typealias Action = (_ object: AnyObject?) -> Void - private static let context = UnsafeMutableRawPointer.allocate(bytes: 1, alignedTo: 0) - - unowned(unsafe) let unsafeObject: NSObject - let key: String - let action: Action - - fileprivate init(observing object: NSObject, key: String, options: NSKeyValueObservingOptions, action: @escaping Action) { - self.unsafeObject = object - self.key = key - self.action = action - - super.init() - - object.addObserver( - self, - forKeyPath: key, - options: options, - context: KeyValueObserver.context - ) - } - - func detach() { - unsafeObject.removeObserver(self, forKeyPath: key, context: KeyValueObserver.context) - } - - override func observeValue( - forKeyPath keyPath: String?, - of object: Any?, - change: [NSKeyValueChangeKey : Any]?, - context: UnsafeMutableRawPointer? - ) { - if context == KeyValueObserver.context { - action(object as! NSObject) - } - } -} - -extension KeyValueObserver { - /// Establish an observation to the property specified by the key path - /// of `object`. - /// - /// - warning: The observation would not be automatically removed when - /// `object` deinitializes. You must manually dispose of the - /// returned disposable before `object` completes its - /// deinitialization. - /// - /// - parameters: - /// - object: The object to be observed. - /// - keyPath: The key path of the property to be observed. - /// - options: The desired configuration of the observation. - /// - action: The action to be invoked upon arrival of changes. - /// - /// - returns: - /// A disposable that would tear down the observation upon disposal. - static func observe( - _ object: NSObject, - keyPath: String, - options: NSKeyValueObservingOptions, - action: @escaping (_ value: AnyObject?) -> Void - ) -> ActionDisposable { - // Compute the key path head and tail. - let components = keyPath.components(separatedBy: ".") - precondition(!components.isEmpty, "Received an empty key path.") - - let isNested = components.count > 1 - let keyPathHead = components[0] - let keyPathTail = components[1 ..< components.endIndex].joined(separator: ".") - - // The serial disposable for the head key. - // - // The inner disposable would be disposed of, and replaced with a new one - // when the value of the head key changes. - let headSerialDisposable = SerialDisposable() - - // If the property of the head key isn't actually an object (or is a Class - // object), there is no point in observing the deallocation. - // - // If this property is not a weak reference to an object, we don't need to - // watch for it spontaneously being set to nil. - // - // Attempting to observe non-weak properties using dynamic getters will - // result in broken behavior, so don't even try. - let shouldObserveDeinit = keyPathHead.withCString { cString -> Bool in - if let propertyPointer = class_getProperty(type(of: object), cString) { - let attributes = PropertyAttributes(property: propertyPointer) - return attributes.isObject && attributes.isWeak && attributes.objectClass != NSClassFromString("Protocol") && !attributes.isBlock - } - - return false - } - - // Establish the observation. - // - // The initial value is also handled by the closure below, if `Initial` has - // been specified in the observation options. - let observer: KeyValueObserver - - if isNested { - observer = KeyValueObserver(observing: object, key: keyPathHead, options: options) { object in - guard let value = object?.value(forKey: keyPathHead) as! NSObject? else { - action(nil) - return - } - - let headDisposable = CompositeDisposable() - headSerialDisposable.inner = headDisposable - - if shouldObserveDeinit { - let disposable = value.reactive.lifetime.ended.observeCompleted { - action(nil) - } - headDisposable += disposable - } - - // Recursively add observers along the key path tail. - let disposable = KeyValueObserver.observe( - value, - keyPath: keyPathTail, - options: options.subtracting(.initial), - action: action - ) - headDisposable += disposable - - // Send the latest value of the key path tail. - action(value.value(forKeyPath: keyPathTail) as AnyObject?) - } - } else { - observer = KeyValueObserver(observing: object, key: keyPathHead, options: options) { object in - guard let value = object?.value(forKey: keyPathHead) as! NSObject? else { - action(nil) - return - } - - if shouldObserveDeinit { - let disposable = value.reactive.lifetime.ended.observeCompleted { - action(nil) - } - headSerialDisposable.inner = disposable - } - - // Send the latest value of the key. - action(value) - } - } - - return ActionDisposable { - observer.detach() - headSerialDisposable.dispose() - } - } -} - -/// A descriptor of the attributes and type information of a property in -/// Objective-C. -internal struct PropertyAttributes { - struct Code { - static let start = Int8(UInt8(ascii: "T")) - static let quote = Int8(UInt8(ascii: "\"")) - static let nul = Int8(UInt8(ascii: "\0")) - static let comma = Int8(UInt8(ascii: ",")) - - struct ContainingType { - static let object = Int8(UInt8(ascii: "@")) - static let block = Int8(UInt8(ascii: "?")) - } - - struct Attribute { - static let readonly = Int8(UInt8(ascii: "R")) - static let copy = Int8(UInt8(ascii: "C")) - static let retain = Int8(UInt8(ascii: "&")) - static let nonatomic = Int8(UInt8(ascii: "N")) - static let getter = Int8(UInt8(ascii: "G")) - static let setter = Int8(UInt8(ascii: "S")) - static let dynamic = Int8(UInt8(ascii: "D")) - static let ivar = Int8(UInt8(ascii: "V")) - static let weak = Int8(UInt8(ascii: "W")) - static let collectable = Int8(UInt8(ascii: "P")) - static let oldTypeEncoding = Int8(UInt8(ascii: "t")) - } - } - - /// The class of the property. - let objectClass: AnyClass? - - /// Indicate whether the property is a weak reference. - let isWeak: Bool - - /// Indicate whether the property is an object. - let isObject: Bool - - /// Indicate whether the property is a block. - let isBlock: Bool - - init(property: objc_property_t) { - guard let attrString = property_getAttributes(property) else { - preconditionFailure("Could not get attribute string from property.") - } - - precondition(attrString[0] == Code.start, "Expected attribute string to start with 'T'.") - - let typeString = attrString + 1 - - let _next = NSGetSizeAndAlignment(typeString, nil, nil) - guard _next != typeString else { - let string = String(validatingUTF8: attrString) - preconditionFailure("Could not read past type in attribute string: \(string).") - } - var next = UnsafeMutablePointer(mutating: _next) - - let typeLength = typeString.distance(to: next) - precondition(typeLength > 0, "Invalid type in attribute string.") - - var objectClass: AnyClass? = nil - - // if this is an object type, and immediately followed by a quoted string... - if typeString[0] == Code.ContainingType.object && typeString[1] == Code.quote { - // we should be able to extract a class name - let className = typeString + 2; - - // fast forward the `next` pointer. - guard let endQuote = strchr(className, Int32(Code.quote)) else { - preconditionFailure("Could not read class name in attribute string.") - } - next = endQuote - - if className != UnsafePointer(next) { - let length = className.distance(to: next) - let name = UnsafeMutablePointer.allocate(capacity: length + 1) - name.initialize(from: UnsafeMutablePointer(mutating: className), count: length) - (name + length).initialize(to: Code.nul) - - // attempt to look up the class in the runtime - objectClass = objc_getClass(name) as! AnyClass? - - name.deinitialize(count: length + 1) - name.deallocate(capacity: length + 1) - } - } - - if next.pointee != Code.nul { - // skip past any junk before the first flag - next = strchr(next, Int32(Code.comma)) - } - - let emptyString = UnsafeMutablePointer.allocate(capacity: 1) - emptyString.initialize(to: Code.nul) - defer { - emptyString.deinitialize() - emptyString.deallocate(capacity: 1) - } - - var isWeak = false - - while next.pointee == Code.comma { - let flag = next[1] - next += 2 - - switch flag { - case Code.nul: - break; - - case Code.Attribute.readonly: - break; - - case Code.Attribute.copy: - break; - - case Code.Attribute.retain: - break; - - case Code.Attribute.nonatomic: - break; - - case Code.Attribute.getter: - fallthrough - - case Code.Attribute.setter: - next = strchr(next, Int32(Code.comma)) ?? emptyString - - case Code.Attribute.dynamic: - break - - case Code.Attribute.ivar: - // assume that the rest of the string (if present) is the ivar name - if next.pointee != Code.nul { - next = emptyString - } - - case Code.Attribute.weak: - isWeak = true - - case Code.Attribute.collectable: - break - - case Code.Attribute.oldTypeEncoding: - let string = String(validatingUTF8: attrString) - assertionFailure("Old-style type encoding is unsupported in attribute string \"\(string)\"") - - // skip over this type encoding - while next.pointee != Code.comma && next.pointee != Code.nul { - next += 1 - } - - default: - let pointer = UnsafeMutablePointer.allocate(capacity: 2) - pointer.initialize(to: flag) - (pointer + 1).initialize(to: Code.nul) - - let flag = String(validatingUTF8: pointer) - let string = String(validatingUTF8: attrString) - preconditionFailure("ERROR: Unrecognized attribute string flag '\(flag)' in attribute string \"\(string)\".") - } - } - - if next.pointee != Code.nul { - let unparsedData = String(validatingUTF8: next) - let string = String(validatingUTF8: attrString) - assertionFailure("Warning: Unparsed data \"\(unparsedData)\" in attribute string \"\(string)\".") - } - - self.objectClass = objectClass - self.isWeak = isWeak - self.isObject = typeString[0] == Code.ContainingType.object - self.isBlock = isObject && typeString[1] == Code.ContainingType.block - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Lifetime.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Lifetime.swift deleted file mode 100644 index 5311d03..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/NSObject+Lifetime.swift +++ /dev/null @@ -1,84 +0,0 @@ -import Foundation -import ReactiveSwift - -/// Holds the `Lifetime` of the object. -fileprivate let isSwizzledKey = AssociationKey(default: false) - -/// Holds the `Lifetime` of the object. -fileprivate let lifetimeKey = AssociationKey(default: nil) - -/// Holds the `Lifetime.Token` of the object. -fileprivate let lifetimeTokenKey = AssociationKey(default: nil) - -extension Reactive where Base: NSObject { - /// Returns a lifetime that ends when the object is deallocated. - @nonobjc public var lifetime: Lifetime { - return base.synchronized { - if let lifetime = base.associations.value(forKey: lifetimeKey) { - return lifetime - } - - let token = Lifetime.Token() - let lifetime = Lifetime(token) - - let objcClass: AnyClass = (base as AnyObject).objcClass - let objcClassAssociations = Associations(objcClass as AnyObject) - - let deallocSelector = sel_registerName("dealloc")! - - // Swizzle `-dealloc` so that the lifetime token is released at the - // beginning of the deallocation chain, and only after the KVO `-dealloc`. - synchronized(objcClass) { - // Swizzle the class only if it has not been swizzled before. - if !objcClassAssociations.value(forKey: isSwizzledKey) { - objcClassAssociations.setValue(true, forKey: isSwizzledKey) - - var existingImpl: IMP? = nil - - let newImplBlock: @convention(block) (UnsafeRawPointer) -> Void = { objectRef in - // A custom trampoline of `objc_setAssociatedObject` is used, since - // the imported version has been inserted with ARC calls that would - // mess with the object deallocation chain. - - // Release the lifetime token. - unsafeSetAssociatedValue(nil, forKey: lifetimeTokenKey, forObjectAt: objectRef) - - let impl: IMP - - // Call the existing implementation if one has been caught. Otherwise, - // call the one first available in the superclass hierarchy. - if let existingImpl = existingImpl { - impl = existingImpl - } else { - let superclass: AnyClass = class_getSuperclass(objcClass) - impl = class_getMethodImplementation(superclass, deallocSelector) - } - - typealias Impl = @convention(c) (UnsafeRawPointer, Selector) -> Void - unsafeBitCast(impl, to: Impl.self)(objectRef, deallocSelector) - } - - let newImpl = imp_implementationWithBlock(newImplBlock as Any) - - if !class_addMethod(objcClass, deallocSelector, newImpl, "v@:") { - // The class has an existing `dealloc`. Preserve that as `existingImpl`. - let deallocMethod = class_getInstanceMethod(objcClass, deallocSelector) - - // Store the existing implementation to `existingImpl` to ensure it is - // available before our version is swapped in. - existingImpl = method_getImplementation(deallocMethod) - - // Store the swapped-out implementation to `existingImpl` in case - // the implementation has been changed concurrently. - existingImpl = method_setImplementation(deallocMethod, newImpl) - } - } - } - - base.associations.setValue(token, forKey: lifetimeTokenKey) - base.associations.setValue(lifetime, forKey: lifetimeKey) - - return lifetime - } - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+Runtime.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+Runtime.swift deleted file mode 100644 index 63a9117..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+Runtime.swift +++ /dev/null @@ -1,24 +0,0 @@ -/// Search in `class` for any method that matches the supplied selector without -/// propagating to the ancestors. -/// -/// - parameters: -/// - class: The class to search the method in. -/// - selector: The selector of the method. -/// -/// - returns: -/// The matching method, or `nil` if none is found. -internal func class_getImmediateMethod(_ `class`: AnyClass, _ selector: Selector) -> Method? { - if let buffer = class_copyMethodList(`class`, nil) { - defer { free(buffer) } - - var iterator = buffer - while let method = iterator.pointee { - if method_getName(method) == selector { - return method - } - iterator = iterator.advanced(by: 1) - } - } - - return nil -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+RuntimeSubclassing.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+RuntimeSubclassing.swift deleted file mode 100644 index 0b8caa4..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+RuntimeSubclassing.swift +++ /dev/null @@ -1,85 +0,0 @@ -import ReactiveSwift - -/// Whether the runtime subclass has already been swizzled. -fileprivate let runtimeSubclassedKey = AssociationKey(default: false) - -/// A known RAC runtime subclass of the instance. `nil` if the runtime subclass -/// has not been requested for the instance before. -fileprivate let knownRuntimeSubclassKey = AssociationKey(default: nil) - -/// ISA-swizzle the class of the supplied instance. -/// -/// - note: If the instance has already been isa-swizzled, the swizzling happens -/// in place in the runtime subclass created by external parties. -/// -/// - parameters: -/// - instance: The instance to be swizzled. -/// -/// - returns: -/// The runtime subclass of the perceived class of the instance. -internal func swizzleClass(_ instance: NSObject) -> AnyClass { - if let knownSubclass = instance.associations.value(forKey: knownRuntimeSubclassKey) { - return knownSubclass - } - - let perceivedClass: AnyClass = instance.objcClass - let realClass: AnyClass = object_getClass(instance)! - let realClassAssociations = Associations(realClass as AnyObject) - - if perceivedClass != realClass { - // If the class is already lying about what it is, it's probably a KVO - // dynamic subclass or something else that we shouldn't subclass at runtime. - synchronized(realClass) { - let isSwizzled = realClassAssociations.value(forKey: runtimeSubclassedKey) - if !isSwizzled { - replaceGetClass(in: realClass, decoy: perceivedClass) - realClassAssociations.setValue(true, forKey: runtimeSubclassedKey) - } - } - - return realClass - } else { - let name = subclassName(of: perceivedClass) - let subclass: AnyClass = name.withCString { cString in - if let existingClass = objc_getClass(cString) as! AnyClass? { - return existingClass - } else { - let subclass: AnyClass = objc_allocateClassPair(perceivedClass, cString, 0)! - replaceGetClass(in: subclass, decoy: perceivedClass) - objc_registerClassPair(subclass) - return subclass - } - } - - object_setClass(instance, subclass) - instance.associations.setValue(subclass, forKey: knownRuntimeSubclassKey) - return subclass - } -} - -private func subclassName(of class: AnyClass) -> String { - return String(cString: class_getName(`class`)).appending("_RACSwift") -} - -/// Swizzle the `-class` and `+class` methods. -/// -/// - parameters: -/// - class: The class to swizzle. -/// - perceivedClass: The class to be reported by the methods. -private func replaceGetClass(in class: AnyClass, decoy perceivedClass: AnyClass) { - let getClass: @convention(block) (Any) -> AnyClass = { _ in - return perceivedClass - } - - let impl = imp_implementationWithBlock(getClass as Any) - - _ = class_replaceMethod(`class`, - ObjCSelector.getClass, - impl, - ObjCMethodEncoding.getClass) - - _ = class_replaceMethod(object_getClass(`class`), - ObjCSelector.getClass, - impl, - ObjCMethodEncoding.getClass) -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+Selector.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+Selector.swift deleted file mode 100644 index a6dd4fe..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/ObjC+Selector.swift +++ /dev/null @@ -1,38 +0,0 @@ -extension Selector { - /// `self` as a pointer. It is uniqued across instances, similar to - /// `StaticString`. - internal var utf8Start: UnsafePointer { - return unsafeBitCast(self, to: UnsafePointer.self) - } - - /// An alias of `self`, used in method interception. - internal var alias: Selector { - return prefixing("rac0_") - } - - /// An alias of `self`, used in method interception specifically for - /// preserving (if found) an immediate implementation of `self` in the - /// runtime subclass. - internal var interopAlias: Selector { - return prefixing("rac1_") - } - - internal func prefixing(_ prefix: StaticString) -> Selector { - let length = Int(strlen(utf8Start)) - let prefixedLength = length + prefix.utf8CodeUnitCount - - let asciiPrefix = UnsafeRawPointer(prefix.utf8Start).assumingMemoryBound(to: Int8.self) - - let cString = UnsafeMutablePointer.allocate(capacity: prefixedLength + 1) - defer { - cString.deinitialize() - cString.deallocate(capacity: prefixedLength + 1) - } - - cString.initialize(from: asciiPrefix, count: prefix.utf8CodeUnitCount) - (cString + prefix.utf8CodeUnitCount).initialize(from: utf8Start, count: length) - (cString + prefixedLength).initialize(to: Int8(UInt8(ascii: "\0"))) - - return sel_registerName(cString) - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UIControl.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UIControl.swift deleted file mode 100644 index 403247e..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UIControl.swift +++ /dev/null @@ -1,87 +0,0 @@ -import ReactiveSwift -import UIKit -import enum Result.NoError - -extension Reactive where Base: UIControl { - /// The current associated action of `self`, with its registered event mask - /// and its disposable. - internal var associatedAction: Atomic<(action: CocoaAction, controlEvents: UIControlEvents, disposable: Disposable)?> { - return associatedValue { _ in Atomic(nil) } - } - - /// Set the associated action of `self` to `action`, and register it for the - /// control events specified by `controlEvents`. - /// - /// - parameters: - /// - action: The action to be associated. - /// - controlEvents: The control event mask. - /// - disposable: An outside disposable that will be bound to the scope of - /// the given `action`. - internal func setAction(_ action: CocoaAction?, for controlEvents: UIControlEvents, disposable: Disposable? = nil) { - associatedAction.modify { associatedAction in - associatedAction?.disposable.dispose() - - if let action = action { - base.addTarget(action, action: CocoaAction.selector, for: controlEvents) - - let compositeDisposable = CompositeDisposable() - compositeDisposable += isEnabled <~ action.isEnabled - compositeDisposable += { [weak base = self.base] in - base?.removeTarget(action, action: CocoaAction.selector, for: controlEvents) - } - compositeDisposable += disposable - - associatedAction = (action, controlEvents, ScopedDisposable(compositeDisposable)) - } else { - associatedAction = nil - } - } - } - - /// Create a signal which sends a `value` event for each of the specified - /// control events. - /// - /// - parameters: - /// - controlEvents: The control event mask. - /// - /// - returns: - /// A signal that sends the control each time the control event occurs. - public func controlEvents(_ controlEvents: UIControlEvents) -> Signal { - return Signal { observer in - let receiver = CocoaTarget(observer) { $0 as! Base } - base.addTarget(receiver, - action: #selector(receiver.sendNext), - for: controlEvents) - - let disposable = lifetime.ended.observeCompleted(observer.sendCompleted) - - return ActionDisposable { [weak base = self.base] in - disposable?.dispose() - - base?.removeTarget(receiver, - action: #selector(receiver.sendNext), - for: controlEvents) - } - } - } - - @available(*, unavailable, renamed: "controlEvents(_:)") - public func trigger(for controlEvents: UIControlEvents) -> Signal<(), NoError> { - fatalError() - } - - /// Sets whether the control is enabled. - public var isEnabled: BindingTarget { - return makeBindingTarget { $0.isEnabled = $1 } - } - - /// Sets whether the control is selected. - public var isSelected: BindingTarget { - return makeBindingTarget { $0.isSelected = $1 } - } - - /// Sets whether the control is highlighted. - public var isHighlighted: BindingTarget { - return makeBindingTarget { $0.isHighlighted = $1 } - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UIGestureRecognizer.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UIGestureRecognizer.swift deleted file mode 100644 index 6ffc5a8..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UIGestureRecognizer.swift +++ /dev/null @@ -1,25 +0,0 @@ -import ReactiveSwift -import UIKit -import enum Result.NoError - -extension Reactive where Base: UIGestureRecognizer { - /// Create a signal which sends a `next` event for each gesture event - /// - /// - returns: - /// A trigger signal. - public var stateChanged: Signal { - return Signal { observer in - let receiver = CocoaTarget(observer) { gestureRecognizer in - return gestureRecognizer as! Base - } - base.addTarget(receiver, action: #selector(receiver.sendNext)) - - let disposable = lifetime.ended.observeCompleted(observer.sendCompleted) - - return ActionDisposable { [weak base = self.base] in - disposable?.dispose() - base?.removeTarget(receiver, action: #selector(receiver.sendNext)) - } - } - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UITextField.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UITextField.swift deleted file mode 100644 index ca575a5..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/UITextField.swift +++ /dev/null @@ -1,50 +0,0 @@ -import ReactiveSwift -import enum Result.NoError -import UIKit - -extension Reactive where Base: UITextField { - /// Sets the text of the text field. - public var text: BindingTarget { - return makeBindingTarget { $0.text = $1 } - } - - /// A signal of text values emitted by the text field upon end of editing. - /// - /// - note: To observe text values that change on all editing events, - /// see `continuousTextValues`. - public var textValues: Signal { - return controlEvents(.editingDidEnd).map { $0.text } - } - - /// A signal of text values emitted by the text field upon any changes. - /// - /// - note: To observe text values only when editing ends, see `textValues`. - public var continuousTextValues: Signal { - return controlEvents(.editingChanged).map { $0.text } - } - - /// Sets the attributed text of the text field. - public var attributedText: BindingTarget { - return makeBindingTarget { $0.attributedText = $1 } - } - - /// A signal of attributed text values emitted by the text field upon end of editing. - /// - /// - note: To observe attributed text values that change on all editing events, - /// see `continuousAttributedTextValues`. - public var attributedTextValues: Signal { - return controlEvents(.editingDidEnd).map { $0.attributedText } - } - - /// A signal of attributed text values emitted by the text field upon any changes. - /// - /// - note: To observe attributed text values only when editing ends, see `attributedTextValues`. - public var continuousAttributedTextValues: Signal { - return controlEvents(.editingChanged).map { $0.attributedText } - } - - /// Sets the secure text entry attribute on the text field. - public var isSecureTextEntry: BindingTarget { - return makeBindingTarget { $0.isSecureTextEntry = $1 } - } -} diff --git a/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UIPickerView.swift b/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UIPickerView.swift deleted file mode 100644 index 2e792d2..0000000 --- a/Example/Pods/ReactiveCocoa/ReactiveCocoa/UIKit/iOS/UIPickerView.swift +++ /dev/null @@ -1,43 +0,0 @@ -import ReactiveSwift -import enum Result.NoError -import UIKit - -private class PickerViewDelegateProxy: DelegateProxy, UIPickerViewDelegate { - @objc func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { - forwardee?.pickerView?(pickerView, didSelectRow: row, inComponent: component) - } -} - -extension Reactive where Base: UIPickerView { - - private var proxy: PickerViewDelegateProxy { - return .proxy(for: base, - setter: #selector(setter: base.delegate), - getter: #selector(getter: base.delegate)) - } - - /// Sets the selected row in the specified component, without animating the - /// position. - public func selectedRow(inComponent component: Int) -> BindingTarget { - return makeBindingTarget { $0.selectRow($1, inComponent: component, animated: false) } - } - - /// Reloads all components - public var reloadAllComponents: BindingTarget<()> { - return makeBindingTarget { base, _ in base.reloadAllComponents() } - } - - /// Reloads the specified component - public var reloadComponent: BindingTarget { - return makeBindingTarget { $0.reloadComponent($1) } - } - - /// Create a signal which sends a `value` event for each row selection - /// - /// - returns: - /// A trigger signal. - public var selections: Signal<(row: Int, component: Int), NoError> { - return proxy.intercept(#selector(UIPickerViewDelegate.pickerView(_:didSelectRow:inComponent:))) - .map { (row: $0[1] as! Int, component: $0[2] as! Int) } - } -} diff --git a/Example/Pods/ReactiveSwift/README.md b/Example/Pods/ReactiveSwift/README.md deleted file mode 100644 index be5da6d..0000000 --- a/Example/Pods/ReactiveSwift/README.md +++ /dev/null @@ -1,492 +0,0 @@ -

- ReactiveSwift

- Streams of values over time. Tailored for Swift.

- Latest ReactiveSwift Documentation Join the ReactiveSwift Slack community. -

-
-[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](#carthage) [![CocoaPods compatible](https://img.shields.io/cocoapods/v/ReactiveSwift.svg)](#cocoapods) [![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-orange.svg)](#swift-package-manager) [![GitHub release](https://img.shields.io/github/release/ReactiveCocoa/ReactiveSwift.svg)](https://github.com/ReactiveCocoa/ReactiveSwift/releases) ![Swift 3.0.x](https://img.shields.io/badge/Swift-3.0.x-orange.svg) ![platforms](https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-lightgrey.svg) - -☕️ [Looking for Cocoa extensions?][ReactiveCocoa] -🎉 [Getting Started](#getting-started) -⚠️ [Still using Swift 2.x?][] - - -🚄 [Release Roadmap](#release-roadmap) -## What is ReactiveSwift? -__ReactiveSwift__ offers composable, declarative and flexible primitives that are built around the grand concept of ___streams of values over time___. - -These primitives can be used to uniformly represent common Cocoa and generic programming patterns that are fundamentally an act of observation, e.g. delegate pattern, callback closures, notifications, control actions, responder chain events, [futures/promises](https://en.wikipedia.org/wiki/Futures_and_promises) and [key-value observing](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html) (KVO). - -Because all of these different mechanisms can be represented in the _same_ way, -it’s easy to declaratively compose them together, with less spaghetti -code and state to bridge the gap. - -### Core Reactive Primitives -#### `Signal`: a unidirectional stream of events. -The owner of a `Signal` has unilateral control of the event stream. Observers may register their interests in the future events at any time, but the observation would have no side effect on the stream or its owner. - -It is like a live TV feed — you can observe and react to the content, but you cannot have a side effect on the live feed or the TV station. - -```swift -let channel: Signal = tvStation.channelOne -channel.observeValues { program in ... } -``` - -#### `Event`: the basic transfer unit of an event stream. -A `Signal` may have any arbitrary number of events carrying a value, following by an eventual terminal event of a specific reason. - -It is like a frame in a one-time live feed — seas of data frames carry the visual and audio data, but the feed would eventually be terminated with a special frame to indicate "end of stream". - -#### `SignalProducer`: deferred work that creates a stream of values. -`SignalProducer` defers work — of which the output is represented as a stream of values — until it is started. For every invocation to start the `SignalProducer`, a new `Signal` is created and the deferred work is subsequently invoked. - -It is like a on-demand streaming service — even though the episode is streamed like a live TV feed, you can choose what you watch, when to start watching and when to interrupt it. - - -```swift -let frames: SignalProducer = vidStreamer.streamAsset(id: tvShowId) -let interrupter = frames.start { frame in ... } -interrupter.dispose() -``` - -#### `Lifetime`: limits the scope of an observation -When observing a `Signal` or `SignalProducer`, it doesn't make sense to continue emitting values if there's no longer anyone observing them. -Consider the video stream: once you stop watching the video, the stream can be automatically closed by providing a `Lifetime`: - -```swift -class VideoPlayer { - private let (lifetime, token) = Lifetime.make() - - func play() { - let frames: SignalProducer = ... - frames.take(during: lifetime).start { frame in ... } - } -} -``` - -#### `Property`: an observable box that always holds a value. -`Property` is a variable that can be observed for its changes. In other words, it is a stream of values with a stronger guarantee than `Signal` — the latest value is always available, and the stream would never fail. - -It is like the continuously updated current time offset of a video playback — the playback is always at a certain time offset at any time, and it would be updated by the playback logic as the playback continues. - -```swift -let currentTime: Property = video.currentTime -print("Current time offset: \(currentTime.value)") -currentTime.signal.observeValues { timeBar.timeLabel.text = "\($0)" } -``` - -#### `Action`: a serialized worker with a preset action. -When being invoked with an input, `Action` apply the input and the latest state to the preset action, and pushes the output to any interested parties. - -It is like an automatic vending machine — after choosing an option with coins inserted, the machine would process the order and eventually output your wanted snack. Notice that the entire process is mutually exclusive — you cannot have the machine to serve two customers concurrently. - -```swift -// Purchase from the vending machine with a specific option. -vendingMachine.purchase - .apply(snackId) - .startWithResult { result - switch result { - case let .success(snack): - print("Snack: \(snack)") - - case let .failure(error): - // Out of stock? Insufficient fund? - print("Transaction aborted: \(error)") - } - } - -// The vending machine. -class VendingMachine { - let purchase: Action - let coins: MutableProperty - - // The vending machine is connected with a sales recorder. - init(_ salesRecorder: SalesRecorder) { - coins = MutableProperty(0) - purchase = Action(state: coins, enabledIf: { $0 > 0 }) { coins, snackId in - return SignalProducer { observer, _ in - // The sales magic happens here. - // Fetch a snack based on its id - } - } - - // The sales recorders are notified for any successful sales. - purchase.values.observeValues(salesRecorder.record) - } -} -``` - -#### References - -For more details about the concepts and primitives in ReactiveSwift, check these documentations out: - -1. **[Framework Overview][]** - - An overview of the behaviors and the suggested use cases of the ReactiveSwift primitives and utilities. - -1. **[Basic Operators][]** - - An overview of the operators provided to compose and transform these primitives. - -1. **[Design Guidelines][]** - - Contracts of the ReactiveSwift primitives, Best Practices with ReactiveSwift, and Guidelines on implementing custom operators. - -## Example: online search - -Let’s say you have a text field, and whenever the user types something into it, -you want to make a network request which searches for that query. - -_Please note that the following examples use Cocoa extensions in [ReactiveCocoa][] for illustration._ - -#### Observing text edits - -The first step is to observe edits to the text field, using a RAC extension to -`UITextField` specifically for this purpose: - -```swift -let searchStrings = textField.reactive.continuousTextValues -``` - -This gives us a [Signal][] which sends values of type `String?`. - -#### Making network requests - -With each string, we want to execute a network request. ReactiveSwift offers an -`URLSession` extension for doing exactly that: - -```swift -let searchResults = searchStrings - .flatMap(.latest) { (query: String?) -> SignalProducer<(Data, URLResponse), AnyError> in - let request = self.makeSearchRequest(escapedQuery: query) - return URLSession.shared.reactive.data(with: request) - } - .map { (data, response) -> [SearchResult] in - let string = String(data: data, encoding: .utf8)! - return self.searchResults(fromJSONString: string) - } - .observe(on: UIScheduler()) -``` - -This has transformed our producer of `String`s into a producer of `Array`s -containing the search results, which will be forwarded on the main thread -(using the [`UIScheduler`][Schedulers]). - -Additionally, [`flatMap(.latest)`][flatMapLatest] here ensures that _only one search_—the -latest—is allowed to be running. If the user types another character while the -network request is still in flight, it will be cancelled before starting a new -one. Just think of how much code that would take to do by hand! - -#### Receiving the results - -Since the source of search strings is a `Signal` which has a hot signal semantic, -the transformations we applied are automatically evaluated whenever new values are -emitted from `searchStrings`. - -Therefore, we can simply observe the signal using `Signal.observe(_:)`: - -```swift -searchResults.observe { event in - switch event { - case let .value(results): - print("Search results: \(results)") - - case let .failed(error): - print("Search error: \(error)") - - case .completed, .interrupted: - break - } -} -``` - -Here, we watch for the `Value` [event][Events], which contains our results, and -just log them to the console. This could easily do something else instead, like -update a table view or a label on screen. - -#### Handling failures - -In this example so far, any network error will generate a `Failed` -[event][Events], which will terminate the event stream. Unfortunately, this -means that future queries won’t even be attempted. - -To remedy this, we need to decide what to do with failures that occur. The -quickest solution would be to log them, then ignore them: - -```swift - .flatMap(.latest) { (query: String) -> SignalProducer<(Data, URLResponse), AnyError> in - let request = self.makeSearchRequest(escapedQuery: query) - - return URLSession.shared.reactive - .data(with: request) - .flatMapError { error in - print("Network error occurred: \(error)") - return SignalProducer.empty - } - } -``` - -By replacing failures with the `empty` event stream, we’re able to effectively -ignore them. - -However, it’s probably more appropriate to retry at least a couple of times -before giving up. Conveniently, there’s a [`retry`][retry] operator to do exactly that! - -Our improved `searchResults` producer might look like this: - -```swift -let searchResults = searchStrings - .flatMap(.latest) { (query: String) -> SignalProducer<(Data, URLResponse), AnyError> in - let request = self.makeSearchRequest(escapedQuery: query) - - return URLSession.shared.reactive - .data(with: request) - .retry(upTo: 2) - .flatMapError { error in - print("Network error occurred: \(error)") - return SignalProducer.empty - } - } - .map { (data, response) -> [SearchResult] in - let string = String(data: data, encoding: .utf8)! - return self.searchResults(fromJSONString: string) - } - .observe(on: UIScheduler()) -``` - -#### Throttling requests - -Now, let’s say you only want to actually perform the search periodically, -to minimize traffic. - -ReactiveCocoa has a declarative `throttle` operator that we can apply to our -search strings: - -```swift -let searchStrings = textField.reactive.continuousTextValues - .throttle(0.5, on: QueueScheduler.main) -``` - -This prevents values from being sent less than 0.5 seconds apart. - -To do this manually would require significant state, and end up much harder to -read! With ReactiveCocoa, we can use just one operator to incorporate _time_ into -our event stream. - -#### Debugging event streams - -Due to its nature, a stream's stack trace might have dozens of frames, which, more often than not, can make debugging a very frustrating activity. -A naive way of debugging, is by injecting side effects into the stream, like so: - -```swift -let searchString = textField.reactive.continuousTextValues - .throttle(0.5, on: QueueScheduler.main) - .on(event: { print ($0) }) // the side effect -``` - -This will print the stream's [events][Events], while preserving the original stream behaviour. Both [`SignalProducer`][SignalProducer] -and [`Signal`][Signal] provide the `logEvents` operator, that will do this automatically for you: - -```swift -let searchString = textField.reactive.continuousTextValues - .throttle(0.5, on: QueueScheduler.main) - .logEvents() -``` - -For more information and advance usage, check the [Debugging Techniques](Documentation/DebuggingTechniques.md) document. - -## How does ReactiveSwift relate to RxSwift? -RxSwift is a Swift implementation of the [ReactiveX][] (Rx) APIs. While ReactiveCocoa -was inspired and heavily influenced by Rx, ReactiveSwift is an opinionated -implementation of [functional reactive programming][], and _intentionally_ not a -direct port like [RxSwift][]. - -ReactiveSwift differs from RxSwift/ReactiveX where doing so: - - * Results in a simpler API - * Addresses common sources of confusion - * Matches closely to Swift, and sometimes Cocoa, conventions - -The following are a few important differences, along with their rationales. - -### Signals and SignalProducers (“hot” and “cold” observables) - -One of the most confusing aspects of Rx is that of [“hot”, “cold”, and “warm” -observables](http://www.introtorx.com/content/v1.0.10621.0/14_HotAndColdObservables.html) (event streams). - -In short, given just a method or function declaration like this, in C#: - -```csharp -IObservable Search(string query) -``` - -… it is **impossible to tell** whether subscribing to (observing) that -`IObservable` will involve side effects. If it _does_ involve side effects, it’s -also impossible to tell whether _each subscription_ has a side effect, or if only -the first one does. - -This example is contrived, but it demonstrates **a real, pervasive problem** -that makes it extremely hard to understand Rx code (and pre-3.0 ReactiveCocoa -code) at a glance. - -**ReactiveSwift** addresses this by distinguishing side effects with the separate -[`Signal`][Signal] and [`SignalProducer`][SignalProducer] types. Although this -means there’s another type to learn about, it improves code clarity and helps -communicate intent much better. - -In other words, **ReactiveSwift’s changes here are [simple, not -easy](http://www.infoq.com/presentations/Simple-Made-Easy)**. - -### Typed errors - -When [Signals][Signal] and [SignalProducers][SignalProducer] are allowed to [fail][Events] in ReactiveSwift, -the kind of error must be specified in the type system. For example, -`Signal` is a signal of integer values that may fail with an error -of type `AnyError`. - -More importantly, RAC allows the special type `NoError` to be used instead, -which _statically guarantees_ that an event stream is not allowed to send a -failure. **This eliminates many bugs caused by unexpected failure events.** - -In Rx systems with types, event streams only specify the type of their -values—not the type of their errors—so this sort of guarantee is impossible. - -### Naming - -In most versions of Rx, Streams over time are known as `Observable`s, which -parallels the `Enumerable` type in .NET. Additionally, most operations in Rx.NET -borrow names from [LINQ](https://msdn.microsoft.com/en-us/library/bb397926.aspx), -which uses terms reminiscent of relational databases, like `Select` and `Where`. - -**ReactiveSwift**, on the other hand, focuses on being a native Swift citizen -first and foremost, following the [Swift API Guidelines][] as appropriate. Other -naming differences are typically inspired by significantly better alternatives -from [Haskell](https://www.haskell.org) or [Elm](http://elm-lang.org) (which is the primary source for the “signal” terminology). - -### UI programming - -Rx is basically agnostic as to how it’s used. Although UI programming with Rx is -very common, it has few features tailored to that particular case. - -ReactiveSwift takes a lot of inspiration from [ReactiveUI](http://reactiveui.net/), -including the basis for [Actions][]. - -Unlike ReactiveUI, which unfortunately cannot directly change Rx to make it more -friendly for UI programming, **ReactiveSwift has been improved many times -specifically for this purpose**—even when it means diverging further from Rx. - -## Getting started - -ReactiveSwift supports macOS 10.9+, iOS 8.0+, watchOS 2.0+, tvOS 9.0+ and Linux. - -#### Carthage - -If you use [Carthage][] to manage your dependencies, simply add -ReactiveSwift to your `Cartfile`: - -``` -github "ReactiveCocoa/ReactiveSwift" ~> 1.1 -``` - -If you use Carthage to build your dependencies, make sure you have added `ReactiveSwift.framework`, and `Result.framework` to the "_Linked Frameworks and Libraries_" section of your target, and have included them in your Carthage framework copying build phase. - -#### CocoaPods - -If you use [CocoaPods][] to manage your dependencies, simply add -ReactiveSwift to your `Podfile`: - -``` -pod 'ReactiveSwift', '~> 1.1' -``` - -#### Swift Package Manager - -If you use Swift Package Manager, simply add ReactiveSwift as a dependency -of your package in `Package.swift`: - -``` -.Package(url: "https://github.com/ReactiveCocoa/ReactiveSwift.git", majorVersion: 1) -``` - -#### Git submodule - - 1. Add the ReactiveSwift repository as a [submodule][] of your - application’s repository. - 1. Run `git submodule update --init --recursive` from within the ReactiveCocoa folder. - 1. Drag and drop `ReactiveSwift.xcodeproj` and - `Carthage/Checkouts/Result/Result.xcodeproj` into your application’s Xcode - project or workspace. - 1. On the “General” tab of your application target’s settings, add - `ReactiveSwift.framework`, and `Result.framework` - to the “Embedded Binaries” section. - 1. If your application target does not contain Swift code at all, you should also - set the `EMBEDDED_CONTENT_CONTAINS_SWIFT` build setting to “Yes”. - -## Playground - -We also provide a great Playground, so you can get used to ReactiveCocoa's operators. In order to start using it: - - 1. Clone the ReactiveSwift repository. - 1. Retrieve the project dependencies using one of the following terminal commands from the ReactiveSwift project root directory: - - `git submodule update --init --recursive` **OR**, if you have [Carthage][] installed - - `carthage checkout` - 1. Open `ReactiveSwift.xcworkspace` - 1. Build `Result-Mac` scheme - 1. Build `ReactiveSwift-macOS` scheme - 1. Finally open the `ReactiveSwift.playground` - 1. Choose `View > Show Debug Area` - -## Have a question? -If you need any help, please visit our [GitHub issues][] or [Stack Overflow][]. Feel free to file an issue if you do not manage to find any solution from the archives. - -## Release Roadmap -**Current Stable Release:**
[![GitHub release](https://img.shields.io/github/release/ReactiveCocoa/ReactiveSwift.svg)](https://github.com/ReactiveCocoa/ReactiveSwift/releases) - -### Plan of Record -#### ReactiveSwift 2.0 -It targets Swift 3.1.x. The estimated schedule is Spring 2017. - -The release contains breaking changes. But they are not expected to affect the general mass of users, but only a few specific use cases. - -The primary goal of ReactiveSwift 2.0 is to adopt **concrete same-type requirements**, and remove as many single-implementation protocols as possible. - -ReactiveSwift 2.0 may include other proposed breaking changes. - -As Swift 4.0 introduces library evolution and resilience, it is important for us to have a clean and steady API to start with. The expectation is to **have the API cleanup and the reviewing to be concluded in ReactiveSwift 2.0**, before we move on to ReactiveSwift 3.0 and Swift 4.0. Any contribution to help realising this goal is welcomed. - -#### ReactiveSwift 3.0 -It targets Swift 4.0.x. The estimated schedule is late 2017. - -The release may contain breaking changes, depending on what features are being delivered by Swift 4.0. - -ReactiveSwift 3.0 would focus on two main goals: - -1. Swift 4.0 Library Evolution and Resilience -2. Adapt to new features introduced in Swift 4.0 Phase 2. - -[ReactiveCocoa]: https://github.com/ReactiveCocoa/ReactiveCocoa/#readme -[Actions]: Documentation/FrameworkOverview.md#actions -[Basic Operators]: Documentation/BasicOperators.md -[Design Guidelines]: Documentation/DesignGuidelines.md -[Carthage]: https://github.com/Carthage/Carthage/#readme -[CocoaPods]: https://cocoapods.org/ -[CHANGELOG]: CHANGELOG.md -[Code]: Sources -[Documentation]: Documentation -[Events]: Documentation/FrameworkOverview.md#events -[Framework Overview]: Documentation/FrameworkOverview.md -[Schedulers]: Documentation/FrameworkOverview.md#schedulers -[SignalProducer]: Documentation/FrameworkOverview.md#signal-producers -[Signal]: Documentation/FrameworkOverview.md#signals -[Swift API]: ReactiveCocoa/Swift -[flatMapLatest]: Documentation/BasicOperators.md#switching-to-the-latest -[retry]: Documentation/BasicOperators.md#retrying -[Looking for the Objective-C API?]: https://github.com/ReactiveCocoa/ReactiveObjC/#readme -[Still using Swift 2.x?]: https://github.com/ReactiveCocoa/ReactiveCocoa/tree/v4.0.0 -[GitHub issues]: https://github.com/ReactiveCocoa/ReactiveSwift/issues?q=is%3Aissue+label%3Aquestion+ -[Stack Overflow]: http://stackoverflow.com/questions/tagged/reactive-cocoa -[submodule]: https://git-scm.com/docs/git-submodule -[functional reactive programming]: https://en.wikipedia.org/wiki/Functional_reactive_programming -[ReactiveX]: https://reactivex.io/ -[RxSwift]: https://github.com/ReactiveX/RxSwift/#readme -[Swift API Guidelines]: https://swift.org/documentation/api-design-guidelines/ diff --git a/Example/Pods/ReactiveSwift/Sources/Action.swift b/Example/Pods/ReactiveSwift/Sources/Action.swift deleted file mode 100644 index 5095155..0000000 --- a/Example/Pods/ReactiveSwift/Sources/Action.swift +++ /dev/null @@ -1,325 +0,0 @@ -import Dispatch -import Foundation -import Result - -/// Represents an action that will do some work when executed with a value of -/// type `Input`, then return zero or more values of type `Output` and/or fail -/// with an error of type `Error`. If no failure should be possible, NoError can -/// be specified for the `Error` parameter. -/// -/// Actions enforce serial execution. Any attempt to execute an action multiple -/// times concurrently will return an error. -public final class Action { - private let deinitToken: Lifetime.Token - - private let executeClosure: (_ state: Any, _ input: Input) -> SignalProducer - private let eventsObserver: Signal, NoError>.Observer - private let disabledErrorsObserver: Signal<(), NoError>.Observer - - /// The lifetime of the Action. - public let lifetime: Lifetime - - /// A signal of all events generated from applications of the Action. - /// - /// In other words, this will send every `Event` from every signal generated - /// by each SignalProducer returned from apply() except `ActionError.disabled`. - public let events: Signal, NoError> - - /// A signal of all values generated from applications of the Action. - /// - /// In other words, this will send every value from every signal generated - /// by each SignalProducer returned from apply() except `ActionError.disabled`. - public let values: Signal - - /// A signal of all errors generated from applications of the Action. - /// - /// In other words, this will send errors from every signal generated by - /// each SignalProducer returned from apply() except `ActionError.disabled`. - public let errors: Signal - - /// A signal which is triggered by `ActionError.disabled`. - public let disabledErrors: Signal<(), NoError> - - /// A signal of all completed events generated from applications of the action. - /// - /// In other words, this will send completed events from every signal generated - /// by each SignalProducer returned from apply(). - public let completed: Signal<(), NoError> - - /// Whether the action is currently executing. - public let isExecuting: Property - - /// Whether the action is currently enabled. - public let isEnabled: Property - - private let state: MutableProperty - - /// Initializes an action that will be conditionally enabled based on the - /// value of `state`. Creates a `SignalProducer` for each input and the - /// current value of `state`. - /// - /// - note: `Action` guarantees that changes to `state` are observed in a - /// thread-safe way. Thus, the value passed to `isEnabled` will - /// always be identical to the value passed to `execute`, for each - /// application of the action. - /// - /// - note: This initializer should only be used if you need to provide - /// custom input can also influence whether the action is enabled. - /// The various convenience initializers should cover most use cases. - /// - /// - parameters: - /// - state: A property that provides the current state of the action - /// whenever `apply()` is called. - /// - enabledIf: A predicate that, given the current value of `state`, - /// returns whether the action should be enabled. - /// - execute: A closure that returns the `SignalProducer` returned by - /// calling `apply(Input)` on the action, optionally using - /// the current value of `state`. - public init(state property: State, enabledIf isEnabled: @escaping (State.Value) -> Bool, _ execute: @escaping (State.Value, Input) -> SignalProducer) { - deinitToken = Lifetime.Token() - lifetime = Lifetime(deinitToken) - - // Retain the `property` for the created `Action`. - lifetime.observeEnded { _ = property } - - executeClosure = { state, input in execute(state as! State.Value, input) } - - (events, eventsObserver) = Signal, NoError>.pipe() - (disabledErrors, disabledErrorsObserver) = Signal<(), NoError>.pipe() - - values = events.map { $0.value }.skipNil() - errors = events.map { $0.error }.skipNil() - completed = events.filter { $0.isCompleted }.map { _ in } - - let initial = ActionState(value: property.value, isEnabled: { isEnabled($0 as! State.Value) }) - state = MutableProperty(initial) - - property.signal - .take(during: state.lifetime) - .observeValues { [weak state] newValue in - state?.modify { - $0.value = newValue - } - } - - self.isEnabled = state.map { $0.isEnabled }.skipRepeats() - self.isExecuting = state.map { $0.isExecuting }.skipRepeats() - } - - /// Initializes an action that will be conditionally enabled, and creates a - /// `SignalProducer` for each input. - /// - /// - parameters: - /// - enabledIf: Boolean property that shows whether the action is - /// enabled. - /// - execute: A closure that returns the signal producer returned by - /// calling `apply(Input)` on the action. - public convenience init(enabledIf property: P, _ execute: @escaping (Input) -> SignalProducer) where P.Value == Bool { - self.init(state: property, enabledIf: { $0 }) { _, input in - execute(input) - } - } - - /// Initializes an action that will be enabled by default, and creates a - /// SignalProducer for each input. - /// - /// - parameters: - /// - execute: A closure that returns the signal producer returned by - /// calling `apply(Input)` on the action. - public convenience init(_ execute: @escaping (Input) -> SignalProducer) { - self.init(enabledIf: Property(value: true), execute) - } - - deinit { - eventsObserver.sendCompleted() - disabledErrorsObserver.sendCompleted() - } - - /// Creates a SignalProducer that, when started, will execute the action - /// with the given input, then forward the results upon the produced Signal. - /// - /// - note: If the action is disabled when the returned SignalProducer is - /// started, the produced signal will send `ActionError.disabled`, - /// and nothing will be sent upon `values` or `errors` for that - /// particular signal. - /// - /// - parameters: - /// - input: A value that will be passed to the closure creating the signal - /// producer. - public func apply(_ input: Input) -> SignalProducer> { - return SignalProducer { observer, disposable in - let startingState = self.state.modify { state -> Any? in - if state.isEnabled { - state.isExecuting = true - return state.value - } else { - return nil - } - } - - guard let state = startingState else { - observer.send(error: .disabled) - self.disabledErrorsObserver.send(value: ()) - return - } - - self.executeClosure(state, input).startWithSignal { signal, signalDisposable in - disposable += signalDisposable - - signal.observe { event in - observer.action(event.mapError(ActionError.producerFailed)) - self.eventsObserver.send(value: event) - } - } - - disposable += { - self.state.modify { - $0.isExecuting = false - } - } - } - } -} - -private struct ActionState { - var isExecuting: Bool = false - - var value: Any { - didSet { - userEnabled = userEnabledClosure(value) - } - } - - private var userEnabled: Bool - private let userEnabledClosure: (Any) -> Bool - - init(value: Any, isEnabled: @escaping (Any) -> Bool) { - self.value = value - self.userEnabled = isEnabled(value) - self.userEnabledClosure = isEnabled - } - - /// Whether the action should be enabled for the given combination of user - /// enabledness and executing status. - fileprivate var isEnabled: Bool { - return userEnabled && !isExecuting - } -} - -/// A protocol used to constraint `Action` initializers. -@available(swift, deprecated: 3.1, message: "This protocol is no longer necessary and will be removed in a future version of ReactiveSwift. Use Action directly instead.") -public protocol ActionProtocol: BindingTargetProvider, BindingTargetProtocol { - /// The type of argument to apply the action to. - associatedtype Input - /// The type of values returned by the action. - associatedtype Output - /// The type of error when the action fails. If errors aren't possible then - /// `NoError` can be used. - associatedtype Error: Swift.Error - - /// Initializes an action that will be conditionally enabled based on the - /// value of `state`. Creates a `SignalProducer` for each input and the - /// current value of `state`. - /// - /// - note: `Action` guarantees that changes to `state` are observed in a - /// thread-safe way. Thus, the value passed to `isEnabled` will - /// always be identical to the value passed to `execute`, for each - /// application of the action. - /// - /// - note: This initializer should only be used if you need to provide - /// custom input can also influence whether the action is enabled. - /// The various convenience initializers should cover most use cases. - /// - /// - parameters: - /// - state: A property that provides the current state of the action - /// whenever `apply()` is called. - /// - enabledIf: A predicate that, given the current value of `state`, - /// returns whether the action should be enabled. - /// - execute: A closure that returns the `SignalProducer` returned by - /// calling `apply(Input)` on the action, optionally using - /// the current value of `state`. - init(state property: State, enabledIf isEnabled: @escaping (State.Value) -> Bool, _ execute: @escaping (State.Value, Input) -> SignalProducer) - - /// Whether the action is currently enabled. - var isEnabled: Property { get } - - /// Extracts an action from the receiver. - var action: Action { get } - - /// Creates a SignalProducer that, when started, will execute the action - /// with the given input, then forward the results upon the produced Signal. - /// - /// - note: If the action is disabled when the returned SignalProducer is - /// started, the produced signal will send `ActionError.disabled`, - /// and nothing will be sent upon `values` or `errors` for that - /// particular signal. - /// - /// - parameters: - /// - input: A value that will be passed to the closure creating the signal - /// producer. - func apply(_ input: Input) -> SignalProducer> -} - -extension Action: ActionProtocol { - public var action: Action { - return self - } - - public var bindingTarget: BindingTarget { - return BindingTarget(lifetime: lifetime) { [weak self] in self?.apply($0).start() } - } -} - -extension ActionProtocol where Input == Void { - /// Initializes an action that uses an `Optional` property for its input, - /// and is disabled whenever the input is `nil`. When executed, a `SignalProducer` - /// is created with the current value of the input. - /// - /// - parameters: - /// - input: An `Optional` property whose current value is used as input - /// whenever the action is executed. The action is disabled - /// whenever the value is `nil`. - /// - execute: A closure to return a new `SignalProducer` based on the - /// current value of `input`. - public init(input: P, _ execute: @escaping (T) -> SignalProducer) where P.Value == T? { - self.init(state: input, enabledIf: { $0 != nil }) { input, _ in - execute(input!) - } - } - - /// Initializes an action that uses a property for its input. When executed, - /// a `SignalProducer` is created with the current value of the input. - /// - /// - parameters: - /// - input: A property whose current value is used as input - /// whenever the action is executed. - /// - execute: A closure to return a new `SignalProducer` based on the - /// current value of `input`. - public init(input: P, _ execute: @escaping (T) -> SignalProducer) where P.Value == T { - self.init(input: input.map(Optional.some), execute) - } -} - -/// The type of error that can occur from Action.apply, where `Error` is the -/// type of error that can be generated by the specific Action instance. -public enum ActionError: Swift.Error { - /// The producer returned from apply() was started while the Action was - /// disabled. - case disabled - - /// The producer returned from apply() sent the given error. - case producerFailed(Error) -} - -public func == (lhs: ActionError, rhs: ActionError) -> Bool { - switch (lhs, rhs) { - case (.disabled, .disabled): - return true - - case let (.producerFailed(left), .producerFailed(right)): - return left == right - - default: - return false - } -} diff --git a/Example/Pods/ReactiveSwift/Sources/Atomic.swift b/Example/Pods/ReactiveSwift/Sources/Atomic.swift deleted file mode 100644 index 8a2be77..0000000 --- a/Example/Pods/ReactiveSwift/Sources/Atomic.swift +++ /dev/null @@ -1,298 +0,0 @@ -// -// Atomic.swift -// ReactiveSwift -// -// Created by Justin Spahr-Summers on 2014-06-10. -// Copyright (c) 2014 GitHub. All rights reserved. -// - -import Foundation -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) -import MachO -#endif - -/// Represents a finite state machine that can transit from one state to -/// another. -internal protocol AtomicStateProtocol { - associatedtype State: RawRepresentable - - /// Try to transition from the expected current state to the specified next - /// state. - /// - /// - parameters: - /// - expected: The expected state. - /// - /// - returns: - /// `true` if the transition succeeds. `false` otherwise. - func tryTransition(from expected: State, to next: State) -> Bool -} - -/// A simple, generic lock-free finite state machine. -/// -/// - warning: `deinitialize` must be called to dispose of the consumed memory. -internal struct UnsafeAtomicState: AtomicStateProtocol where State.RawValue == Int32 { - internal typealias Transition = (expected: State, next: State) -#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) - private let value: UnsafeMutablePointer - - /// Create a finite state machine with the specified initial state. - /// - /// - parameters: - /// - initial: The desired initial state. - internal init(_ initial: State) { - value = UnsafeMutablePointer.allocate(capacity: 1) - value.initialize(to: initial.rawValue) - } - - /// Deinitialize the finite state machine. - internal func deinitialize() { - value.deinitialize() - value.deallocate(capacity: 1) - } - - /// Compare the current state with the specified state. - /// - /// - parameters: - /// - expected: The expected state. - /// - /// - returns: - /// `true` if the current state matches the expected state. `false` - /// otherwise. - internal func `is`(_ expected: State) -> Bool { - return OSAtomicCompareAndSwap32Barrier(expected.rawValue, - expected.rawValue, - value) - } - - /// Try to transition from the expected current state to the specified next - /// state. - /// - /// - parameters: - /// - expected: The expected state. - /// - /// - returns: - /// `true` if the transition succeeds. `false` otherwise. - internal func tryTransition(from expected: State, to next: State) -> Bool { - return OSAtomicCompareAndSwap32Barrier(expected.rawValue, - next.rawValue, - value) - } -#else - private let value: Atomic - - /// Create a finite state machine with the specified initial state. - /// - /// - parameters: - /// - initial: The desired initial state. - internal init(_ initial: State) { - value = Atomic(initial.rawValue) - } - - /// Deinitialize the finite state machine. - internal func deinitialize() {} - - /// Compare the current state with the specified state. - /// - /// - parameters: - /// - expected: The expected state. - /// - /// - returns: - /// `true` if the current state matches the expected state. `false` - /// otherwise. - internal func `is`(_ expected: State) -> Bool { - return value.modify { $0 == expected.rawValue } - } - - /// Try to transition from the expected current state to the specified next - /// state. - /// - /// - parameters: - /// - expected: The expected state. - /// - /// - returns: - /// `true` if the transition succeeds. `false` otherwise. - internal func tryTransition(from expected: State, to next: State) -> Bool { - return value.modify { value in - if value == expected.rawValue { - value = next.rawValue - return true - } - return false - } - } -#endif -} - -final class PosixThreadMutex: NSLocking { - private var mutex = pthread_mutex_t() - - init() { - let result = pthread_mutex_init(&mutex, nil) - precondition(result == 0, "Failed to initialize mutex with error \(result).") - } - - deinit { - let result = pthread_mutex_destroy(&mutex) - precondition(result == 0, "Failed to destroy mutex with error \(result).") - } - - func lock() { - let result = pthread_mutex_lock(&mutex) - precondition(result == 0, "Failed to lock \(self) with error \(result).") - } - - func unlock() { - let result = pthread_mutex_unlock(&mutex) - precondition(result == 0, "Failed to unlock \(self) with error \(result).") - } -} - -/// An atomic variable. -public final class Atomic: AtomicProtocol { - private let lock: PosixThreadMutex - private var _value: Value - - /// Atomically get or set the value of the variable. - public var value: Value { - get { - return withValue { $0 } - } - - set(newValue) { - swap(newValue) - } - } - - /// Initialize the variable with the given initial value. - /// - /// - parameters: - /// - value: Initial value for `self`. - public init(_ value: Value) { - _value = value - lock = PosixThreadMutex() - } - - /// Atomically modifies the variable. - /// - /// - parameters: - /// - action: A closure that takes the current value. - /// - /// - returns: The result of the action. - @discardableResult - public func modify(_ action: (inout Value) throws -> Result) rethrows -> Result { - lock.lock() - defer { lock.unlock() } - - return try action(&_value) - } - - /// Atomically perform an arbitrary action using the current value of the - /// variable. - /// - /// - parameters: - /// - action: A closure that takes the current value. - /// - /// - returns: The result of the action. - @discardableResult - public func withValue(_ action: (Value) throws -> Result) rethrows -> Result { - lock.lock() - defer { lock.unlock() } - - return try action(_value) - } - - /// Atomically replace the contents of the variable. - /// - /// - parameters: - /// - newValue: A new value for the variable. - /// - /// - returns: The old value. - @discardableResult - public func swap(_ newValue: Value) -> Value { - return modify { (value: inout Value) in - let oldValue = value - value = newValue - return oldValue - } - } -} - - -/// An atomic variable which uses a recursive lock. -internal final class RecursiveAtomic: AtomicProtocol { - private let lock: NSRecursiveLock - private var _value: Value - private let didSetObserver: ((Value) -> Void)? - - /// Atomically get or set the value of the variable. - public var value: Value { - get { - return withValue { $0 } - } - - set(newValue) { - swap(newValue) - } - } - - /// Initialize the variable with the given initial value. - /// - /// - parameters: - /// - value: Initial value for `self`. - /// - name: An optional name used to create the recursive lock. - /// - action: An optional closure which would be invoked every time the - /// value of `self` is mutated. - internal init(_ value: Value, name: StaticString? = nil, didSet action: ((Value) -> Void)? = nil) { - _value = value - lock = NSRecursiveLock() - lock.name = name.map(String.init(describing:)) - didSetObserver = action - } - - /// Atomically modifies the variable. - /// - /// - parameters: - /// - action: A closure that takes the current value. - /// - /// - returns: The result of the action. - @discardableResult - func modify(_ action: (inout Value) throws -> Result) rethrows -> Result { - lock.lock() - defer { - didSetObserver?(_value) - lock.unlock() - } - - return try action(&_value) - } - - /// Atomically perform an arbitrary action using the current value of the - /// variable. - /// - /// - parameters: - /// - action: A closure that takes the current value. - /// - /// - returns: The result of the action. - @discardableResult - func withValue(_ action: (Value) throws -> Result) rethrows -> Result { - lock.lock() - defer { lock.unlock() } - - return try action(_value) - } - - /// Atomically replace the contents of the variable. - /// - /// - parameters: - /// - newValue: A new value for the variable. - /// - /// - returns: The old value. - @discardableResult - public func swap(_ newValue: Value) -> Value { - return modify { (value: inout Value) in - let oldValue = value - value = newValue - return oldValue - } - } -} diff --git a/Example/Pods/ReactiveSwift/Sources/Deprecations+Removals.swift b/Example/Pods/ReactiveSwift/Sources/Deprecations+Removals.swift deleted file mode 100644 index 95ccce0..0000000 --- a/Example/Pods/ReactiveSwift/Sources/Deprecations+Removals.swift +++ /dev/null @@ -1,620 +0,0 @@ -import Foundation -import enum Result.NoError - -// MARK: Depreciated types in ReactiveSwift 1.x. -@available(*, deprecated, renamed:"Scheduler") -public typealias SchedulerProtocol = Scheduler - -@available(*, deprecated, renamed:"DateScheduler") -public typealias DateSchedulerProtocol = DateScheduler - -@available(*, deprecated, renamed:"BindingSource") -public typealias BindingSourceProtocol = BindingSource - -@available(*, deprecated, message:"The protocol has been replaced by `BindingTargetProvider`, and will be removed in a future version.") -public protocol BindingTargetProtocol: class, BindingTargetProvider { - var lifetime: Lifetime { get } - - func consume(_ value: Value) -} - -extension BindingTargetProtocol { - public var bindingTarget: BindingTarget { - return BindingTarget(lifetime: lifetime) { [weak self] in self?.consume($0) } - } -} - -extension MutablePropertyProtocol { - @available(*, deprecated, message:"Use the regular setter.") - public func consume(_ value: Value) { - self.value = value - } -} - -extension Action: BindingTargetProtocol { - @available(*, deprecated, message:"Use the regular SignalProducer.") - public func consume(_ value: Input) { - self.apply(value).start() - } -} - -extension BindingTarget { - @available(*, deprecated, renamed:"action") - public func consume(_ value: Value) { - action(value) - } - - @available(*, deprecated, renamed:"init(lifetime:action:)") - public init(lifetime: Lifetime, setter: @escaping (Value) -> Void, _ void: Void? = nil) { - self.init(lifetime: lifetime, action: setter) - } - - @available(*, deprecated, renamed:"init(on:lifetime:action:)") - public init(on scheduler: Scheduler, lifetime: Lifetime, setter: @escaping (Value) -> Void, _ void: Void? = nil) { - self.init(on: scheduler, lifetime: lifetime, action: setter) - } -} - -/// A protocol used to constraint convenience `Atomic` methods and properties. -@available(*, deprecated, message:"The protocol has been deprecated, and will be removed in a future version.") -public protocol AtomicProtocol: class { - associatedtype Value - - @discardableResult - func withValue(_ action: (Value) throws -> Result) rethrows -> Result - - @discardableResult - func modify(_ action: (inout Value) throws -> Result) rethrows -> Result -} - -extension AtomicProtocol { - /// Atomically get or set the value of the variable. - public var value: Value { - get { - return withValue { $0 } - } - - set(newValue) { - swap(newValue) - } - } - - /// Atomically replace the contents of the variable. - /// - /// - parameters: - /// - newValue: A new value for the variable. - /// - /// - returns: The old value. - @discardableResult - public func swap(_ newValue: Value) -> Value { - return modify { (value: inout Value) in - let oldValue = value - value = newValue - return oldValue - } - } -} - -// MARK: Removed Types and APIs in ReactiveCocoa 5.0. - -// Renamed Protocols -@available(*, unavailable, renamed:"ActionProtocol") -public enum ActionType {} - -@available(*, unavailable, renamed:"SignalProtocol") -public enum SignalType {} - -@available(*, unavailable, renamed:"SignalProducerProtocol") -public enum SignalProducerType {} - -@available(*, unavailable, renamed:"PropertyProtocol") -public enum PropertyType {} - -@available(*, unavailable, renamed:"MutablePropertyProtocol") -public enum MutablePropertyType {} - -@available(*, unavailable, renamed:"ObserverProtocol") -public enum ObserverType {} - -@available(*, unavailable, renamed:"Scheduler") -public enum SchedulerType {} - -@available(*, unavailable, renamed:"DateScheduler") -public enum DateSchedulerType {} - -@available(*, unavailable, renamed:"OptionalProtocol") -public enum OptionalType {} - -@available(*, unavailable, renamed:"EventLoggerProtocol") -public enum EventLoggerType {} - -@available(*, unavailable, renamed:"EventProtocol") -public enum EventType {} - -// Renamed and Removed Types - -@available(*, unavailable, renamed:"Property") -public struct AnyProperty {} - -@available(*, unavailable, message:"Use 'Property(value:)' to create a constant property instead. 'ConstantProperty' is removed in RAC 5.0.") -public struct ConstantProperty {} - -// Renamed Properties - -extension Disposable { - @available(*, unavailable, renamed:"isDisposed") - public var disposed: Bool { fatalError() } -} - -extension SerialDisposable { - @available(*, unavailable, renamed:"inner") - public var innerDisposable: Disposable? { - get { fatalError() } - set { fatalError() } - } -} - -extension ScopedDisposable { - @available(*, unavailable, renamed:"inner") - public var innerDisposable: Disposable { fatalError() } -} - -extension ActionProtocol { - @available(*, unavailable, renamed:"isEnabled") - public var enabled: Bool { fatalError() } - - @available(*, unavailable, renamed:"isExecuting") - public var executing: Bool { fatalError() } -} - -// Renamed Enum cases - -extension Event { - @available(*, unavailable, renamed:"value") - public static var Next: Event { fatalError() } - - @available(*, unavailable, renamed:"failed") - public static var Failed: Event { fatalError() } - - @available(*, unavailable, renamed:"completed") - public static var Completed: Event { fatalError() } - - @available(*, unavailable, renamed:"interrupted") - public static var Interrupted: Event { fatalError() } -} - -extension ActionError { - @available(*, unavailable, renamed:"producerFailed") - public static var ProducerError: ActionError { fatalError() } - - @available(*, unavailable, renamed:"disabled") - public static var NotEnabled: ActionError { fatalError() } -} - -extension FlattenStrategy { - @available(*, unavailable, renamed:"latest") - public static var Latest: FlattenStrategy { fatalError() } - - @available(*, unavailable, renamed:"concat") - public static var Concat: FlattenStrategy { fatalError() } - - @available(*, unavailable, renamed:"merge") - public static var Merge: FlattenStrategy { fatalError() } -} - -extension LoggingEvent.Signal { - @available(*, unavailable, renamed:"next") - public static var Next: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"completed") - public static var Completed: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"failed") - public static var Failed: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"terminated") - public static var Terminated: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"disposed") - public static var Disposed: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"interrupted") - public static var Interrupted: LoggingEvent.Signal { fatalError() } -} - -extension LoggingEvent.SignalProducer { - @available(*, unavailable, renamed:"started") - public static var Started: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"next") - public static var Next: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"completed") - public static var Completed: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"failed") - public static var Failed: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"terminated") - public static var Terminated: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"disposed") - public static var Disposed: LoggingEvent.Signal { fatalError() } - - @available(*, unavailable, renamed:"interrupted") - public static var Interrupted: LoggingEvent.Signal { fatalError() } -} - -// Methods - -extension Bag { - @available(*, unavailable, renamed:"remove(using:)") - public func removeValueForToken(_ token: RemovalToken) { fatalError() } -} - -extension CompositeDisposable { - @available(*, unavailable, renamed:"add(_:)") - public func addDisposable(_ d: Disposable) -> DisposableHandle { fatalError() } -} - -extension Observer { - @available(*, unavailable, renamed: "init(value:failed:completed:interrupted:)") - public convenience init( - next: ((Value) -> Void)? = nil, - failed: ((Error) -> Void)? = nil, - completed: (() -> Void)? = nil, - interrupted: (() -> Void)? = nil - ) { fatalError() } -} - -extension ObserverProtocol { - @available(*, unavailable, renamed: "send(value:)") - public func sendNext(_ value: Value) { fatalError() } - - @available(*, unavailable, renamed: "send(error:)") - public func sendFailed(_ error: Error) { fatalError() } -} - -extension SignalProtocol { - @available(*, unavailable, renamed:"take(first:)") - public func take(_ count: Int) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"take(last:)") - public func takeLast(_ count: Int) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"skip(first:)") - public func skip(_ count: Int) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"observe(on:)") - public func observeOn(_ scheduler: Scheduler) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"combineLatest(with:)") - public func combineLatestWith(_ otherSignal: S) -> Signal<(Value, S.Value), Error> { fatalError() } - - @available(*, unavailable, renamed:"zip(with:)") - public func zipWith(_ otherSignal: S) -> Signal<(Value, S.Value), Error> { fatalError() } - - @available(*, unavailable, renamed:"take(until:)") - public func takeUntil(_ trigger: Signal<(), NoError>) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"take(untilReplacement:)") - public func takeUntilReplacement(_ replacement: Signal) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"skip(until:)") - public func skipUntil(_ trigger: Signal<(), NoError>) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"skip(while:)") - public func skipWhile(_ predicate: (Value) -> Bool) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"take(while:)") - public func takeWhile(_ predicate: (Value) -> Bool) -> Signal { fatalError() } - - @available(*, unavailable, renamed:"timeout(after:raising:on:)") - public func timeoutWithError(_ error: Error, afterInterval: TimeInterval, onScheduler: DateScheduler) -> Signal { fatalError() } - - @available(*, unavailable, message: "This Signal may emit errors which must be handled explicitly, or observed using `observeResult(_:)`") - public func observeNext(_ next: (Value) -> Void) -> Disposable? { fatalError() } -} - -extension SignalProtocol where Value: OptionalProtocol { - @available(*, unavailable, renamed:"skipNil()") - public func ignoreNil() -> SignalProducer { fatalError() } -} - -extension SignalProtocol where Error == NoError { - @available(*, unavailable, renamed: "observeValues") - public func observeNext(_ next: (Value) -> Void) -> Disposable? { fatalError() } -} - -extension SignalProtocol where Value: Sequence { - @available(*, deprecated, message: "Use flatten() instead") - public func flatten(_ strategy: FlattenStrategy) -> Signal { - return self.flatMap(strategy, transform: SignalProducer.init) - } -} - -extension SignalProducerProtocol { - @available(*, unavailable, renamed:"take(first:)") - public func take(_ count: Int) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"take(last:)") - public func takeLast(_ count: Int) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"skip(first:)") - public func skip(_ count: Int) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"retry(upTo:)") - public func retry(_ count: Int) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"observe(on:)") - public func observeOn(_ scheduler: Scheduler) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"start(on:)") - public func startOn(_ scheduler: Scheduler) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"combineLatest(with:)") - public func combineLatestWith(_ otherProducer: SignalProducer) -> SignalProducer<(Value, U), Error> { fatalError() } - - @available(*, unavailable, renamed:"combineLatest(with:)") - public func combineLatestWith(_ otherSignal: Signal) -> SignalProducer<(Value, U), Error> { fatalError() } - - @available(*, unavailable, renamed:"zip(with:)") - public func zipWith(_ otherProducer: SignalProducer) -> SignalProducer<(Value, U), Error> { fatalError() } - - @available(*, unavailable, renamed:"zip(with:)") - public func zipWith(_ otherSignal: Signal) -> SignalProducer<(Value, U), Error> { fatalError() } - - @available(*, unavailable, renamed:"take(until:)") - public func takeUntil(_ trigger: Signal<(), NoError>) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"take(until:)") - public func takeUntil(_ trigger: SignalProducer<(), NoError>) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"take(untilReplacement:)") - public func takeUntilReplacement(_ replacement: Signal) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"take(untilReplacement:)") - public func takeUntilReplacement(_ replacement: SignalProducer) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"skip(until:)") - public func skipUntil(_ trigger: Signal<(), NoError>) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"skip(until:)") - public func skipUntil(_ trigger: SignalProducer<(), NoError>) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"skip(while:)") - public func skipWhile(_ predicate: (Value) -> Bool) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"take(while:)") - public func takeWhile(_ predicate: (Value) -> Bool) -> SignalProducer { fatalError() } - - @available(*, unavailable, renamed:"timeout(after:raising:on:)") - public func timeoutWithError(_ error: Error, afterInterval: TimeInterval, onScheduler: DateScheduler) -> SignalProducer { fatalError() } - - @available(*, unavailable, message:"This SignalProducer may emit errors which must be handled explicitly, or observed using `startWithResult(_:)`.") - public func startWithNext(_ next: (Value) -> Void) -> Disposable { fatalError() } - - @available(*, unavailable, renamed:"repeat(_:)") - public func times(_ count: Int) -> SignalProducer { fatalError() } -} - -extension SignalProducerProtocol where Value: OptionalProtocol { - @available(*, unavailable, renamed:"skipNil()") - public func ignoreNil() -> SignalProducer { fatalError() } -} - -extension SignalProducerProtocol where Error == NoError { - @available(*, unavailable, renamed: "startWithValues") - public func startWithNext(_ value: @escaping (Value) -> Void) -> Disposable { fatalError() } -} - -extension SignalProducerProtocol where Value: Sequence { - @available(*, deprecated, message: "Use flatten() instead") - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - return self.flatMap(strategy, transform: SignalProducer.init) - } -} - -extension SignalProducer { - @available(*, unavailable, message:"Use properties instead. `buffer(_:)` is removed in RAC 5.0.") - public static func buffer(_ capacity: Int) -> (SignalProducer, Signal.Observer) { fatalError() } - - @available(*, unavailable, renamed:"init(_:)") - public init(signal: S) where S.Value == Value, S.Error == Error { fatalError() } - - @available(*, unavailable, renamed:"init(_:)") - public init(values: S) where S.Iterator.Element == Value { fatalError() } -} - -extension PropertyProtocol { - @available(*, unavailable, renamed:"combineLatest(with:)") - public func combineLatestWith(_ otherProperty: P) -> Property<(Value, P.Value)> { fatalError() } - - @available(*, unavailable, renamed:"zip(with:)") - public func zipWith(_ otherProperty: P) -> Property<(Value, P.Value)> { fatalError() } -} - -extension Property { - @available(*, unavailable, renamed:"Property(initial:then:)") - public convenience init(initialValue: Value, producer: SignalProducer) { fatalError() } - - @available(*, unavailable, renamed:"Property(initial:then:)") - public convenience init(initialValue: Value, signal: Signal) { fatalError() } -} - -extension DateScheduler { - @available(*, unavailable, renamed:"schedule(after:action:)") - func scheduleAfter(date: Date, _ action: () -> Void) -> Disposable? { fatalError() } - - @available(*, unavailable, renamed:"schedule(after:interval:leeway:)") - func scheduleAfter(date: Date, repeatingEvery: TimeInterval, withLeeway: TimeInterval, action: () -> Void) -> Disposable? { fatalError() } - - @available(*, unavailable, message:"schedule(after:interval:leeway:action:) now uses DispatchTimeInterval") - func schedule(after date: Date, interval: TimeInterval, leeway: TimeInterval, action: @escaping () -> Void) -> Disposable? { fatalError() } - - @available(*, unavailable, message:"schedule(after:interval:action:) now uses DispatchTimeInterval") - public func schedule(after date: Date, interval: TimeInterval, action: @escaping () -> Void) -> Disposable? { fatalError() } -} - -extension TestScheduler { - @available(*, unavailable, renamed:"advance(by:)") - public func advanceByInterval(_ interval: TimeInterval) { fatalError() } - - @available(*, unavailable, renamed:"advance(to:)") - public func advanceToDate(_ date: Date) { fatalError() } - - @available(*, unavailable, message:"advance(by:) now uses DispatchTimeInterval") - public func advance(by interval: TimeInterval) { fatalError() } - - @available(*, unavailable, message:"rewind(by:) now uses DispatchTimeInterval") - public func rewind(by interval: TimeInterval) { fatalError() } -} - -extension QueueScheduler { - @available(*, unavailable, renamed:"main") - public static var mainQueueScheduler: QueueScheduler { fatalError() } -} - -extension NotificationCenter { - @available(*, unavailable, renamed:"reactive.notifications") - public func rac_notifications(forName name: Notification.Name?, object: AnyObject? = nil) -> SignalProducer { fatalError() } -} - -extension URLSession { - @available(*, unavailable, renamed:"reactive.data") - public func rac_data(with request: URLRequest) -> SignalProducer<(Data, URLResponse), NSError> { fatalError() } -} - -extension Reactive where Base: URLSession { - @available(*, unavailable, message:"Use the overload which returns `SignalProducer<(Data, URLResponse), AnyError>` instead, and cast `AnyError.error` to `NSError` as you need") - public func data(with request: URLRequest) -> SignalProducer<(Data, URLResponse), NSError> { fatalError() } -} - -// Free functions - -@available(*, unavailable, message:"timer(interval:on:) now uses DispatchTimeInterval") -public func timer(interval: TimeInterval, on scheduler: DateScheduler) -> SignalProducer { fatalError() } - -@available(*, unavailable, message:"timer(interval:on:leeway:) now uses DispatchTimeInterval") -public func timer(interval: TimeInterval, on scheduler: DateScheduler, leeway: TimeInterval) -> SignalProducer { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal) -> Signal<(A, B), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal, _ c: Signal) -> Signal<(A, B, C), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal) -> Signal<(A, B, C, D), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal) -> Signal<(A, B, C, D, E), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal) -> Signal<(A, B, C, D, E, F), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal, _ g: Signal) -> Signal<(A, B, C, D, E, F, G), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal, _ g: Signal, _ h: Signal) -> Signal<(A, B, C, D, E, F, G, H), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal, _ g: Signal, _ h: Signal, _ i: Signal) -> Signal<(A, B, C, D, E, F, G, H, I), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal, _ g: Signal, _ h: Signal, _ i: Signal, _ j: Signal) -> Signal<(A, B, C, D, E, F, G, H, I, J), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.combineLatest") -public func combineLatest(_ signals: S) -> Signal<[Value], Error> where S.Iterator.Element == Signal { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal) -> Signal<(A, B), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal, _ c: Signal) -> Signal<(A, B, C), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal) -> Signal<(A, B, C, D), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal) -> Signal<(A, B, C, D, E), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal) -> Signal<(A, B, C, D, E, F), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal, _ g: Signal) -> Signal<(A, B, C, D, E, F, G), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal, _ g: Signal, _ h: Signal) -> Signal<(A, B, C, D, E, F, G, H), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal, _ g: Signal, _ h: Signal, _ i: Signal) -> Signal<(A, B, C, D, E, F, G, H, I), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ a: Signal, _ b: Signal, _ c: Signal, _ d: Signal, _ e: Signal, _ f: Signal, _ g: Signal, _ h: Signal, _ i: Signal, _ j: Signal) -> Signal<(A, B, C, D, E, F, G, H, I, J), Error> { fatalError() } - -@available(*, unavailable, renamed:"Signal.zip") -public func zip(_ signals: S) -> Signal<[Value], Error> where S.Iterator.Element == Signal { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer) -> SignalProducer<(A, B), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer) -> SignalProducer<(A, B, C), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer) -> SignalProducer<(A, B, C, D), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer) -> SignalProducer<(A, B, C, D, E), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer) -> SignalProducer<(A, B, C, D, E, F), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer, _ g: SignalProducer) -> SignalProducer<(A, B, C, D, E, F, G), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer, _ g: SignalProducer, _ h: SignalProducer) -> SignalProducer<(A, B, C, D, E, F, G, H), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer, _ g: SignalProducer, _ h: SignalProducer, _ i: SignalProducer) -> SignalProducer<(A, B, C, D, E, F, G, H, I), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer, _ g: SignalProducer, _ h: SignalProducer, _ i: SignalProducer, _ j: SignalProducer) -> SignalProducer<(A, B, C, D, E, F, G, H, I, J), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.combineLatest") -public func combineLatest(_ producers: S) -> SignalProducer<[Value], Error> where S.Iterator.Element == SignalProducer { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer) -> SignalProducer<(A, B), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer) -> SignalProducer<(A, B, C), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer) -> SignalProducer<(A, B, C, D), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer) -> SignalProducer<(A, B, C, D, E), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer) -> SignalProducer<(A, B, C, D, E, F), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer, _ g: SignalProducer) -> SignalProducer<(A, B, C, D, E, F, G), Error> { - fatalError()} - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer, _ g: SignalProducer, _ h: SignalProducer) -> SignalProducer<(A, B, C, D, E, F, G, H), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer, _ g: SignalProducer, _ h: SignalProducer, _ i: SignalProducer) -> SignalProducer<(A, B, C, D, E, F, G, H, I), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ a: SignalProducer, _ b: SignalProducer, _ c: SignalProducer, _ d: SignalProducer, _ e: SignalProducer, _ f: SignalProducer, _ g: SignalProducer, _ h: SignalProducer, _ i: SignalProducer, _ j: SignalProducer) -> SignalProducer<(A, B, C, D, E, F, G, H, I, J), Error> { fatalError() } - -@available(*, unavailable, renamed:"SignalProducer.zip") -public func zip(_ producers: S) -> SignalProducer<[Value], Error> where S.Iterator.Element == SignalProducer { fatalError() } diff --git a/Example/Pods/ReactiveSwift/Sources/Disposable.swift b/Example/Pods/ReactiveSwift/Sources/Disposable.swift deleted file mode 100644 index 806ed11..0000000 --- a/Example/Pods/ReactiveSwift/Sources/Disposable.swift +++ /dev/null @@ -1,408 +0,0 @@ -// -// Disposable.swift -// ReactiveSwift -// -// Created by Justin Spahr-Summers on 2014-06-02. -// Copyright (c) 2014 GitHub. All rights reserved. -// - -/// Represents something that can be “disposed”, usually associated with freeing -/// resources or canceling work. -public protocol Disposable: class { - /// Whether this disposable has been disposed already. - var isDisposed: Bool { get } - - /// Disposing of the resources represented by `self`. If `self` has already - /// been disposed of, it does nothing. - /// - /// - note: Implementations must issue a memory barrier. - func dispose() -} - -/// Represents the state of a disposable. -private enum DisposableState: Int32 { - /// The disposable is active. - case active - - /// The disposable has been disposed. - case disposed -} - -extension AtomicStateProtocol where State == DisposableState { - /// Try to transition from `active` to `disposed`. - /// - /// - returns: - /// `true` if the transition succeeds. `false` otherwise. - @inline(__always) - fileprivate func tryDispose() -> Bool { - return tryTransition(from: .active, to: .disposed) - } -} - -/// A type-erased disposable that forwards operations to an underlying disposable. -public final class AnyDisposable: Disposable { - private let disposable: Disposable - - public var isDisposed: Bool { - return disposable.isDisposed - } - - public init(_ disposable: Disposable) { - self.disposable = disposable - } - - public func dispose() { - disposable.dispose() - } -} - -/// A disposable that only flips `isDisposed` upon disposal, and performs no other -/// work. -public final class SimpleDisposable: Disposable { - private var state = UnsafeAtomicState(DisposableState.active) - - public var isDisposed: Bool { - return state.is(.disposed) - } - - public init() {} - - public func dispose() { - _ = state.tryDispose() - } - - deinit { - state.deinitialize() - } -} - -/// A disposable that will run an action upon disposal. -public final class ActionDisposable: Disposable { - private var action: (() -> Void)? - private var state: UnsafeAtomicState - - public var isDisposed: Bool { - return state.is(.disposed) - } - - /// Initialize the disposable to run the given action upon disposal. - /// - /// - parameters: - /// - action: A closure to run when calling `dispose()`. - public init(action: @escaping () -> Void) { - self.action = action - self.state = UnsafeAtomicState(DisposableState.active) - } - - public func dispose() { - if state.tryDispose() { - action?() - action = nil - } - } - - deinit { - state.deinitialize() - } -} - -/// A disposable that will dispose of any number of other disposables. -public final class CompositeDisposable: Disposable { - private let disposables: Atomic?> - private var state: UnsafeAtomicState - - /// Represents a handle to a disposable previously added to a - /// CompositeDisposable. - public final class DisposableHandle { - private var state: UnsafeAtomicState - private var bagToken: RemovalToken? - private weak var disposable: CompositeDisposable? - - fileprivate static let empty = DisposableHandle() - - fileprivate init() { - self.state = UnsafeAtomicState(.disposed) - self.bagToken = nil - } - - deinit { - state.deinitialize() - } - - fileprivate init(bagToken: RemovalToken, disposable: CompositeDisposable) { - self.state = UnsafeAtomicState(.active) - self.bagToken = bagToken - self.disposable = disposable - } - - /// Remove the pointed-to disposable from its `CompositeDisposable`. - /// - /// - note: This is useful to minimize memory growth, by removing - /// disposables that are no longer needed. - public func remove() { - if state.tryDispose(), let token = bagToken { - _ = disposable?.disposables.modify { - $0?.remove(using: token) - } - bagToken = nil - disposable = nil - } - } - } - - public var isDisposed: Bool { - return state.is(.disposed) - } - - /// Initialize a `CompositeDisposable` containing the given sequence of - /// disposables. - /// - /// - parameters: - /// - disposables: A collection of objects conforming to the `Disposable` - /// protocol - public init(_ disposables: S) - where S.Iterator.Element == Disposable - { - var bag: Bag = Bag() - - for disposable in disposables { - bag.insert(disposable) - } - - self.disposables = Atomic(bag) - self.state = UnsafeAtomicState(DisposableState.active) - } - - /// Initialize a `CompositeDisposable` containing the given sequence of - /// disposables. - /// - /// - parameters: - /// - disposables: A collection of objects conforming to the `Disposable` - /// protocol - public convenience init(_ disposables: S) - where S.Iterator.Element == Disposable? - { - self.init(disposables.flatMap { $0 }) - } - - /// Initializes an empty `CompositeDisposable`. - public convenience init() { - self.init([Disposable]()) - } - - public func dispose() { - if state.tryDispose() { - if let ds = disposables.swap(nil) { - for d in ds { - d.dispose() - } - } - } - } - - /// Add the given disposable to the list, then return a handle which can - /// be used to opaquely remove the disposable later (if desired). - /// - /// - parameters: - /// - d: Optional disposable. - /// - /// - returns: An instance of `DisposableHandle` that can be used to - /// opaquely remove the disposable later (if desired). - @discardableResult - public func add(_ d: Disposable?) -> DisposableHandle { - guard let d = d else { - return DisposableHandle.empty - } - - let handle: DisposableHandle? = disposables.modify { - return ($0?.insert(d)).map { DisposableHandle(bagToken: $0, disposable: self) } - } - - if let handle = handle { - return handle - } else { - d.dispose() - return DisposableHandle.empty - } - } - - /// Add an ActionDisposable to the list. - /// - /// - parameters: - /// - action: A closure that will be invoked when `dispose()` is called. - /// - /// - returns: An instance of `DisposableHandle` that can be used to - /// opaquely remove the disposable later (if desired). - @discardableResult - public func add(_ action: @escaping () -> Void) -> DisposableHandle { - return add(ActionDisposable(action: action)) - } - - deinit { - state.deinitialize() - } -} - -/// A disposable that, upon deinitialization, will automatically dispose of -/// its inner disposable. -public final class ScopedDisposable: Disposable { - /// The disposable which will be disposed when the ScopedDisposable - /// deinitializes. - public let inner: Inner - - public var isDisposed: Bool { - return inner.isDisposed - } - - /// Initialize the receiver to dispose of the argument upon - /// deinitialization. - /// - /// - parameters: - /// - disposable: A disposable to dispose of when deinitializing. - public init(_ disposable: Inner) { - inner = disposable - } - - deinit { - dispose() - } - - public func dispose() { - return inner.dispose() - } -} - -extension ScopedDisposable where Inner: AnyDisposable { - /// Initialize the receiver to dispose of the argument upon - /// deinitialization. - /// - /// - parameters: - /// - disposable: A disposable to dispose of when deinitializing, which - /// will be wrapped in an `AnyDisposable`. - public convenience init(_ disposable: Disposable) { - self.init(Inner(disposable)) - } -} - -/// A disposable that disposes of its wrapped disposable, and allows its -/// wrapped disposable to be replaced. -public final class SerialDisposable: Disposable { - private let _inner: Atomic - private var state: UnsafeAtomicState - - public var isDisposed: Bool { - return state.is(.disposed) - } - - /// The current inner disposable to dispose of. - /// - /// Whenever this property is set (even to the same value!), the previous - /// disposable is automatically disposed. - public var inner: Disposable? { - get { - return _inner.value - } - - set(d) { - _inner.swap(d)?.dispose() - if let d = d, isDisposed { - d.dispose() - } - } - } - - /// Initializes the receiver to dispose of the argument when the - /// SerialDisposable is disposed. - /// - /// - parameters: - /// - disposable: Optional disposable. - public init(_ disposable: Disposable? = nil) { - self._inner = Atomic(disposable) - self.state = UnsafeAtomicState(DisposableState.active) - } - - public func dispose() { - if state.tryDispose() { - _inner.swap(nil)?.dispose() - } - } - - deinit { - state.deinitialize() - } -} - -/// Adds the right-hand-side disposable to the left-hand-side -/// `CompositeDisposable`. -/// -/// ```` -/// disposable += producer -/// .filter { ... } -/// .map { ... } -/// .start(observer) -/// ```` -/// -/// - parameters: -/// - lhs: Disposable to add to. -/// - rhs: Disposable to add. -/// -/// - returns: An instance of `DisposableHandle` that can be used to opaquely -/// remove the disposable later (if desired). -@discardableResult -public func +=(lhs: CompositeDisposable, rhs: Disposable?) -> CompositeDisposable.DisposableHandle { - return lhs.add(rhs) -} - -/// Adds the right-hand-side `ActionDisposable` to the left-hand-side -/// `CompositeDisposable`. -/// -/// ```` -/// disposable += { ... } -/// ```` -/// -/// - parameters: -/// - lhs: Disposable to add to. -/// - rhs: Closure to add as a disposable. -/// -/// - returns: An instance of `DisposableHandle` that can be used to opaquely -/// remove the disposable later (if desired). -@discardableResult -public func +=(lhs: CompositeDisposable, rhs: @escaping () -> ()) -> CompositeDisposable.DisposableHandle { - return lhs.add(rhs) -} - -/// Adds the right-hand-side disposable to the left-hand-side -/// `ScopedDisposable`. -/// -/// ```` -/// disposable += { ... } -/// ```` -/// -/// - parameters: -/// - lhs: Disposable to add to. -/// - rhs: Disposable to add. -/// -/// - returns: An instance of `DisposableHandle` that can be used to opaquely -/// remove the disposable later (if desired). -@discardableResult -public func +=(lhs: ScopedDisposable, rhs: Disposable?) -> CompositeDisposable.DisposableHandle { - return lhs.inner.add(rhs) -} - -/// Adds the right-hand-side disposable to the left-hand-side -/// `ScopedDisposable`. -/// -/// ```` -/// disposable += { ... } -/// ```` -/// -/// - parameters: -/// - lhs: Disposable to add to. -/// - rhs: Closure to add as a disposable. -/// -/// - returns: An instance of `DisposableHandle` that can be used to opaquely -/// remove the disposable later (if desired). -@discardableResult -public func +=(lhs: ScopedDisposable, rhs: @escaping () -> ()) -> CompositeDisposable.DisposableHandle { - return lhs.inner.add(rhs) -} diff --git a/Example/Pods/ReactiveSwift/Sources/Flatten.swift b/Example/Pods/ReactiveSwift/Sources/Flatten.swift deleted file mode 100644 index 0adb04c..0000000 --- a/Example/Pods/ReactiveSwift/Sources/Flatten.swift +++ /dev/null @@ -1,957 +0,0 @@ -// -// Flatten.swift -// ReactiveSwift -// -// Created by Neil Pankey on 11/30/15. -// Copyright © 2015 GitHub. All rights reserved. -// - -import enum Result.NoError - -/// Describes how multiple producers should be joined together. -public enum FlattenStrategy: Equatable { - /// The producers should be merged, so that any value received on any of the - /// input producers will be forwarded immediately to the output producer. - /// - /// The resulting producer will complete only when all inputs have - /// completed. - case merge - - /// The producers should be concatenated, so that their values are sent in - /// the order of the producers themselves. - /// - /// The resulting producer will complete only when all inputs have - /// completed. - case concat - - /// Only the events from the latest input producer should be considered for - /// the output. Any producers received before that point will be disposed - /// of. - /// - /// The resulting producer will complete only when the producer-of-producers - /// and the latest producer has completed. - case latest -} - - -extension SignalProtocol where Value: SignalProducerProtocol, Error == Value.Error { - /// Flattens the inner producers sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If `signal` or an active inner producer fails, the returned - /// signal will forward that failure immediately. - /// - /// - note: `interrupted` events on inner producers will be treated like - /// `Completed events on inner producers. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - switch strategy { - case .merge: - return self.merge() - - case .concat: - return self.concat() - - case .latest: - return self.switchToLatest() - } - } -} - -extension SignalProtocol where Value: SignalProducerProtocol, Error == NoError { - /// Flattens the inner producers sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If an active inner producer fails, the returned signal will - /// forward that failure immediately. - /// - /// - warning: `interrupted` events on inner producers will be treated like - /// `completed` events on inner producers. - /// - /// - parameters: - /// - strategy: Strategy used when flattening signals. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - return self - .promoteErrors(Value.Error.self) - .flatten(strategy) - } -} - -extension SignalProtocol where Value: SignalProducerProtocol, Error == NoError, Value.Error == NoError { - /// Flattens the inner producers sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - warning: `interrupted` events on inner producers will be treated like - /// `completed` events on inner producers. - /// - /// - parameters: - /// - strategy: Strategy used when flattening signals. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - switch strategy { - case .merge: - return self.merge() - - case .concat: - return self.concat() - - case .latest: - return self.switchToLatest() - } - } -} - -extension SignalProtocol where Value: SignalProducerProtocol, Value.Error == NoError { - /// Flattens the inner producers sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If `signal` fails, the returned signal will forward that failure - /// immediately. - /// - /// - warning: `interrupted` events on inner producers will be treated like - /// `completed` events on inner producers. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - return self.flatMap(strategy) { $0.promoteErrors(Error.self) } - } -} - -extension SignalProducerProtocol where Value: SignalProducerProtocol, Error == Value.Error { - /// Flattens the inner producers sent upon `producer` (into a single - /// producer of values), according to the semantics of the given strategy. - /// - /// - note: If `producer` or an active inner producer fails, the returned - /// producer will forward that failure immediately. - /// - /// - warning: `interrupted` events on inner producers will be treated like - /// `completed` events on inner producers. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - switch strategy { - case .merge: - return self.merge() - - case .concat: - return self.concat() - - case .latest: - return self.switchToLatest() - } - } -} - -extension SignalProducerProtocol where Value: SignalProducerProtocol, Error == NoError { - /// Flattens the inner producers sent upon `producer` (into a single - /// producer of values), according to the semantics of the given strategy. - /// - /// - note: If an active inner producer fails, the returned producer will - /// forward that failure immediately. - /// - /// - warning: `interrupted` events on inner producers will be treated like - /// `completed` events on inner producers. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - return self - .promoteErrors(Value.Error.self) - .flatten(strategy) - } -} - -extension SignalProducerProtocol where Value: SignalProducerProtocol, Error == NoError, Value.Error == NoError { - /// Flattens the inner producers sent upon `producer` (into a single - /// producer of values), according to the semantics of the given strategy. - /// - /// - warning: `interrupted` events on inner producers will be treated like - /// `completed` events on inner producers. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - switch strategy { - case .merge: - return self.merge() - - case .concat: - return self.concat() - - case .latest: - return self.switchToLatest() - } - } -} - -extension SignalProducerProtocol where Value: SignalProducerProtocol, Value.Error == NoError { - /// Flattens the inner producers sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If `signal` fails, the returned signal will forward that failure - /// immediately. - /// - /// - warning: `interrupted` events on inner producers will be treated like - /// `completed` events on inner producers. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - return self.flatMap(strategy) { $0.promoteErrors(Error.self) } - } -} - -extension SignalProtocol where Value: SignalProtocol, Error == Value.Error { - /// Flattens the inner signals sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If `signal` or an active inner signal emits an error, the - /// returned signal will forward that error immediately. - /// - /// - warning: `interrupted` events on inner signals will be treated like - /// `completed` events on inner signals. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - return self - .map(SignalProducer.init) - .flatten(strategy) - } -} - -extension SignalProtocol where Value: SignalProtocol, Error == NoError { - /// Flattens the inner signals sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If an active inner signal emits an error, the returned signal - /// will forward that error immediately. - /// - /// - warning: `interrupted` events on inner signals will be treated like - /// `completed` events on inner signals. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - return self - .promoteErrors(Value.Error.self) - .flatten(strategy) - } -} - -extension SignalProtocol where Value: SignalProtocol, Error == NoError, Value.Error == NoError { - /// Flattens the inner signals sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - warning: `interrupted` events on inner signals will be treated like - /// `completed` events on inner signals. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - return self - .map(SignalProducer.init) - .flatten(strategy) - } -} - -extension SignalProtocol where Value: SignalProtocol, Value.Error == NoError { - /// Flattens the inner signals sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If `signal` emits an error, the returned signal will forward - /// that error immediately. - /// - /// - warning: `interrupted` events on inner signals will be treated like - /// `completed` events on inner signals. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - return self.flatMap(strategy) { $0.promoteErrors(Error.self) } - } -} - -extension SignalProtocol where Value: Sequence { - /// Flattens the `sequence` value sent by `signal`. - public func flatten() -> Signal { - return self.flatMap(.merge, transform: SignalProducer.init) - } -} - -extension SignalProducerProtocol where Value: SignalProtocol, Error == Value.Error { - /// Flattens the inner signals sent upon `producer` (into a single producer - /// of values), according to the semantics of the given strategy. - /// - /// - note: If `producer` or an active inner signal emits an error, the - /// returned producer will forward that error immediately. - /// - /// - warning: `interrupted` events on inner signals will be treated like - /// `completed` events on inner signals. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - return self - .map(SignalProducer.init) - .flatten(strategy) - } -} - -extension SignalProducerProtocol where Value: SignalProtocol, Error == NoError { - /// Flattens the inner signals sent upon `producer` (into a single producer - /// of values), according to the semantics of the given strategy. - /// - /// - note: If an active inner signal emits an error, the returned producer - /// will forward that error immediately. - /// - /// - warning: `interrupted` events on inner signals will be treated like - /// `completed` events on inner signals. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - return self - .promoteErrors(Value.Error.self) - .flatten(strategy) - } -} - -extension SignalProducerProtocol where Value: SignalProtocol, Error == NoError, Value.Error == NoError { - /// Flattens the inner signals sent upon `producer` (into a single producer - /// of values), according to the semantics of the given strategy. - /// - /// - warning: `interrupted` events on inner signals will be treated like - /// `completed` events on inner signals. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - return self - .map(SignalProducer.init) - .flatten(strategy) - } -} - -extension SignalProducerProtocol where Value: SignalProtocol, Value.Error == NoError { - /// Flattens the inner signals sent upon `producer` (into a single producer - /// of values), according to the semantics of the given strategy. - /// - /// - note: If `producer` emits an error, the returned producer will forward - /// that error immediately. - /// - /// - warning: `interrupted` events on inner signals will be treated like - /// `completed` events on inner signals. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - return self.flatMap(strategy) { $0.promoteErrors(Error.self) } - } -} - -extension SignalProducerProtocol where Value: Sequence { - /// Flattens the `sequence` value sent by `signal`. - public func flatten() -> SignalProducer { - return self.flatMap(.merge, transform: SignalProducer.init) - } -} - -extension SignalProtocol where Value: PropertyProtocol { - /// Flattens the inner properties sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If `signal` fails, the returned signal will forward that failure - /// immediately. - public func flatten(_ strategy: FlattenStrategy) -> Signal { - return self.flatMap(strategy) { $0.producer } - } -} - -extension SignalProducerProtocol where Value: PropertyProtocol { - /// Flattens the inner properties sent upon `signal` (into a single signal of - /// values), according to the semantics of the given strategy. - /// - /// - note: If `signal` fails, the returned signal will forward that failure - /// immediately. - public func flatten(_ strategy: FlattenStrategy) -> SignalProducer { - return self.flatMap(strategy) { $0.producer } - } -} - -extension SignalProtocol where Value: SignalProducerProtocol, Error == Value.Error { - /// Returns a signal which sends all the values from producer signal emitted - /// from `signal`, waiting until each inner producer completes before - /// beginning to send the values from the next inner producer. - /// - /// - note: If any of the inner producers fail, the returned signal will - /// forward that failure immediately - /// - /// - note: The returned signal completes only when `signal` and all - /// producers emitted from `signal` complete. - fileprivate func concat() -> Signal { - return Signal { relayObserver in - let disposable = CompositeDisposable() - let relayDisposable = CompositeDisposable() - - disposable += relayDisposable - disposable += self.observeConcat(relayObserver, relayDisposable) - - return disposable - } - } - - fileprivate func observeConcat(_ observer: Observer, _ disposable: CompositeDisposable? = nil) -> Disposable? { - let state = Atomic(ConcatState()) - - func startNextIfNeeded() { - while let producer = state.modify({ $0.dequeue() }) { - producer.startWithSignal { signal, inner in - let handle = disposable?.add(inner) - - signal.observe { event in - switch event { - case .completed, .interrupted: - handle?.remove() - - let shouldStart: Bool = state.modify { - $0.active = nil - return !$0.isStarting - } - - if shouldStart { - startNextIfNeeded() - } - - case .value, .failed: - observer.action(event) - } - } - } - state.modify { $0.isStarting = false } - } - } - - return observe { event in - switch event { - case let .value(value): - state.modify { $0.queue.append(value.producer) } - startNextIfNeeded() - - case let .failed(error): - observer.send(error: error) - - case .completed: - state.modify { state in - state.queue.append(SignalProducer.empty.on(completed: observer.sendCompleted)) - } - startNextIfNeeded() - - case .interrupted: - observer.sendInterrupted() - } - } - } -} - -extension SignalProducerProtocol where Value: SignalProducerProtocol, Error == Value.Error { - /// Returns a producer which sends all the values from each producer emitted - /// from `producer`, waiting until each inner producer completes before - /// beginning to send the values from the next inner producer. - /// - /// - note: If any of the inner producers emit an error, the returned - /// producer will emit that error. - /// - /// - note: The returned producer completes only when `producer` and all - /// producers emitted from `producer` complete. - fileprivate func concat() -> SignalProducer { - return SignalProducer { observer, disposable in - self.startWithSignal { signal, signalDisposable in - disposable += signalDisposable - _ = signal.observeConcat(observer, disposable) - } - } - } -} - -extension SignalProducerProtocol { - /// `concat`s `next` onto `self`. - public func concat(_ next: SignalProducer) -> SignalProducer { - return SignalProducer, Error>([ self.producer, next ]).flatten(.concat) - } - - /// `concat`s `value` onto `self`. - public func concat(value: Value) -> SignalProducer { - return self.concat(SignalProducer(value: value)) - } - - /// `concat`s `self` onto initial `previous`. - public func prefix(_ previous: P) -> SignalProducer - where P.Value == Value, P.Error == Error - { - return previous.concat(self.producer) - } - - /// `concat`s `self` onto initial `value`. - public func prefix(value: Value) -> SignalProducer { - return self.prefix(SignalProducer(value: value)) - } -} - -private final class ConcatState { - typealias SignalProducer = ReactiveSwift.SignalProducer - - /// The active producer, if any. - var active: SignalProducer? = nil - - /// The producers waiting to be started. - var queue: [SignalProducer] = [] - - /// Whether the active producer is currently starting. - /// Used to prevent deep recursion. - var isStarting: Bool = false - - /// Dequeue the next producer if one should be started. - /// - /// - note: The caller *must* set `isStarting` to false after the returned - /// producer has been started. - /// - /// - returns: The `SignalProducer` to start or `nil` if no producer should - /// be started. - func dequeue() -> SignalProducer? { - if active != nil { - return nil - } - - active = queue.first - if active != nil { - queue.removeFirst() - isStarting = true - } - return active - } -} - -extension SignalProtocol where Value: SignalProducerProtocol, Error == Value.Error { - /// Merges a `signal` of SignalProducers down into a single signal, biased - /// toward the producer added earlier. Returns a Signal that will forward - /// events from the inner producers as they arrive. - fileprivate func merge() -> Signal { - return Signal { relayObserver in - let disposable = CompositeDisposable() - let relayDisposable = CompositeDisposable() - - disposable += relayDisposable - disposable += self.observeMerge(relayObserver, relayDisposable) - - return disposable - } - } - - fileprivate func observeMerge(_ observer: Observer, _ disposable: CompositeDisposable) -> Disposable? { - let inFlight = Atomic(1) - let decrementInFlight = { - let shouldComplete: Bool = inFlight.modify { - $0 -= 1 - return $0 == 0 - } - - if shouldComplete { - observer.sendCompleted() - } - } - - return self.observe { event in - switch event { - case let .value(producer): - producer.startWithSignal { innerSignal, innerDisposable in - inFlight.modify { $0 += 1 } - let handle = disposable.add(innerDisposable) - - innerSignal.observe { event in - switch event { - case .completed, .interrupted: - handle.remove() - decrementInFlight() - - case .value, .failed: - observer.action(event) - } - } - } - - case let .failed(error): - observer.send(error: error) - - case .completed: - decrementInFlight() - - case .interrupted: - observer.sendInterrupted() - } - } - } -} - -extension SignalProducerProtocol where Value: SignalProducerProtocol, Error == Value.Error { - /// Merges a `signal` of SignalProducers down into a single signal, biased - /// toward the producer added earlier. Returns a Signal that will forward - /// events from the inner producers as they arrive. - fileprivate func merge() -> SignalProducer { - return SignalProducer { relayObserver, disposable in - self.startWithSignal { signal, signalDisposable in - disposable += signalDisposable - - _ = signal.observeMerge(relayObserver, disposable) - } - - } - } -} - -extension SignalProtocol { - /// Merges the given signals into a single `Signal` that will emit all - /// values from each of them, and complete when all of them have completed. - public static func merge(_ signals: Seq) -> Signal - where S.Value == Value, S.Error == Error, Seq.Iterator.Element == S - { - return SignalProducer(signals) - .flatten(.merge) - .startAndRetrieveSignal() - } - - /// Merges the given signals into a single `Signal` that will emit all - /// values from each of them, and complete when all of them have completed. - public static func merge(_ signals: S...) -> Signal - where S.Value == Value, S.Error == Error - { - return Signal.merge(signals) - } -} - -extension SignalProducerProtocol { - /// Merges the given producers into a single `SignalProducer` that will emit - /// all values from each of them, and complete when all of them have - /// completed. - public static func merge(_ producers: Seq) -> SignalProducer - where S.Value == Value, S.Error == Error, Seq.Iterator.Element == S - { - return SignalProducer(producers).flatten(.merge) - } - - /// Merges the given producers into a single `SignalProducer` that will emit - /// all values from each of them, and complete when all of them have - /// completed. - public static func merge(_ producers: S...) -> SignalProducer - where S.Value == Value, S.Error == Error - { - return SignalProducer.merge(producers) - } -} - -extension SignalProtocol where Value: SignalProducerProtocol, Error == Value.Error { - /// Returns a signal that forwards values from the latest signal sent on - /// `signal`, ignoring values sent on previous inner signal. - /// - /// An error sent on `signal` or the latest inner signal will be sent on the - /// returned signal. - /// - /// The returned signal completes when `signal` and the latest inner - /// signal have both completed. - fileprivate func switchToLatest() -> Signal { - return Signal { observer in - let composite = CompositeDisposable() - let serial = SerialDisposable() - - composite += serial - composite += self.observeSwitchToLatest(observer, serial) - - return composite - } - } - - fileprivate func observeSwitchToLatest(_ observer: Observer, _ latestInnerDisposable: SerialDisposable) -> Disposable? { - let state = Atomic(LatestState()) - - return self.observe { event in - switch event { - case let .value(innerProducer): - innerProducer.startWithSignal { innerSignal, innerDisposable in - state.modify { - // When we replace the disposable below, this prevents - // the generated Interrupted event from doing any work. - $0.replacingInnerSignal = true - } - - latestInnerDisposable.inner = innerDisposable - - state.modify { - $0.replacingInnerSignal = false - $0.innerSignalComplete = false - } - - innerSignal.observe { event in - switch event { - case .interrupted: - // If interruption occurred as a result of a new - // producer arriving, we don't want to notify our - // observer. - let shouldComplete: Bool = state.modify { state in - if !state.replacingInnerSignal { - state.innerSignalComplete = true - } - return !state.replacingInnerSignal && state.outerSignalComplete - } - - if shouldComplete { - observer.sendCompleted() - } - - case .completed: - let shouldComplete: Bool = state.modify { - $0.innerSignalComplete = true - return $0.outerSignalComplete - } - - if shouldComplete { - observer.sendCompleted() - } - - case .value, .failed: - observer.action(event) - } - } - } - - case let .failed(error): - observer.send(error: error) - - case .completed: - let shouldComplete: Bool = state.modify { - $0.outerSignalComplete = true - return $0.innerSignalComplete - } - - if shouldComplete { - observer.sendCompleted() - } - - case .interrupted: - observer.sendInterrupted() - } - } - } -} - -extension SignalProducerProtocol where Value: SignalProducerProtocol, Error == Value.Error { - /// Returns a signal that forwards values from the latest signal sent on - /// `signal`, ignoring values sent on previous inner signal. - /// - /// An error sent on `signal` or the latest inner signal will be sent on the - /// returned signal. - /// - /// The returned signal completes when `signal` and the latest inner - /// signal have both completed. - fileprivate func switchToLatest() -> SignalProducer { - return SignalProducer { observer, disposable in - let latestInnerDisposable = SerialDisposable() - disposable += latestInnerDisposable - - self.startWithSignal { signal, signalDisposable in - disposable += signalDisposable - disposable += signal.observeSwitchToLatest(observer, latestInnerDisposable) - } - } - } -} - -private struct LatestState { - var outerSignalComplete: Bool = false - var innerSignalComplete: Bool = true - - var replacingInnerSignal: Bool = false -} - - -extension SignalProtocol { - /// Maps each event from `signal` to a new signal, then flattens the - /// resulting producers (into a signal of values), according to the - /// semantics of the given strategy. - /// - /// If `signal` or any of the created producers fail, the returned signal - /// will forward that failure immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> SignalProducer) -> Signal { - return map(transform).flatten(strategy) - } - - /// Maps each event from `signal` to a new signal, then flattens the - /// resulting producers (into a signal of values), according to the - /// semantics of the given strategy. - /// - /// If `signal` fails, the returned signal will forward that failure - /// immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> SignalProducer) -> Signal { - return map(transform).flatten(strategy) - } - - /// Maps each event from `signal` to a new signal, then flattens the - /// resulting signals (into a signal of values), according to the - /// semantics of the given strategy. - /// - /// If `signal` or any of the created signals emit an error, the returned - /// signal will forward that error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> Signal) -> Signal { - return map(transform).flatten(strategy) - } - - /// Maps each event from `signal` to a new signal, then flattens the - /// resulting signals (into a signal of values), according to the - /// semantics of the given strategy. - /// - /// If `signal` emits an error, the returned signal will forward that - /// error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> Signal) -> Signal { - return map(transform).flatten(strategy) - } - - /// Maps each event from `signal` to a new property, then flattens the - /// resulting properties (into a signal of values), according to the - /// semantics of the given strategy. - /// - /// If `signal` emits an error, the returned signal will forward that - /// error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> P) -> Signal { - return map(transform).flatten(strategy) - } -} - -extension SignalProtocol where Error == NoError { - /// Maps each event from `signal` to a new signal, then flattens the - /// resulting signals (into a signal of values), according to the - /// semantics of the given strategy. - /// - /// If any of the created signals emit an error, the returned signal - /// will forward that error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> SignalProducer) -> Signal { - return map(transform).flatten(strategy) - } - - /// Maps each event from `signal` to a new signal, then flattens the - /// resulting signals (into a signal of values), according to the - /// semantics of the given strategy. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> SignalProducer) -> Signal { - return map(transform).flatten(strategy) - } - - /// Maps each event from `signal` to a new signal, then flattens the - /// resulting signals (into a signal of values), according to the - /// semantics of the given strategy. - /// - /// If any of the created signals emit an error, the returned signal - /// will forward that error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> Signal) -> Signal { - return map(transform).flatten(strategy) - } - - /// Maps each event from `signal` to a new signal, then flattens the - /// resulting signals (into a signal of values), according to the - /// semantics of the given strategy. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> Signal) -> Signal { - return map(transform).flatten(strategy) - } -} - -extension SignalProducerProtocol { - /// Maps each event from `self` to a new producer, then flattens the - /// resulting producers (into a producer of values), according to the - /// semantics of the given strategy. - /// - /// If `self` or any of the created producers fail, the returned producer - /// will forward that failure immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> SignalProducer) -> SignalProducer { - return map(transform).flatten(strategy) - } - - /// Maps each event from `self` to a new producer, then flattens the - /// resulting producers (into a producer of values), according to the - /// semantics of the given strategy. - /// - /// If `self` fails, the returned producer will forward that failure - /// immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> SignalProducer) -> SignalProducer { - return map(transform).flatten(strategy) - } - - /// Maps each event from `self` to a new producer, then flattens the - /// resulting signals (into a producer of values), according to the - /// semantics of the given strategy. - /// - /// If `self` or any of the created signals emit an error, the returned - /// producer will forward that error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> Signal) -> SignalProducer { - return map(transform).flatten(strategy) - } - - /// Maps each event from `self` to a new producer, then flattens the - /// resulting signals (into a producer of values), according to the - /// semantics of the given strategy. - /// - /// If `self` emits an error, the returned producer will forward that - /// error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> Signal) -> SignalProducer { - return map(transform).flatten(strategy) - } - - /// Maps each event from `self` to a new property, then flattens the - /// resulting properties (into a producer of values), according to the - /// semantics of the given strategy. - /// - /// If `self` emits an error, the returned producer will forward that - /// error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> P) -> SignalProducer { - return map(transform).flatten(strategy) - } -} - -extension SignalProducerProtocol where Error == NoError { - /// Maps each event from `self` to a new producer, then flattens the - /// resulting producers (into a producer of values), according to the - /// semantics of the given strategy. - /// - /// If any of the created producers fail, the returned producer will - /// forward that failure immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> SignalProducer) -> SignalProducer { - return map(transform).flatten(strategy) - } - - /// Maps each event from `self` to a new producer, then flattens the - /// resulting producers (into a producer of values), according to the - /// semantics of the given strategy. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> SignalProducer) -> SignalProducer { - return map(transform).flatten(strategy) - } - - /// Maps each event from `self` to a new producer, then flattens the - /// resulting signals (into a producer of values), according to the - /// semantics of the given strategy. - /// - /// If any of the created signals emit an error, the returned - /// producer will forward that error immediately. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> Signal) -> SignalProducer { - return map(transform).flatten(strategy) - } - - /// Maps each event from `self` to a new producer, then flattens the - /// resulting signals (into a producer of values), according to the - /// semantics of the given strategy. - public func flatMap(_ strategy: FlattenStrategy, transform: @escaping (Value) -> Signal) -> SignalProducer { - return map(transform).flatten(strategy) - } -} - - -extension SignalProtocol { - /// Catches any failure that may occur on the input signal, mapping to a new - /// producer that starts in its place. - public func flatMapError(_ handler: @escaping (Error) -> SignalProducer) -> Signal { - return Signal { observer in - self.observeFlatMapError(handler, observer, SerialDisposable()) - } - } - - fileprivate func observeFlatMapError(_ handler: @escaping (Error) -> SignalProducer, _ observer: Observer, _ serialDisposable: SerialDisposable) -> Disposable? { - return self.observe { event in - switch event { - case let .value(value): - observer.send(value: value) - case let .failed(error): - handler(error).startWithSignal { signal, disposable in - serialDisposable.inner = disposable - signal.observe(observer) - } - case .completed: - observer.sendCompleted() - case .interrupted: - observer.sendInterrupted() - } - } - } -} - -extension SignalProducerProtocol { - /// Catches any failure that may occur on the input producer, mapping to a - /// new producer that starts in its place. - public func flatMapError(_ handler: @escaping (Error) -> SignalProducer) -> SignalProducer { - return SignalProducer { observer, disposable in - let serialDisposable = SerialDisposable() - disposable += serialDisposable - - self.startWithSignal { signal, signalDisposable in - serialDisposable.inner = signalDisposable - - _ = signal.observeFlatMapError(handler, observer, serialDisposable) - } - } - } -} diff --git a/Example/Pods/ReactiveSwift/Sources/Lifetime.swift b/Example/Pods/ReactiveSwift/Sources/Lifetime.swift deleted file mode 100644 index 7a8e3c2..0000000 --- a/Example/Pods/ReactiveSwift/Sources/Lifetime.swift +++ /dev/null @@ -1,91 +0,0 @@ -import Foundation -import enum Result.NoError - -/// Represents the lifetime of an object, and provides a hook to observe when -/// the object deinitializes. -public final class Lifetime { - /// MARK: Type properties and methods - - /// Factory method for creating a `Lifetime` and its associated `Token`. - public static func make() -> (lifetime: Lifetime, token: Token) { - let token = Token() - return (Lifetime(token), token) - } - - /// A `Lifetime` that has already ended. - public static var empty: Lifetime { - return Lifetime(ended: .empty) - } - - /// MARK: Instance properties - - /// A signal that sends a `completed` event when the lifetime ends. - /// - /// - note: Consider using `Lifetime.observeEnded` if only a closure observer - /// is to be attached. - public let ended: Signal<(), NoError> - - /// MARK: Initializers - - /// Initialize a `Lifetime` object with the supplied ended signal. - /// - /// - parameters: - /// - signal: The ended signal. - private init(ended signal: Signal<(), NoError>) { - ended = signal - } - - /// Initialize a `Lifetime` from a lifetime token, which is expected to be - /// associated with an object. - /// - /// - important: The resulting lifetime object does not retain the lifetime - /// token. - /// - /// - parameters: - /// - token: A lifetime token for detecting the deinitialization of the - /// associated object. - public convenience init(_ token: Token) { - self.init(ended: token.ended) - } - - /// Observe the termination of `self`. - /// - /// - parameters: - /// - action: The action to be invoked when `self` ends. - /// - /// - returns: A disposable that detaches `action` from the lifetime, or `nil` - /// if `lifetime` has already ended. - @discardableResult - public func observeEnded(_ action: @escaping () -> Void) -> Disposable? { - return ended.observe { event in - if event.isTerminating { - action() - } - } - } - - /// A token object which completes its signal when it deinitializes. - /// - /// It is generally used in conjuncion with `Lifetime` as a private - /// deinitialization trigger. - /// - /// ``` - /// class MyController { - /// private let (lifetime, token) = Lifetime.make() - /// } - /// ``` - public final class Token { - /// A signal that sends a Completed event when the lifetime ends. - fileprivate let ended: Signal<(), NoError> - - private let endedObserver: Signal<(), NoError>.Observer - - public init() { - (ended, endedObserver) = Signal.pipe() - } - - deinit { - endedObserver.sendCompleted() - } - } -}