├── .gitignore ├── .travis.yml ├── Example ├── Podfile ├── Podfile.lock ├── Pods │ ├── Local Podspecs │ │ └── RxSmartBag.podspec.json │ ├── Manifest.lock │ ├── Pods.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── RxSwift │ │ ├── LICENSE.md │ │ ├── Platform │ │ │ ├── DataStructures │ │ │ │ ├── Bag.swift │ │ │ │ ├── InfiniteSequence.swift │ │ │ │ ├── PriorityQueue.swift │ │ │ │ └── Queue.swift │ │ │ ├── DispatchQueue+Extensions.swift │ │ │ ├── Platform.Darwin.swift │ │ │ ├── Platform.Linux.swift │ │ │ └── RecursiveLock.swift │ │ ├── README.md │ │ └── RxSwift │ │ │ ├── AnyObserver.swift │ │ │ ├── Cancelable.swift │ │ │ ├── Concurrency │ │ │ ├── AsyncLock.swift │ │ │ ├── Lock.swift │ │ │ ├── LockOwnerType.swift │ │ │ ├── SynchronizedDisposeType.swift │ │ │ ├── SynchronizedOnType.swift │ │ │ └── SynchronizedUnsubscribeType.swift │ │ │ ├── ConnectableObservableType.swift │ │ │ ├── Deprecated.swift │ │ │ ├── Disposable.swift │ │ │ ├── Disposables │ │ │ ├── AnonymousDisposable.swift │ │ │ ├── BinaryDisposable.swift │ │ │ ├── BooleanDisposable.swift │ │ │ ├── CompositeDisposable.swift │ │ │ ├── Disposables.swift │ │ │ ├── DisposeBag.swift │ │ │ ├── DisposeBase.swift │ │ │ ├── NopDisposable.swift │ │ │ ├── RefCountDisposable.swift │ │ │ ├── ScheduledDisposable.swift │ │ │ ├── SerialDisposable.swift │ │ │ ├── SingleAssignmentDisposable.swift │ │ │ └── SubscriptionDisposable.swift │ │ │ ├── Errors.swift │ │ │ ├── Event.swift │ │ │ ├── Extensions │ │ │ ├── Bag+Rx.swift │ │ │ └── String+Rx.swift │ │ │ ├── GroupedObservable.swift │ │ │ ├── ImmediateSchedulerType.swift │ │ │ ├── Observable.swift │ │ │ ├── ObservableConvertibleType.swift │ │ │ ├── ObservableType+Extensions.swift │ │ │ ├── ObservableType.swift │ │ │ ├── Observables │ │ │ ├── AddRef.swift │ │ │ ├── Amb.swift │ │ │ ├── AsMaybe.swift │ │ │ ├── AsSingle.swift │ │ │ ├── Buffer.swift │ │ │ ├── Catch.swift │ │ │ ├── CombineLatest+Collection.swift │ │ │ ├── CombineLatest+arity.swift │ │ │ ├── CombineLatest.swift │ │ │ ├── Concat.swift │ │ │ ├── Create.swift │ │ │ ├── Debounce.swift │ │ │ ├── Debug.swift │ │ │ ├── DefaultIfEmpty.swift │ │ │ ├── Deferred.swift │ │ │ ├── Delay.swift │ │ │ ├── DelaySubscription.swift │ │ │ ├── Dematerialize.swift │ │ │ ├── DistinctUntilChanged.swift │ │ │ ├── Do.swift │ │ │ ├── ElementAt.swift │ │ │ ├── Empty.swift │ │ │ ├── Enumerated.swift │ │ │ ├── Error.swift │ │ │ ├── Filter.swift │ │ │ ├── First.swift │ │ │ ├── Generate.swift │ │ │ ├── GroupBy.swift │ │ │ ├── Just.swift │ │ │ ├── Map.swift │ │ │ ├── Materialize.swift │ │ │ ├── Merge.swift │ │ │ ├── Multicast.swift │ │ │ ├── Never.swift │ │ │ ├── ObserveOn.swift │ │ │ ├── Optional.swift │ │ │ ├── Producer.swift │ │ │ ├── Range.swift │ │ │ ├── Reduce.swift │ │ │ ├── Repeat.swift │ │ │ ├── RetryWhen.swift │ │ │ ├── Sample.swift │ │ │ ├── Scan.swift │ │ │ ├── Sequence.swift │ │ │ ├── ShareReplayScope.swift │ │ │ ├── SingleAsync.swift │ │ │ ├── Sink.swift │ │ │ ├── Skip.swift │ │ │ ├── SkipUntil.swift │ │ │ ├── SkipWhile.swift │ │ │ ├── StartWith.swift │ │ │ ├── SubscribeOn.swift │ │ │ ├── Switch.swift │ │ │ ├── SwitchIfEmpty.swift │ │ │ ├── Take.swift │ │ │ ├── TakeLast.swift │ │ │ ├── TakeUntil.swift │ │ │ ├── TakeWhile.swift │ │ │ ├── Throttle.swift │ │ │ ├── Timeout.swift │ │ │ ├── Timer.swift │ │ │ ├── ToArray.swift │ │ │ ├── Using.swift │ │ │ ├── Window.swift │ │ │ ├── WithLatestFrom.swift │ │ │ ├── Zip+Collection.swift │ │ │ ├── Zip+arity.swift │ │ │ └── Zip.swift │ │ │ ├── ObserverType.swift │ │ │ ├── Observers │ │ │ ├── AnonymousObserver.swift │ │ │ ├── ObserverBase.swift │ │ │ └── TailRecursiveSink.swift │ │ │ ├── Reactive.swift │ │ │ ├── Rx.swift │ │ │ ├── RxMutableBox.swift │ │ │ ├── SchedulerType.swift │ │ │ ├── Schedulers │ │ │ ├── ConcurrentDispatchQueueScheduler.swift │ │ │ ├── ConcurrentMainScheduler.swift │ │ │ ├── CurrentThreadScheduler.swift │ │ │ ├── HistoricalScheduler.swift │ │ │ ├── HistoricalSchedulerTimeConverter.swift │ │ │ ├── Internal │ │ │ │ ├── DispatchQueueConfiguration.swift │ │ │ │ ├── InvocableScheduledItem.swift │ │ │ │ ├── InvocableType.swift │ │ │ │ ├── ScheduledItem.swift │ │ │ │ └── ScheduledItemType.swift │ │ │ ├── MainScheduler.swift │ │ │ ├── OperationQueueScheduler.swift │ │ │ ├── RecursiveScheduler.swift │ │ │ ├── SchedulerServices+Emulation.swift │ │ │ ├── SerialDispatchQueueScheduler.swift │ │ │ ├── VirtualTimeConverterType.swift │ │ │ └── VirtualTimeScheduler.swift │ │ │ ├── Subjects │ │ │ ├── AsyncSubject.swift │ │ │ ├── BehaviorSubject.swift │ │ │ ├── PublishSubject.swift │ │ │ ├── ReplaySubject.swift │ │ │ └── SubjectType.swift │ │ │ ├── SwiftSupport │ │ │ └── SwiftSupport.swift │ │ │ └── Traits │ │ │ ├── Completable+AndThen.swift │ │ │ ├── Completable.swift │ │ │ ├── Maybe.swift │ │ │ ├── ObservableType+PrimitiveSequence.swift │ │ │ ├── PrimitiveSequence+Zip+arity.swift │ │ │ ├── PrimitiveSequence.swift │ │ │ └── Single.swift │ └── Target Support Files │ │ ├── Pods-RxSmartBag_Example │ │ ├── Info.plist │ │ ├── Pods-RxSmartBag_Example-acknowledgements.markdown │ │ ├── Pods-RxSmartBag_Example-acknowledgements.plist │ │ ├── Pods-RxSmartBag_Example-dummy.m │ │ ├── Pods-RxSmartBag_Example-frameworks.sh │ │ ├── Pods-RxSmartBag_Example-resources.sh │ │ ├── Pods-RxSmartBag_Example-umbrella.h │ │ ├── Pods-RxSmartBag_Example.debug.xcconfig │ │ ├── Pods-RxSmartBag_Example.modulemap │ │ └── Pods-RxSmartBag_Example.release.xcconfig │ │ ├── Pods-RxSmartBag_Tests │ │ ├── Info.plist │ │ ├── Pods-RxSmartBag_Tests-acknowledgements.markdown │ │ ├── Pods-RxSmartBag_Tests-acknowledgements.plist │ │ ├── Pods-RxSmartBag_Tests-dummy.m │ │ ├── Pods-RxSmartBag_Tests-frameworks.sh │ │ ├── Pods-RxSmartBag_Tests-resources.sh │ │ ├── Pods-RxSmartBag_Tests-umbrella.h │ │ ├── Pods-RxSmartBag_Tests.debug.xcconfig │ │ ├── Pods-RxSmartBag_Tests.modulemap │ │ └── Pods-RxSmartBag_Tests.release.xcconfig │ │ ├── RxSmartBag │ │ ├── Info.plist │ │ ├── RxSmartBag-dummy.m │ │ ├── RxSmartBag-prefix.pch │ │ ├── RxSmartBag-umbrella.h │ │ ├── RxSmartBag.modulemap │ │ └── RxSmartBag.xcconfig │ │ └── RxSwift │ │ ├── Info.plist │ │ ├── RxSwift-dummy.m │ │ ├── RxSwift-prefix.pch │ │ ├── RxSwift-umbrella.h │ │ ├── RxSwift.modulemap │ │ └── RxSwift.xcconfig ├── RxSmartBag.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ └── RxSmartBag-Example.xcscheme ├── RxSmartBag.xcworkspace │ └── contents.xcworkspacedata ├── RxSmartBag │ ├── AppDelegate.swift │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── UIViewControllerExtension.swift │ └── ViewController.swift └── Tests │ └── Info.plist ├── LICENSE ├── README.md ├── RxSmartBag.podspec ├── RxSmartBag ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ └── RxSmartBag.swift └── _Pods.xcodeproj /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | ## Build generated 5 | build/ 6 | DerivedData/ 7 | 8 | ## Various settings 9 | *.pbxuser 10 | !default.pbxuser 11 | *.mode1v3 12 | !default.mode1v3 13 | *.mode2v3 14 | !default.mode2v3 15 | *.perspectivev3 16 | !default.perspectivev3 17 | xcuserdata/ 18 | *.xccheckout 19 | profile 20 | *.moved-aside 21 | DerivedData 22 | *.hmap 23 | *.ipa 24 | 25 | # Bundler 26 | .bundle 27 | 28 | Carthage 29 | # We recommend against adding the Pods directory to your .gitignore. However 30 | # you should judge for yourself, the pros and cons are mentioned at: 31 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 32 | # 33 | # Note: if you ignore the Pods directory, make sure to uncomment 34 | # `pod install` in .travis.yml 35 | # 36 | # Pods/ 37 | 38 | ## Other 39 | *.moved-aside 40 | *.xcuserstate 41 | 42 | ## Obj-C/Swift specific 43 | *.hmap 44 | *.ipa 45 | *.dSYM.zip 46 | *.dSYM 47 | 48 | ## Playgrounds 49 | timeline.xctimeline 50 | playground.xcworkspace 51 | 52 | # Swift Package Manager 53 | # 54 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 55 | # Packages/ 56 | .build/ 57 | 58 | # CocoaPods 59 | # 60 | # We recommend against adding the Pods directory to your .gitignore. However 61 | # you should judge for yourself, the pros and cons are mentioned at: 62 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 63 | # 64 | # Pods/ 65 | 66 | # Carthage 67 | # 68 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 69 | # Carthage/Checkouts 70 | 71 | Carthage/Build 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 76 | # screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots 83 | fastlane/test_output 84 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode7.3 6 | language: objective-c 7 | # cache: cocoapods 8 | # podfile: Example/Podfile 9 | # before_install: 10 | # - gem install cocoapods # Since Travis is not always on latest version 11 | # - pod install --project-directory=Example 12 | script: 13 | - set -o pipefail && xcodebuild test -workspace Example/RxSmartBag.xcworkspace -scheme RxSmartBag-Example -sdk iphonesimulator9.3 ONLY_ACTIVE_ARCH=NO | xcpretty 14 | - pod lib lint 15 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target 'RxSmartBag_Example' do 4 | pod 'RxSmartBag', :path => '../' 5 | target 'RxSmartBag_Tests' do 6 | inherit! :search_paths 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - RxSmartBag (2.0.0): 3 | - RxSwift (~> 4.0) 4 | - RxSwift (4.0.0) 5 | 6 | DEPENDENCIES: 7 | - RxSmartBag (from `../`) 8 | 9 | EXTERNAL SOURCES: 10 | RxSmartBag: 11 | :path: ../ 12 | 13 | SPEC CHECKSUMS: 14 | RxSmartBag: c1f54b5d0e1ccfc583db60253083479465f2c038 15 | RxSwift: fd680d75283beb5e2559486f3c0ff852f0d35334 16 | 17 | PODFILE CHECKSUM: a425ec67ec5739ed326ab08a62b5e07b0e809f03 18 | 19 | COCOAPODS: 1.2.1 20 | -------------------------------------------------------------------------------- /Example/Pods/Local Podspecs/RxSmartBag.podspec.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "RxSmartBag", 3 | "version": "2.0.0", 4 | "summary": "A useful dispose bag for RxSwift.", 5 | "description": "A simple way to omit declararing DisposeBag.", 6 | "homepage": "https://github.com/rinov/RxSmartBag", 7 | "license": { 8 | "type": "MIT", 9 | "file": "LICENSE" 10 | }, 11 | "authors": { 12 | "rinov": "rinov@rinov.jp" 13 | }, 14 | "source": { 15 | "git": "https://github.com/rinov/RxSmartBag.git", 16 | "tag": "2.0.0" 17 | }, 18 | "platforms": { 19 | "ios": "8.0" 20 | }, 21 | "source_files": "RxSmartBag/Classes/**/*", 22 | "dependencies": { 23 | "RxSwift": [ 24 | "~> 4.0" 25 | ] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Example/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - RxSmartBag (2.0.0): 3 | - RxSwift (~> 4.0) 4 | - RxSwift (4.0.0) 5 | 6 | DEPENDENCIES: 7 | - RxSmartBag (from `../`) 8 | 9 | EXTERNAL SOURCES: 10 | RxSmartBag: 11 | :path: ../ 12 | 13 | SPEC CHECKSUMS: 14 | RxSmartBag: c1f54b5d0e1ccfc583db60253083479465f2c038 15 | RxSwift: fd680d75283beb5e2559486f3c0ff852f0d35334 16 | 17 | PODFILE CHECKSUM: a425ec67ec5739ed326ab08a62b5e07b0e809f03 18 | 19 | COCOAPODS: 1.2.1 20 | -------------------------------------------------------------------------------- /Example/Pods/Pods.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/LICENSE.md: -------------------------------------------------------------------------------- 1 | **The MIT License** 2 | **Copyright © 2015 Krunoslav Zaher** 3 | **All rights reserved.** 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/DataStructures/InfiniteSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InfiniteSequence.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Sequence that repeats `repeatedValue` infinite number of times. 10 | struct InfiniteSequence : Sequence { 11 | typealias Element = E 12 | typealias Iterator = AnyIterator 13 | 14 | private let _repeatedValue: E 15 | 16 | init(repeatedValue: E) { 17 | _repeatedValue = repeatedValue 18 | } 19 | 20 | func makeIterator() -> Iterator { 21 | let repeatedValue = _repeatedValue 22 | return AnyIterator { 23 | return repeatedValue 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/DispatchQueue+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DispatchQueue+Extensions.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 10/22/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Dispatch 10 | 11 | extension DispatchQueue { 12 | private static var token: DispatchSpecificKey<()> = { 13 | let key = DispatchSpecificKey<()>() 14 | DispatchQueue.main.setSpecific(key: key, value: ()) 15 | return key 16 | }() 17 | 18 | static var isMain: Bool { 19 | return DispatchQueue.getSpecific(key: token) != nil 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/Platform.Darwin.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Platform.Darwin.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) 10 | 11 | import Darwin 12 | import class Foundation.Thread 13 | import func Foundation.OSAtomicCompareAndSwap32Barrier 14 | import func Foundation.OSAtomicIncrement32Barrier 15 | import func Foundation.OSAtomicDecrement32Barrier 16 | import protocol Foundation.NSCopying 17 | 18 | typealias AtomicInt = Int32 19 | 20 | fileprivate func castToUInt32Pointer(_ pointer: UnsafeMutablePointer) -> UnsafeMutablePointer { 21 | let raw = UnsafeMutableRawPointer(pointer) 22 | return raw.assumingMemoryBound(to: UInt32.self) 23 | } 24 | 25 | let AtomicCompareAndSwap = OSAtomicCompareAndSwap32Barrier 26 | let AtomicIncrement = OSAtomicIncrement32Barrier 27 | let AtomicDecrement = OSAtomicDecrement32Barrier 28 | func AtomicOr(_ mask: UInt32, _ theValue : UnsafeMutablePointer) -> Int32 { 29 | return OSAtomicOr32OrigBarrier(mask, castToUInt32Pointer(theValue)) 30 | } 31 | func AtomicFlagSet(_ mask: UInt32, _ theValue : UnsafeMutablePointer) -> Bool { 32 | // just used to create a barrier 33 | OSAtomicXor32OrigBarrier(0, castToUInt32Pointer(theValue)) 34 | return (theValue.pointee & Int32(mask)) != 0 35 | } 36 | 37 | extension Thread { 38 | 39 | static func setThreadLocalStorageValue(_ value: T?, forKey key: NSCopying 40 | ) { 41 | let currentThread = Thread.current 42 | let threadDictionary = currentThread.threadDictionary 43 | 44 | if let newValue = value { 45 | threadDictionary[key] = newValue 46 | } 47 | else { 48 | threadDictionary[key] = nil 49 | } 50 | 51 | } 52 | static func getThreadLocalStorageValueForKey(_ key: NSCopying) -> T? { 53 | let currentThread = Thread.current 54 | let threadDictionary = currentThread.threadDictionary 55 | 56 | return threadDictionary[key] as? T 57 | } 58 | } 59 | 60 | extension AtomicInt { 61 | func valueSnapshot() -> Int32 { 62 | return self 63 | } 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/Platform.Linux.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Platform.Linux.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(Linux) 10 | 11 | import XCTest 12 | import Glibc 13 | import SwiftShims 14 | import class Foundation.Thread 15 | 16 | final class AtomicInt { 17 | typealias IntegerLiteralType = Int 18 | fileprivate var value: Int32 = 0 19 | fileprivate var _lock = RecursiveLock() 20 | 21 | func lock() { 22 | _lock.lock() 23 | } 24 | func unlock() { 25 | _lock.unlock() 26 | } 27 | 28 | func valueSnapshot() -> Int32 { 29 | return value 30 | } 31 | } 32 | 33 | extension AtomicInt: ExpressibleByIntegerLiteral { 34 | convenience init(integerLiteral value: Int) { 35 | self.init() 36 | self.value = Int32(value) 37 | } 38 | } 39 | 40 | func >(lhs: AtomicInt, rhs: Int32) -> Bool { 41 | return lhs.value > rhs 42 | } 43 | func ==(lhs: AtomicInt, rhs: Int32) -> Bool { 44 | return lhs.value == rhs 45 | } 46 | 47 | func AtomicFlagSet(_ mask: UInt32, _ atomic: inout AtomicInt) -> Bool { 48 | atomic.lock(); defer { atomic.unlock() } 49 | return (atomic.value & Int32(mask)) != 0 50 | } 51 | 52 | func AtomicOr(_ mask: UInt32, _ atomic: inout AtomicInt) -> Int32 { 53 | atomic.lock(); defer { atomic.unlock() } 54 | let value = atomic.value 55 | atomic.value |= Int32(mask) 56 | return value 57 | } 58 | 59 | func AtomicIncrement(_ atomic: inout AtomicInt) -> Int32 { 60 | atomic.lock(); defer { atomic.unlock() } 61 | atomic.value += 1 62 | return atomic.value 63 | } 64 | 65 | func AtomicDecrement(_ atomic: inout AtomicInt) -> Int32 { 66 | atomic.lock(); defer { atomic.unlock() } 67 | atomic.value -= 1 68 | return atomic.value 69 | } 70 | 71 | func AtomicCompareAndSwap(_ l: Int32, _ r: Int32, _ atomic: inout AtomicInt) -> Bool { 72 | atomic.lock(); defer { atomic.unlock() } 73 | if atomic.value == l { 74 | atomic.value = r 75 | return true 76 | } 77 | 78 | return false 79 | } 80 | 81 | extension Thread { 82 | 83 | static func setThreadLocalStorageValue(_ value: T?, forKey key: String) { 84 | let currentThread = Thread.current 85 | var threadDictionary = currentThread.threadDictionary 86 | 87 | if let newValue = value { 88 | threadDictionary[key] = newValue 89 | } 90 | else { 91 | threadDictionary[key] = nil 92 | } 93 | 94 | currentThread.threadDictionary = threadDictionary 95 | } 96 | 97 | static func getThreadLocalStorageValueForKey(_ key: String) -> T? { 98 | let currentThread = Thread.current 99 | let threadDictionary = currentThread.threadDictionary 100 | 101 | return threadDictionary[key] as? T 102 | } 103 | } 104 | 105 | #endif 106 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/Platform/RecursiveLock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RecursiveLock.swift 3 | // Platform 4 | // 5 | // Created by Krunoslav Zaher on 12/18/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import class Foundation.NSRecursiveLock 10 | 11 | #if TRACE_RESOURCES 12 | class RecursiveLock: NSRecursiveLock { 13 | override init() { 14 | _ = Resources.incrementTotal() 15 | super.init() 16 | } 17 | 18 | override func lock() { 19 | super.lock() 20 | _ = Resources.incrementTotal() 21 | } 22 | 23 | override func unlock() { 24 | super.unlock() 25 | _ = Resources.decrementTotal() 26 | } 27 | 28 | deinit { 29 | _ = Resources.decrementTotal() 30 | } 31 | } 32 | #else 33 | typealias RecursiveLock = NSRecursiveLock 34 | #endif 35 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/AnyObserver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnyObserver.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// A type-erased `ObserverType`. 10 | /// 11 | /// Forwards operations to an arbitrary underlying observer with the same `Element` type, hiding the specifics of the underlying observer type. 12 | public struct AnyObserver : ObserverType { 13 | /// The type of elements in sequence that observer can observe. 14 | public typealias E = Element 15 | 16 | /// Anonymous event handler type. 17 | public typealias EventHandler = (Event) -> Void 18 | 19 | private let observer: EventHandler 20 | 21 | /// Construct an instance whose `on(event)` calls `eventHandler(event)` 22 | /// 23 | /// - parameter eventHandler: Event handler that observes sequences events. 24 | public init(eventHandler: @escaping EventHandler) { 25 | self.observer = eventHandler 26 | } 27 | 28 | /// Construct an instance whose `on(event)` calls `observer.on(event)` 29 | /// 30 | /// - parameter observer: Observer that receives sequence events. 31 | public init(_ observer: O) where O.E == Element { 32 | self.observer = observer.on 33 | } 34 | 35 | /// Send `event` to this observer. 36 | /// 37 | /// - parameter event: Event instance. 38 | public func on(_ event: Event) { 39 | return self.observer(event) 40 | } 41 | 42 | /// Erases type of observer and returns canonical observer. 43 | /// 44 | /// - returns: type erased observer. 45 | public func asObserver() -> AnyObserver { 46 | return self 47 | } 48 | } 49 | 50 | extension AnyObserver { 51 | /// Collection of `AnyObserver`s 52 | typealias s = Bag<(Event) -> ()> 53 | } 54 | 55 | extension ObserverType { 56 | /// Erases type of observer and returns canonical observer. 57 | /// 58 | /// - returns: type erased observer. 59 | public func asObserver() -> AnyObserver { 60 | return AnyObserver(self) 61 | } 62 | 63 | /// Transforms observer of type R to type E using custom transform method. 64 | /// Each event sent to result observer is transformed and sent to `self`. 65 | /// 66 | /// - returns: observer that transforms events. 67 | public func mapObserver(_ transform: @escaping (R) throws -> E) -> AnyObserver { 68 | return AnyObserver { e in 69 | self.on(e.map(transform)) 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Cancelable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Cancelable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents disposable resource with state tracking. 10 | public protocol Cancelable : Disposable { 11 | /// Was resource disposed. 12 | var isDisposed: Bool { get } 13 | } 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AsyncLock.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /** 10 | In case nobody holds this lock, the work will be queued and executed immediately 11 | on thread that is requesting lock. 12 | 13 | In case there is somebody currently holding that lock, action will be enqueued. 14 | When owned of the lock finishes with it's processing, it will also execute 15 | and pending work. 16 | 17 | That means that enqueued work could possibly be executed later on a different thread. 18 | */ 19 | final class AsyncLock 20 | : Disposable 21 | , Lock 22 | , SynchronizedDisposeType { 23 | typealias Action = () -> Void 24 | 25 | var _lock = SpinLock() 26 | 27 | private var _queue: Queue = Queue(capacity: 0) 28 | 29 | private var _isExecuting: Bool = false 30 | private var _hasFaulted: Bool = false 31 | 32 | // lock { 33 | func lock() { 34 | _lock.lock() 35 | } 36 | 37 | func unlock() { 38 | _lock.unlock() 39 | } 40 | // } 41 | 42 | private func enqueue(_ action: I) -> I? { 43 | _lock.lock(); defer { _lock.unlock() } // { 44 | if _hasFaulted { 45 | return nil 46 | } 47 | 48 | if _isExecuting { 49 | _queue.enqueue(action) 50 | return nil 51 | } 52 | 53 | _isExecuting = true 54 | 55 | return action 56 | // } 57 | } 58 | 59 | private func dequeue() -> I? { 60 | _lock.lock(); defer { _lock.unlock() } // { 61 | if _queue.count > 0 { 62 | return _queue.dequeue() 63 | } 64 | else { 65 | _isExecuting = false 66 | return nil 67 | } 68 | // } 69 | } 70 | 71 | func invoke(_ action: I) { 72 | let firstEnqueuedAction = enqueue(action) 73 | 74 | if let firstEnqueuedAction = firstEnqueuedAction { 75 | firstEnqueuedAction.invoke() 76 | } 77 | else { 78 | // action is enqueued, it's somebody else's concern now 79 | return 80 | } 81 | 82 | while true { 83 | let nextAction = dequeue() 84 | 85 | if let nextAction = nextAction { 86 | nextAction.invoke() 87 | } 88 | else { 89 | return 90 | } 91 | } 92 | } 93 | 94 | func dispose() { 95 | synchronizedDispose() 96 | } 97 | 98 | func _synchronized_dispose() { 99 | _queue = Queue(capacity: 0) 100 | _hasFaulted = true 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/Lock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Lock.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/31/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol Lock { 10 | func lock() 11 | func unlock() 12 | } 13 | 14 | // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html 15 | typealias SpinLock = RecursiveLock 16 | 17 | extension RecursiveLock : Lock { 18 | @inline(__always) 19 | final func performLocked(_ action: () -> Void) { 20 | lock(); defer { unlock() } 21 | action() 22 | } 23 | 24 | @inline(__always) 25 | final func calculateLocked(_ action: () -> T) -> T { 26 | lock(); defer { unlock() } 27 | return action() 28 | } 29 | 30 | @inline(__always) 31 | final func calculateLockedOrFail(_ action: () throws -> T) throws -> T { 32 | lock(); defer { unlock() } 33 | let result = try action() 34 | return result 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LockOwnerType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol LockOwnerType : class, Lock { 10 | var _lock: RecursiveLock { get } 11 | } 12 | 13 | extension LockOwnerType { 14 | func lock() { 15 | _lock.lock() 16 | } 17 | 18 | func unlock() { 19 | _lock.unlock() 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedDisposeType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol SynchronizedDisposeType : class, Disposable, Lock { 10 | func _synchronized_dispose() 11 | } 12 | 13 | extension SynchronizedDisposeType { 14 | func synchronizedDispose() { 15 | lock(); defer { unlock() } 16 | _synchronized_dispose() 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedOnType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol SynchronizedOnType : class, ObserverType, Lock { 10 | func _synchronized_on(_ event: Event) 11 | } 12 | 13 | extension SynchronizedOnType { 14 | func synchronizedOn(_ event: Event) { 15 | lock(); defer { unlock() } 16 | _synchronized_on(event) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedUnsubscribeType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol SynchronizedUnsubscribeType : class { 10 | associatedtype DisposeKey 11 | 12 | func synchronizedUnsubscribe(_ disposeKey: DisposeKey) 13 | } 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ConnectableObservableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectableObservableType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /** 10 | Represents an observable sequence wrapper that can be connected and disconnected from its underlying observable sequence. 11 | */ 12 | public protocol ConnectableObservableType : ObservableType { 13 | /** 14 | Connects the observable wrapper to its source. All subscribed observers will receive values from the underlying observable sequence as long as the connection is established. 15 | 16 | - returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence. 17 | */ 18 | func connect() -> Disposable 19 | } 20 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Disposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Respresents a disposable resource. 10 | public protocol Disposable { 11 | /// Dispose resource. 12 | func dispose() 13 | } 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents an Action-based disposable. 10 | /// 11 | /// When dispose method is called, disposal action will be dereferenced. 12 | fileprivate final class AnonymousDisposable : DisposeBase, Cancelable { 13 | public typealias DisposeAction = () -> Void 14 | 15 | private var _isDisposed: AtomicInt = 0 16 | private var _disposeAction: DisposeAction? 17 | 18 | /// - returns: Was resource disposed. 19 | public var isDisposed: Bool { 20 | return _isDisposed == 1 21 | } 22 | 23 | /// Constructs a new disposable with the given action used for disposal. 24 | /// 25 | /// - parameter disposeAction: Disposal action which will be run upon calling `dispose`. 26 | fileprivate init(_ disposeAction: @escaping DisposeAction) { 27 | _disposeAction = disposeAction 28 | super.init() 29 | } 30 | 31 | // Non-deprecated version of the constructor, used by `Disposables.create(with:)` 32 | fileprivate init(disposeAction: @escaping DisposeAction) { 33 | _disposeAction = disposeAction 34 | super.init() 35 | } 36 | 37 | /// Calls the disposal action if and only if the current instance hasn't been disposed yet. 38 | /// 39 | /// After invoking disposal action, disposal action will be dereferenced. 40 | fileprivate func dispose() { 41 | if AtomicCompareAndSwap(0, 1, &_isDisposed) { 42 | assert(_isDisposed == 1) 43 | 44 | if let action = _disposeAction { 45 | _disposeAction = nil 46 | action() 47 | } 48 | } 49 | } 50 | } 51 | 52 | extension Disposables { 53 | 54 | /// Constructs a new disposable with the given action used for disposal. 55 | /// 56 | /// - parameter dispose: Disposal action which will be run upon calling `dispose`. 57 | public static func create(with dispose: @escaping () -> ()) -> Cancelable { 58 | return AnonymousDisposable(disposeAction: dispose) 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents two disposable resources that are disposed together. 10 | private final class BinaryDisposable : DisposeBase, Cancelable { 11 | 12 | private var _isDisposed: AtomicInt = 0 13 | 14 | // state 15 | private var _disposable1: Disposable? 16 | private var _disposable2: Disposable? 17 | 18 | /// - returns: Was resource disposed. 19 | var isDisposed: Bool { 20 | return _isDisposed > 0 21 | } 22 | 23 | /// Constructs new binary disposable from two disposables. 24 | /// 25 | /// - parameter disposable1: First disposable 26 | /// - parameter disposable2: Second disposable 27 | init(_ disposable1: Disposable, _ disposable2: Disposable) { 28 | _disposable1 = disposable1 29 | _disposable2 = disposable2 30 | super.init() 31 | } 32 | 33 | /// Calls the disposal action if and only if the current instance hasn't been disposed yet. 34 | /// 35 | /// After invoking disposal action, disposal action will be dereferenced. 36 | func dispose() { 37 | if AtomicCompareAndSwap(0, 1, &_isDisposed) { 38 | _disposable1?.dispose() 39 | _disposable2?.dispose() 40 | _disposable1 = nil 41 | _disposable2 = nil 42 | } 43 | } 44 | } 45 | 46 | extension Disposables { 47 | 48 | /// Creates a disposable with the given disposables. 49 | public static func create(_ disposable1: Disposable, _ disposable2: Disposable) -> Cancelable { 50 | return BinaryDisposable(disposable1, disposable2) 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BooleanDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Junior B. on 10/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents a disposable resource that can be checked for disposal status. 10 | public final class BooleanDisposable : Cancelable { 11 | 12 | internal static let BooleanDisposableTrue = BooleanDisposable(isDisposed: true) 13 | private var _isDisposed = false 14 | 15 | /// Initializes a new instance of the `BooleanDisposable` class 16 | public init() { 17 | } 18 | 19 | /// Initializes a new instance of the `BooleanDisposable` class with given value 20 | public init(isDisposed: Bool) { 21 | self._isDisposed = isDisposed 22 | } 23 | 24 | /// - returns: Was resource disposed. 25 | public var isDisposed: Bool { 26 | return _isDisposed 27 | } 28 | 29 | /// Sets the status to disposed, which can be observer through the `isDisposed` property. 30 | public func dispose() { 31 | _isDisposed = true 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/Disposables.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Disposables.swift 3 | // RxSwift 4 | // 5 | // Created by Mohsen Ramezanpoor on 01/08/2016. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// A collection of utility methods for common disposable operations. 10 | public struct Disposables { 11 | private init() {} 12 | } 13 | 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisposeBag.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension Disposable { 10 | /// Adds `self` to `bag` 11 | /// 12 | /// - parameter bag: `DisposeBag` to add `self` to. 13 | public func disposed(by bag: DisposeBag) { 14 | bag.insert(self) 15 | } 16 | } 17 | 18 | /** 19 | Thread safe bag that disposes added disposables on `deinit`. 20 | 21 | This returns ARC (RAII) like resource management to `RxSwift`. 22 | 23 | In case contained disposables need to be disposed, just put a different dispose bag 24 | or create a new one in its place. 25 | 26 | self.existingDisposeBag = DisposeBag() 27 | 28 | In case explicit disposal is necessary, there is also `CompositeDisposable`. 29 | */ 30 | public final class DisposeBag: DisposeBase { 31 | 32 | private var _lock = SpinLock() 33 | 34 | // state 35 | private var _disposables = [Disposable]() 36 | private var _isDisposed = false 37 | 38 | /// Constructs new empty dispose bag. 39 | public override init() { 40 | super.init() 41 | } 42 | 43 | /// Adds `disposable` to be disposed when dispose bag is being deinited. 44 | /// 45 | /// - parameter disposable: Disposable to add. 46 | public func insert(_ disposable: Disposable) { 47 | _insert(disposable)?.dispose() 48 | } 49 | 50 | private func _insert(_ disposable: Disposable) -> Disposable? { 51 | _lock.lock(); defer { _lock.unlock() } 52 | if _isDisposed { 53 | return disposable 54 | } 55 | 56 | _disposables.append(disposable) 57 | 58 | return nil 59 | } 60 | 61 | /// This is internal on purpose, take a look at `CompositeDisposable` instead. 62 | private func dispose() { 63 | let oldDisposables = _dispose() 64 | 65 | for disposable in oldDisposables { 66 | disposable.dispose() 67 | } 68 | } 69 | 70 | private func _dispose() -> [Disposable] { 71 | _lock.lock(); defer { _lock.unlock() } 72 | 73 | let disposables = _disposables 74 | 75 | _disposables.removeAll(keepingCapacity: false) 76 | _isDisposed = true 77 | 78 | return disposables 79 | } 80 | 81 | deinit { 82 | dispose() 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisposeBase.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Base class for all disposables. 10 | public class DisposeBase { 11 | init() { 12 | #if TRACE_RESOURCES 13 | let _ = Resources.incrementTotal() 14 | #endif 15 | } 16 | 17 | deinit { 18 | #if TRACE_RESOURCES 19 | let _ = Resources.decrementTotal() 20 | #endif 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NopDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents a disposable that does nothing on disposal. 10 | /// 11 | /// Nop = No Operation 12 | fileprivate struct NopDisposable : Disposable { 13 | 14 | fileprivate static let noOp: Disposable = NopDisposable() 15 | 16 | fileprivate init() { 17 | 18 | } 19 | 20 | /// Does nothing. 21 | public func dispose() { 22 | } 23 | } 24 | 25 | extension Disposables { 26 | /** 27 | Creates a disposable that does nothing on disposal. 28 | */ 29 | static public func create() -> Disposable { 30 | return NopDisposable.noOp 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | private let disposeScheduledDisposable: (ScheduledDisposable) -> Disposable = { sd in 10 | sd.disposeInner() 11 | return Disposables.create() 12 | } 13 | 14 | /// Represents a disposable resource whose disposal invocation will be scheduled on the specified scheduler. 15 | public final class ScheduledDisposable : Cancelable { 16 | public let scheduler: ImmediateSchedulerType 17 | 18 | private var _isDisposed: AtomicInt = 0 19 | 20 | // state 21 | private var _disposable: Disposable? 22 | 23 | /// - returns: Was resource disposed. 24 | public var isDisposed: Bool { 25 | return _isDisposed == 1 26 | } 27 | 28 | /** 29 | Initializes a new instance of the `ScheduledDisposable` that uses a `scheduler` on which to dispose the `disposable`. 30 | 31 | - parameter scheduler: Scheduler where the disposable resource will be disposed on. 32 | - parameter disposable: Disposable resource to dispose on the given scheduler. 33 | */ 34 | public init(scheduler: ImmediateSchedulerType, disposable: Disposable) { 35 | self.scheduler = scheduler 36 | _disposable = disposable 37 | } 38 | 39 | /// Disposes the wrapped disposable on the provided scheduler. 40 | public func dispose() { 41 | let _ = scheduler.schedule(self, action: disposeScheduledDisposable) 42 | } 43 | 44 | func disposeInner() { 45 | if AtomicCompareAndSwap(0, 1, &_isDisposed) { 46 | _disposable!.dispose() 47 | _disposable = nil 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SerialDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource. 10 | public final class SerialDisposable : DisposeBase, Cancelable { 11 | private var _lock = SpinLock() 12 | 13 | // state 14 | private var _current = nil as Disposable? 15 | private var _isDisposed = false 16 | 17 | /// - returns: Was resource disposed. 18 | public var isDisposed: Bool { 19 | return _isDisposed 20 | } 21 | 22 | /// Initializes a new instance of the `SerialDisposable`. 23 | override public init() { 24 | super.init() 25 | } 26 | 27 | /** 28 | Gets or sets the underlying disposable. 29 | 30 | Assigning this property disposes the previous disposable object. 31 | 32 | If the `SerialDisposable` has already been disposed, assignment to this property causes immediate disposal of the given disposable object. 33 | */ 34 | public var disposable: Disposable { 35 | get { 36 | return _lock.calculateLocked { 37 | return self.disposable 38 | } 39 | } 40 | set (newDisposable) { 41 | let disposable: Disposable? = _lock.calculateLocked { 42 | if _isDisposed { 43 | return newDisposable 44 | } 45 | else { 46 | let toDispose = _current 47 | _current = newDisposable 48 | return toDispose 49 | } 50 | } 51 | 52 | if let disposable = disposable { 53 | disposable.dispose() 54 | } 55 | } 56 | } 57 | 58 | /// Disposes the underlying disposable as well as all future replacements. 59 | public func dispose() { 60 | _dispose()?.dispose() 61 | } 62 | 63 | private func _dispose() -> Disposable? { 64 | _lock.lock(); defer { _lock.unlock() } 65 | if _isDisposed { 66 | return nil 67 | } 68 | else { 69 | _isDisposed = true 70 | let current = _current 71 | _current = nil 72 | return current 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SingleAssignmentDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /** 10 | Represents a disposable resource which only allows a single assignment of its underlying disposable resource. 11 | 12 | If an underlying disposable resource has already been set, future attempts to set the underlying disposable resource will throw an exception. 13 | */ 14 | public final class SingleAssignmentDisposable : DisposeBase, Cancelable { 15 | 16 | fileprivate enum DisposeState: UInt32 { 17 | case disposed = 1 18 | case disposableSet = 2 19 | } 20 | 21 | // Jeej, swift API consistency rules 22 | fileprivate enum DisposeStateInt32: Int32 { 23 | case disposed = 1 24 | case disposableSet = 2 25 | } 26 | 27 | // state 28 | private var _state: AtomicInt = 0 29 | private var _disposable = nil as Disposable? 30 | 31 | /// - returns: A value that indicates whether the object is disposed. 32 | public var isDisposed: Bool { 33 | return AtomicFlagSet(DisposeState.disposed.rawValue, &_state) 34 | } 35 | 36 | /// Initializes a new instance of the `SingleAssignmentDisposable`. 37 | public override init() { 38 | super.init() 39 | } 40 | 41 | /// Gets or sets the underlying disposable. After disposal, the result of getting this property is undefined. 42 | /// 43 | /// **Throws exception if the `SingleAssignmentDisposable` has already been assigned to.** 44 | public func setDisposable(_ disposable: Disposable) { 45 | _disposable = disposable 46 | 47 | let previousState = AtomicOr(DisposeState.disposableSet.rawValue, &_state) 48 | 49 | if (previousState & DisposeStateInt32.disposableSet.rawValue) != 0 { 50 | rxFatalError("oldState.disposable != nil") 51 | } 52 | 53 | if (previousState & DisposeStateInt32.disposed.rawValue) != 0 { 54 | disposable.dispose() 55 | _disposable = nil 56 | } 57 | } 58 | 59 | /// Disposes the underlying disposable. 60 | public func dispose() { 61 | let previousState = AtomicOr(DisposeState.disposed.rawValue, &_state) 62 | 63 | if (previousState & DisposeStateInt32.disposed.rawValue) != 0 { 64 | return 65 | } 66 | 67 | if (previousState & DisposeStateInt32.disposableSet.rawValue) != 0 { 68 | guard let disposable = _disposable else { 69 | rxFatalError("Disposable not set") 70 | } 71 | disposable.dispose() 72 | _disposable = nil 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubscriptionDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | struct SubscriptionDisposable : Disposable { 10 | private let _key: T.DisposeKey 11 | private weak var _owner: T? 12 | 13 | init(owner: T, key: T.DisposeKey) { 14 | _owner = owner 15 | _key = key 16 | } 17 | 18 | func dispose() { 19 | _owner?.synchronizedUnsubscribe(_key) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Errors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Errors.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | let RxErrorDomain = "RxErrorDomain" 10 | let RxCompositeFailures = "RxCompositeFailures" 11 | 12 | /// Generic Rx error codes. 13 | public enum RxError 14 | : Swift.Error 15 | , CustomDebugStringConvertible { 16 | /// Unknown error occurred. 17 | case unknown 18 | /// Performing an action on disposed object. 19 | case disposed(object: AnyObject) 20 | /// Aritmetic overflow error. 21 | case overflow 22 | /// Argument out of range error. 23 | case argumentOutOfRange 24 | /// Sequence doesn't contain any elements. 25 | case noElements 26 | /// Sequence contains more than one element. 27 | case moreThanOneElement 28 | /// Timeout error. 29 | case timeout 30 | } 31 | 32 | extension RxError { 33 | /// A textual representation of `self`, suitable for debugging. 34 | public var debugDescription: String { 35 | switch self { 36 | case .unknown: 37 | return "Unknown error occurred." 38 | case .disposed(let object): 39 | return "Object `\(object)` was already disposed." 40 | case .overflow: 41 | return "Arithmetic overflow occurred." 42 | case .argumentOutOfRange: 43 | return "Argument out of range." 44 | case .noElements: 45 | return "Sequence doesn't contain any elements." 46 | case .moreThanOneElement: 47 | return "Sequence contains more than one element." 48 | case .timeout: 49 | return "Sequence timeout." 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Event.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Event.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents a sequence event. 10 | /// 11 | /// Sequence grammar: 12 | /// **next\* (error | completed)** 13 | public enum Event { 14 | /// Next element is produced. 15 | case next(Element) 16 | 17 | /// Sequence terminated with an error. 18 | case error(Swift.Error) 19 | 20 | /// Sequence completed successfully. 21 | case completed 22 | } 23 | 24 | extension Event : CustomDebugStringConvertible { 25 | /// - returns: Description of event. 26 | public var debugDescription: String { 27 | switch self { 28 | case .next(let value): 29 | return "next(\(value))" 30 | case .error(let error): 31 | return "error(\(error))" 32 | case .completed: 33 | return "completed" 34 | } 35 | } 36 | } 37 | 38 | extension Event { 39 | /// Is `completed` or `error` event. 40 | public var isStopEvent: Bool { 41 | switch self { 42 | case .next: return false 43 | case .error, .completed: return true 44 | } 45 | } 46 | 47 | /// If `next` event, returns element value. 48 | public var element: Element? { 49 | if case .next(let value) = self { 50 | return value 51 | } 52 | return nil 53 | } 54 | 55 | /// If `error` event, returns error. 56 | public var error: Swift.Error? { 57 | if case .error(let error) = self { 58 | return error 59 | } 60 | return nil 61 | } 62 | 63 | /// If `completed` event, returns true. 64 | public var isCompleted: Bool { 65 | if case .completed = self { 66 | return true 67 | } 68 | return false 69 | } 70 | } 71 | 72 | extension Event { 73 | /// Maps sequence elements using transform. If error happens during the transform .error 74 | /// will be returned as value 75 | public func map(_ transform: (Element) throws -> Result) -> Event { 76 | do { 77 | switch self { 78 | case let .next(element): 79 | return .next(try transform(element)) 80 | case let .error(error): 81 | return .error(error) 82 | case .completed: 83 | return .completed 84 | } 85 | } 86 | catch let e { 87 | return .error(e) 88 | } 89 | } 90 | } 91 | 92 | /// A type that can be converted to `Event`. 93 | public protocol EventConvertible { 94 | /// Type of element in event 95 | associatedtype ElementType 96 | 97 | /// Event representation of this instance 98 | var event: Event { get } 99 | } 100 | 101 | extension Event : EventConvertible { 102 | /// Event representation of this instance 103 | public var event: Event { 104 | return self 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Extensions/Bag+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Bag+Rx.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/19/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | 10 | // MARK: forEach 11 | 12 | @inline(__always) 13 | func dispatch(_ bag: Bag<(Event) -> ()>, _ event: Event) { 14 | if bag._onlyFastPath { 15 | bag._value0?(event) 16 | return 17 | } 18 | 19 | let value0 = bag._value0 20 | let dictionary = bag._dictionary 21 | 22 | if let value0 = value0 { 23 | value0(event) 24 | } 25 | 26 | let pairs = bag._pairs 27 | for i in 0 ..< pairs.count { 28 | pairs[i].value(event) 29 | } 30 | 31 | if let dictionary = dictionary { 32 | for element in dictionary.values { 33 | element(event) 34 | } 35 | } 36 | } 37 | 38 | /// Dispatches `dispose` to all disposables contained inside bag. 39 | func disposeAll(in bag: Bag) { 40 | if bag._onlyFastPath { 41 | bag._value0?.dispose() 42 | return 43 | } 44 | 45 | let value0 = bag._value0 46 | let dictionary = bag._dictionary 47 | 48 | if let value0 = value0 { 49 | value0.dispose() 50 | } 51 | 52 | let pairs = bag._pairs 53 | for i in 0 ..< pairs.count { 54 | pairs[i].value.dispose() 55 | } 56 | 57 | if let dictionary = dictionary { 58 | for element in dictionary.values { 59 | element.dispose() 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String+Rx.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 12/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension String { 10 | /// This is needed because on Linux Swift doesn't have `rangeOfString(..., options: .BackwardsSearch)` 11 | func lastIndexOf(_ character: Character) -> Index? { 12 | var index = endIndex 13 | while index > startIndex { 14 | index = self.index(before: index) 15 | if self[index] == character { 16 | return index 17 | } 18 | } 19 | 20 | return nil 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/GroupedObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GroupedObservable.swift 3 | // RxSwift 4 | // 5 | // Created by Tomi Koskinen on 01/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents an observable sequence of elements that have a common key. 10 | public struct GroupedObservable : ObservableType { 11 | public typealias E = Element 12 | 13 | /// Gets the common key. 14 | public let key: Key 15 | 16 | private let source: Observable 17 | 18 | /// Initializes grouped observable sequence with key and source observable sequence. 19 | /// 20 | /// - parameter key: Grouped observable sequence key 21 | /// - parameter source: Observable sequence that represents sequence of elements for the key 22 | /// - returns: Grouped observable sequence of elements for the specific key 23 | public init(key: Key, source: Observable) { 24 | self.key = key 25 | self.source = source 26 | } 27 | 28 | /// Subscribes `observer` to receive events for this sequence. 29 | public func subscribe(_ observer: O) -> Disposable where O.E == E { 30 | return self.source.subscribe(observer) 31 | } 32 | 33 | /// Converts `self` to `Observable` sequence. 34 | public func asObservable() -> Observable { 35 | return source 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImmediateSchedulerType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/31/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents an object that immediately schedules units of work. 10 | public protocol ImmediateSchedulerType { 11 | /** 12 | Schedules an action to be executed immediately. 13 | 14 | - parameter state: State passed to the action to be executed. 15 | - parameter action: Action to be executed. 16 | - returns: The disposable object used to cancel the scheduled action (best effort). 17 | */ 18 | func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable 19 | } 20 | 21 | extension ImmediateSchedulerType { 22 | /** 23 | Schedules an action to be executed recursively. 24 | 25 | - parameter state: State passed to the action to be executed. 26 | - parameter action: Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. 27 | - returns: The disposable object used to cancel the scheduled action (best effort). 28 | */ 29 | public func scheduleRecursive(_ state: State, action: @escaping (_ state: State, _ recurse: (State) -> ()) -> ()) -> Disposable { 30 | let recursiveScheduler = RecursiveImmediateScheduler(action: action, scheduler: self) 31 | 32 | recursiveScheduler.schedule(state) 33 | 34 | return Disposables.create(with: recursiveScheduler.dispose) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// A type-erased `ObservableType`. 10 | /// 11 | /// It represents a push style sequence. 12 | public class Observable : ObservableType { 13 | /// Type of elements in sequence. 14 | public typealias E = Element 15 | 16 | init() { 17 | #if TRACE_RESOURCES 18 | let _ = Resources.incrementTotal() 19 | #endif 20 | } 21 | 22 | public func subscribe(_ observer: O) -> Disposable where O.E == E { 23 | rxAbstractMethod() 24 | } 25 | 26 | public func asObservable() -> Observable { 27 | return self 28 | } 29 | 30 | deinit { 31 | #if TRACE_RESOURCES 32 | let _ = Resources.decrementTotal() 33 | #endif 34 | } 35 | 36 | // this is kind of ugly I know :( 37 | // Swift compiler reports "Not supported yet" when trying to override protocol extensions, so ¯\_(ツ)_/¯ 38 | 39 | /// Optimizations for map operator 40 | internal func composeMap(_ transform: @escaping (Element) throws -> R) -> Observable { 41 | return _map(source: self, transform: transform) 42 | } 43 | } 44 | 45 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableConvertibleType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/17/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Type that can be converted to observable sequence (`Observable`). 10 | public protocol ObservableConvertibleType { 11 | /// Type of elements in sequence. 12 | associatedtype E 13 | 14 | /// Converts `self` to `Observable` sequence. 15 | /// 16 | /// - returns: Observable sequence that represents `self`. 17 | func asObservable() -> Observable 18 | } 19 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ObservableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents a push style sequence. 10 | public protocol ObservableType : ObservableConvertibleType { 11 | /** 12 | Subscribes `observer` to receive events for this sequence. 13 | 14 | ### Grammar 15 | 16 | **Next\* (Error | Completed)?** 17 | 18 | * sequences can produce zero or more elements so zero or more `Next` events can be sent to `observer` 19 | * once an `Error` or `Completed` event is sent, the sequence terminates and can't produce any other elements 20 | 21 | It is possible that events are sent from different threads, but no two events can be sent concurrently to 22 | `observer`. 23 | 24 | ### Resource Management 25 | 26 | When sequence sends `Complete` or `Error` event all internal resources that compute sequence elements 27 | will be freed. 28 | 29 | To cancel production of sequence elements and free resources immediately, call `dispose` on returned 30 | subscription. 31 | 32 | - returns: Subscription for `observer` that can be used to cancel production of sequence elements and free resources. 33 | */ 34 | func subscribe(_ observer: O) -> Disposable where O.E == E 35 | } 36 | 37 | extension ObservableType { 38 | 39 | /// Default implementation of converting `ObservableType` to `Observable`. 40 | public func asObservable() -> Observable { 41 | // temporary workaround 42 | //return Observable.create(subscribe: self.subscribe) 43 | return Observable.create { o in 44 | return self.subscribe(o) 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/AddRef.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddRef.swift 3 | // RxSwift 4 | // 5 | // Created by Junior B. on 30/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | final class AddRefSink : Sink, ObserverType { 10 | typealias Element = O.E 11 | 12 | override init(observer: O, cancel: Cancelable) { 13 | super.init(observer: observer, cancel: cancel) 14 | } 15 | 16 | func on(_ event: Event) { 17 | switch event { 18 | case .next(_): 19 | forwardOn(event) 20 | case .completed, .error(_): 21 | forwardOn(event) 22 | dispose() 23 | } 24 | } 25 | } 26 | 27 | final class AddRef : Producer { 28 | typealias EventHandler = (Event) throws -> Void 29 | 30 | private let _source: Observable 31 | private let _refCount: RefCountDisposable 32 | 33 | init(source: Observable, refCount: RefCountDisposable) { 34 | _source = source 35 | _refCount = refCount 36 | } 37 | 38 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 39 | let releaseDisposable = _refCount.retain() 40 | let sink = AddRefSink(observer: observer, cancel: cancel) 41 | let subscription = Disposables.create(releaseDisposable, _source.subscribe(sink)) 42 | 43 | return (sink: sink, subscription: subscription) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/AsMaybe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AsMaybe.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/12/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | fileprivate final class AsMaybeSink : Sink, ObserverType { 10 | typealias ElementType = O.E 11 | typealias E = ElementType 12 | 13 | private var _element: Event? = nil 14 | 15 | func on(_ event: Event) { 16 | switch event { 17 | case .next: 18 | if _element != nil { 19 | forwardOn(.error(RxError.moreThanOneElement)) 20 | dispose() 21 | } 22 | 23 | _element = event 24 | case .error: 25 | forwardOn(event) 26 | dispose() 27 | case .completed: 28 | if let element = _element { 29 | forwardOn(element) 30 | } 31 | forwardOn(.completed) 32 | dispose() 33 | } 34 | } 35 | } 36 | 37 | final class AsMaybe: Producer { 38 | fileprivate let _source: Observable 39 | 40 | init(source: Observable) { 41 | _source = source 42 | } 43 | 44 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 45 | let sink = AsMaybeSink(observer: observer, cancel: cancel) 46 | let subscription = _source.subscribe(sink) 47 | return (sink: sink, subscription: subscription) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/AsSingle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AsSingle.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/12/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | fileprivate final class AsSingleSink : Sink, ObserverType { 10 | typealias ElementType = O.E 11 | typealias E = ElementType 12 | 13 | private var _element: Event? = nil 14 | 15 | func on(_ event: Event) { 16 | switch event { 17 | case .next: 18 | if _element != nil { 19 | forwardOn(.error(RxError.moreThanOneElement)) 20 | dispose() 21 | } 22 | 23 | _element = event 24 | case .error: 25 | forwardOn(event) 26 | dispose() 27 | case .completed: 28 | if let element = _element { 29 | forwardOn(element) 30 | forwardOn(.completed) 31 | } 32 | else { 33 | forwardOn(.error(RxError.noElements)) 34 | } 35 | dispose() 36 | } 37 | } 38 | } 39 | 40 | final class AsSingle: Producer { 41 | fileprivate let _source: Observable 42 | 43 | init(source: Observable) { 44 | _source = source 45 | } 46 | 47 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 48 | let sink = AsSingleSink(observer: observer, cancel: cancel) 49 | let subscription = _source.subscribe(sink) 50 | return (sink: sink, subscription: subscription) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Create.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Create.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | // MARK: create 11 | 12 | /** 13 | Creates an observable sequence from a specified subscribe method implementation. 14 | 15 | - seealso: [create operator on reactivex.io](http://reactivex.io/documentation/operators/create.html) 16 | 17 | - parameter subscribe: Implementation of the resulting observable sequence's `subscribe` method. 18 | - returns: The observable sequence with the specified implementation for the `subscribe` method. 19 | */ 20 | public static func create(_ subscribe: @escaping (AnyObserver) -> Disposable) -> Observable { 21 | return AnonymousObservable(subscribe) 22 | } 23 | } 24 | 25 | final fileprivate class AnonymousObservableSink : Sink, ObserverType { 26 | typealias E = O.E 27 | typealias Parent = AnonymousObservable 28 | 29 | // state 30 | private var _isStopped: AtomicInt = 0 31 | 32 | #if DEBUG 33 | fileprivate let _synchronizationTracker = SynchronizationTracker() 34 | #endif 35 | 36 | override init(observer: O, cancel: Cancelable) { 37 | super.init(observer: observer, cancel: cancel) 38 | } 39 | 40 | func on(_ event: Event) { 41 | #if DEBUG 42 | _synchronizationTracker.register(synchronizationErrorMessage: .default) 43 | defer { _synchronizationTracker.unregister() } 44 | #endif 45 | switch event { 46 | case .next: 47 | if _isStopped == 1 { 48 | return 49 | } 50 | forwardOn(event) 51 | case .error, .completed: 52 | if AtomicCompareAndSwap(0, 1, &_isStopped) { 53 | forwardOn(event) 54 | dispose() 55 | } 56 | } 57 | } 58 | 59 | func run(_ parent: Parent) -> Disposable { 60 | return parent._subscribeHandler(AnyObserver(self)) 61 | } 62 | } 63 | 64 | final fileprivate class AnonymousObservable : Producer { 65 | typealias SubscribeHandler = (AnyObserver) -> Disposable 66 | 67 | let _subscribeHandler: SubscribeHandler 68 | 69 | init(_ subscribeHandler: @escaping SubscribeHandler) { 70 | _subscribeHandler = subscribeHandler 71 | } 72 | 73 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 74 | let sink = AnonymousObservableSink(observer: observer, cancel: cancel) 75 | let subscription = sink.run(self) 76 | return (sink: sink, subscription: subscription) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/DefaultIfEmpty.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultIfEmpty.swift 3 | // RxSwift 4 | // 5 | // Created by sergdort on 23/12/2016. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Emits elements from the source observable sequence, or a default element if the source observable sequence is empty. 13 | 14 | - seealso: [DefaultIfEmpty operator on reactivex.io](http://reactivex.io/documentation/operators/defaultifempty.html) 15 | 16 | - parameter default: Default element to be sent if the source does not emit any elements 17 | - returns: An observable sequence which emits default element end completes in case the original sequence is empty 18 | */ 19 | public func ifEmpty(default: E) -> Observable { 20 | return DefaultIfEmpty(source: self.asObservable(), default: `default`) 21 | } 22 | } 23 | 24 | final fileprivate class DefaultIfEmptySink: Sink, ObserverType { 25 | typealias E = O.E 26 | private let _default: E 27 | private var _isEmpty = true 28 | 29 | init(default: E, observer: O, cancel: Cancelable) { 30 | _default = `default` 31 | super.init(observer: observer, cancel: cancel) 32 | } 33 | 34 | func on(_ event: Event) { 35 | switch event { 36 | case .next(_): 37 | _isEmpty = false 38 | forwardOn(event) 39 | case .error(_): 40 | forwardOn(event) 41 | dispose() 42 | case .completed: 43 | if _isEmpty { 44 | forwardOn(.next(_default)) 45 | } 46 | forwardOn(.completed) 47 | dispose() 48 | } 49 | } 50 | } 51 | 52 | final fileprivate class DefaultIfEmpty: Producer { 53 | private let _source: Observable 54 | private let _default: SourceType 55 | 56 | init(source: Observable, `default`: SourceType) { 57 | _source = source 58 | _default = `default` 59 | } 60 | 61 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == SourceType { 62 | let sink = DefaultIfEmptySink(default: _default, observer: observer, cancel: cancel) 63 | let subscription = _source.subscribe(sink) 64 | return (sink: sink, subscription: subscription) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Deferred.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Deferred.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. 12 | 13 | - seealso: [defer operator on reactivex.io](http://reactivex.io/documentation/operators/defer.html) 14 | 15 | - parameter observableFactory: Observable factory function to invoke for each observer that subscribes to the resulting sequence. 16 | - returns: An observable sequence whose observers trigger an invocation of the given observable factory function. 17 | */ 18 | public static func deferred(_ observableFactory: @escaping () throws -> Observable) 19 | -> Observable { 20 | return Deferred(observableFactory: observableFactory) 21 | } 22 | } 23 | 24 | final fileprivate class DeferredSink : Sink, ObserverType where S.E == O.E { 25 | typealias E = O.E 26 | 27 | private let _observableFactory: () throws -> S 28 | 29 | init(observableFactory: @escaping () throws -> S, observer: O, cancel: Cancelable) { 30 | _observableFactory = observableFactory 31 | super.init(observer: observer, cancel: cancel) 32 | } 33 | 34 | func run() -> Disposable { 35 | do { 36 | let result = try _observableFactory() 37 | return result.subscribe(self) 38 | } 39 | catch let e { 40 | forwardOn(.error(e)) 41 | dispose() 42 | return Disposables.create() 43 | } 44 | } 45 | 46 | func on(_ event: Event) { 47 | forwardOn(event) 48 | 49 | switch event { 50 | case .next: 51 | break 52 | case .error: 53 | dispose() 54 | case .completed: 55 | dispose() 56 | } 57 | } 58 | } 59 | 60 | final fileprivate class Deferred : Producer { 61 | typealias Factory = () throws -> S 62 | 63 | private let _observableFactory : Factory 64 | 65 | init(observableFactory: @escaping Factory) { 66 | _observableFactory = observableFactory 67 | } 68 | 69 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { 70 | let sink = DeferredSink(observableFactory: _observableFactory, observer: observer, cancel: cancel) 71 | let subscription = sink.run() 72 | return (sink: sink, subscription: subscription) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/DelaySubscription.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DelaySubscription.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers. 13 | 14 | - seealso: [delay operator on reactivex.io](http://reactivex.io/documentation/operators/delay.html) 15 | 16 | - parameter dueTime: Relative time shift of the subscription. 17 | - parameter scheduler: Scheduler to run the subscription delay timer on. 18 | - returns: Time-shifted sequence. 19 | */ 20 | public func delaySubscription(_ dueTime: RxTimeInterval, scheduler: SchedulerType) 21 | -> Observable { 22 | return DelaySubscription(source: self.asObservable(), dueTime: dueTime, scheduler: scheduler) 23 | } 24 | } 25 | 26 | final fileprivate class DelaySubscriptionSink 27 | : Sink, ObserverType { 28 | typealias E = O.E 29 | typealias Parent = DelaySubscription 30 | 31 | private let _parent: Parent 32 | 33 | init(parent: Parent, observer: O, cancel: Cancelable) { 34 | _parent = parent 35 | super.init(observer: observer, cancel: cancel) 36 | } 37 | 38 | func on(_ event: Event) { 39 | forwardOn(event) 40 | if event.isStopEvent { 41 | dispose() 42 | } 43 | } 44 | 45 | } 46 | 47 | final fileprivate class DelaySubscription: Producer { 48 | private let _source: Observable 49 | private let _dueTime: RxTimeInterval 50 | private let _scheduler: SchedulerType 51 | 52 | init(source: Observable, dueTime: RxTimeInterval, scheduler: SchedulerType) { 53 | _source = source 54 | _dueTime = dueTime 55 | _scheduler = scheduler 56 | } 57 | 58 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 59 | let sink = DelaySubscriptionSink(parent: self, observer: observer, cancel: cancel) 60 | let subscription = _scheduler.scheduleRelative((), dueTime: _dueTime) { _ in 61 | return self._source.subscribe(sink) 62 | } 63 | 64 | return (sink: sink, subscription: subscription) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Dematerialize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Dematerialize.swift 3 | // RxSwift 4 | // 5 | // Created by Jamie Pinkham on 3/13/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType where E: EventConvertible { 10 | /** 11 | Convert any previously materialized Observable into it's original form. 12 | - seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html) 13 | - returns: The dematerialized observable sequence. 14 | */ 15 | public func dematerialize() -> Observable { 16 | return Dematerialize(source: self.asObservable()) 17 | } 18 | 19 | } 20 | 21 | fileprivate final class DematerializeSink: Sink, ObserverType where O.E == Element.ElementType { 22 | fileprivate func on(_ event: Event) { 23 | switch event { 24 | case .next(let element): 25 | forwardOn(element.event) 26 | if element.event.isStopEvent { 27 | dispose() 28 | } 29 | case .completed: 30 | forwardOn(.completed) 31 | dispose() 32 | case .error(let error): 33 | forwardOn(.error(error)) 34 | dispose() 35 | } 36 | } 37 | } 38 | 39 | final fileprivate class Dematerialize: Producer { 40 | private let _source: Observable 41 | 42 | init(source: Observable) { 43 | _source = source 44 | } 45 | 46 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element.ElementType { 47 | let sink = DematerializeSink(observer: observer, cancel: cancel) 48 | let subscription = _source.subscribe(sink) 49 | return (sink: sink, subscription: subscription) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/ElementAt.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ElementAt.swift 3 | // RxSwift 4 | // 5 | // Created by Junior B. on 21/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Returns a sequence emitting only element _n_ emitted by an Observable 13 | 14 | - seealso: [elementAt operator on reactivex.io](http://reactivex.io/documentation/operators/elementat.html) 15 | 16 | - parameter index: The index of the required element (starting from 0). 17 | - returns: An observable sequence that emits the desired element as its own sole emission. 18 | */ 19 | public func elementAt(_ index: Int) 20 | -> Observable { 21 | return ElementAt(source: asObservable(), index: index, throwOnEmpty: true) 22 | } 23 | } 24 | 25 | final fileprivate class ElementAtSink : Sink, ObserverType { 26 | typealias SourceType = O.E 27 | typealias Parent = ElementAt 28 | 29 | let _parent: Parent 30 | var _i: Int 31 | 32 | init(parent: Parent, observer: O, cancel: Cancelable) { 33 | _parent = parent 34 | _i = parent._index 35 | 36 | super.init(observer: observer, cancel: cancel) 37 | } 38 | 39 | func on(_ event: Event) { 40 | switch event { 41 | case .next(_): 42 | 43 | if (_i == 0) { 44 | forwardOn(event) 45 | forwardOn(.completed) 46 | self.dispose() 47 | } 48 | 49 | do { 50 | let _ = try decrementChecked(&_i) 51 | } catch(let e) { 52 | forwardOn(.error(e)) 53 | dispose() 54 | return 55 | } 56 | 57 | case .error(let e): 58 | forwardOn(.error(e)) 59 | self.dispose() 60 | case .completed: 61 | if (_parent._throwOnEmpty) { 62 | forwardOn(.error(RxError.argumentOutOfRange)) 63 | } else { 64 | forwardOn(.completed) 65 | } 66 | 67 | self.dispose() 68 | } 69 | } 70 | } 71 | 72 | final fileprivate class ElementAt : Producer { 73 | 74 | let _source: Observable 75 | let _throwOnEmpty: Bool 76 | let _index: Int 77 | 78 | init(source: Observable, index: Int, throwOnEmpty: Bool) { 79 | if index < 0 { 80 | rxFatalError("index can't be negative") 81 | } 82 | 83 | self._source = source 84 | self._index = index 85 | self._throwOnEmpty = throwOnEmpty 86 | } 87 | 88 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == SourceType { 89 | let sink = ElementAtSink(parent: self, observer: observer, cancel: cancel) 90 | let subscription = _source.subscribe(sink) 91 | return (sink: sink, subscription: subscription) 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Empty.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Empty.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Returns an empty observable sequence, using the specified scheduler to send out the single `Completed` message. 12 | 13 | - seealso: [empty operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) 14 | 15 | - returns: An observable sequence with no elements. 16 | */ 17 | public static func empty() -> Observable { 18 | return EmptyProducer() 19 | } 20 | } 21 | 22 | final fileprivate class EmptyProducer : Producer { 23 | override func subscribe(_ observer: O) -> Disposable where O.E == Element { 24 | observer.on(.completed) 25 | return Disposables.create() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Enumerated.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Enumerated.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/6/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Enumerates the elements of an observable sequence. 13 | 14 | - seealso: [map operator on reactivex.io](http://reactivex.io/documentation/operators/map.html) 15 | 16 | - returns: An observable sequence that contains tuples of source sequence elements and their indexes. 17 | */ 18 | public func enumerated() 19 | -> Observable<(index: Int, element: E)> { 20 | return Enumerated(source: self.asObservable()) 21 | } 22 | } 23 | 24 | final fileprivate class EnumeratedSink: Sink, ObserverType where O.E == (index: Int, element: Element) { 25 | typealias E = Element 26 | var index = 0 27 | 28 | func on(_ event: Event) { 29 | switch event { 30 | case .next(let value): 31 | do { 32 | let nextIndex = try incrementChecked(&index) 33 | let next = (index: nextIndex, element: value) 34 | forwardOn(.next(next)) 35 | } 36 | catch let e { 37 | forwardOn(.error(e)) 38 | dispose() 39 | } 40 | case .completed: 41 | forwardOn(.completed) 42 | dispose() 43 | case .error(let error): 44 | forwardOn(.error(error)) 45 | dispose() 46 | } 47 | } 48 | } 49 | 50 | final fileprivate class Enumerated : Producer<(index: Int, element: Element)> { 51 | private let _source: Observable 52 | 53 | init(source: Observable) { 54 | _source = source 55 | } 56 | 57 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == (index: Int, element: Element) { 58 | let sink = EnumeratedSink(observer: observer, cancel: cancel) 59 | let subscription = _source.subscribe(sink) 60 | return (sink: sink, subscription: subscription) 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Error.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Error.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Returns an observable sequence that terminates with an `error`. 12 | 13 | - seealso: [throw operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) 14 | 15 | - returns: The observable sequence that terminates with specified error. 16 | */ 17 | public static func error(_ error: Swift.Error) -> Observable { 18 | return ErrorProducer(error: error) 19 | } 20 | } 21 | 22 | final fileprivate class ErrorProducer : Producer { 23 | private let _error: Swift.Error 24 | 25 | init(error: Swift.Error) { 26 | _error = error 27 | } 28 | 29 | override func subscribe(_ observer: O) -> Disposable where O.E == Element { 30 | observer.on(.error(_error)) 31 | return Disposables.create() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Filter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Filter.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/17/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Filters the elements of an observable sequence based on a predicate. 13 | 14 | - seealso: [filter operator on reactivex.io](http://reactivex.io/documentation/operators/filter.html) 15 | 16 | - parameter predicate: A function to test each source element for a condition. 17 | - returns: An observable sequence that contains elements from the input sequence that satisfy the condition. 18 | */ 19 | public func filter(_ predicate: @escaping (E) throws -> Bool) 20 | -> Observable { 21 | return Filter(source: asObservable(), predicate: predicate) 22 | } 23 | } 24 | 25 | extension ObservableType { 26 | 27 | /** 28 | Skips elements and completes (or errors) when the receiver completes (or errors). Equivalent to filter that always returns false. 29 | 30 | - seealso: [ignoreElements operator on reactivex.io](http://reactivex.io/documentation/operators/ignoreelements.html) 31 | 32 | - returns: An observable sequence that skips all elements of the source sequence. 33 | */ 34 | public func ignoreElements() 35 | -> Completable { 36 | return flatMap { _ in 37 | return Observable.empty() 38 | } 39 | .asCompletable() 40 | } 41 | } 42 | 43 | final fileprivate class FilterSink: Sink, ObserverType { 44 | typealias Predicate = (Element) throws -> Bool 45 | typealias Element = O.E 46 | 47 | private let _predicate: Predicate 48 | 49 | init(predicate: @escaping Predicate, observer: O, cancel: Cancelable) { 50 | _predicate = predicate 51 | super.init(observer: observer, cancel: cancel) 52 | } 53 | 54 | func on(_ event: Event) { 55 | switch event { 56 | case .next(let value): 57 | do { 58 | let satisfies = try _predicate(value) 59 | if satisfies { 60 | forwardOn(.next(value)) 61 | } 62 | } 63 | catch let e { 64 | forwardOn(.error(e)) 65 | dispose() 66 | } 67 | case .completed, .error: 68 | forwardOn(event) 69 | dispose() 70 | } 71 | } 72 | } 73 | 74 | final fileprivate class Filter : Producer { 75 | typealias Predicate = (Element) throws -> Bool 76 | 77 | private let _source: Observable 78 | private let _predicate: Predicate 79 | 80 | init(source: Observable, predicate: @escaping Predicate) { 81 | _source = source 82 | _predicate = predicate 83 | } 84 | 85 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 86 | let sink = FilterSink(predicate: _predicate, observer: observer, cancel: cancel) 87 | let subscription = _source.subscribe(sink) 88 | return (sink: sink, subscription: subscription) 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/First.swift: -------------------------------------------------------------------------------- 1 | // 2 | // First.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 7/31/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | fileprivate final class FirstSink : Sink, ObserverType where O.E == Element? { 10 | typealias E = Element 11 | typealias Parent = First 12 | 13 | func on(_ event: Event) { 14 | switch event { 15 | case .next(let value): 16 | forwardOn(.next(value)) 17 | forwardOn(.completed) 18 | dispose() 19 | case .error(let error): 20 | forwardOn(.error(error)) 21 | dispose() 22 | case .completed: 23 | forwardOn(.next(nil)) 24 | forwardOn(.completed) 25 | dispose() 26 | } 27 | } 28 | } 29 | 30 | final class First: Producer { 31 | fileprivate let _source: Observable 32 | 33 | init(source: Observable) { 34 | _source = source 35 | } 36 | 37 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element? { 38 | let sink = FirstSink(observer: observer, cancel: cancel) 39 | let subscription = _source.subscribe(sink) 40 | return (sink: sink, subscription: subscription) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Generate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generate.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler 12 | to run the loop send out observer messages. 13 | 14 | - seealso: [create operator on reactivex.io](http://reactivex.io/documentation/operators/create.html) 15 | 16 | - parameter initialState: Initial state. 17 | - parameter condition: Condition to terminate generation (upon returning `false`). 18 | - parameter iterate: Iteration step function. 19 | - parameter scheduler: Scheduler on which to run the generator loop. 20 | - returns: The generated sequence. 21 | */ 22 | public static func generate(initialState: E, condition: @escaping (E) throws -> Bool, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance, iterate: @escaping (E) throws -> E) -> Observable { 23 | return Generate(initialState: initialState, condition: condition, iterate: iterate, resultSelector: { $0 }, scheduler: scheduler) 24 | } 25 | } 26 | 27 | final fileprivate class GenerateSink : Sink { 28 | typealias Parent = Generate 29 | 30 | private let _parent: Parent 31 | 32 | private var _state: S 33 | 34 | init(parent: Parent, observer: O, cancel: Cancelable) { 35 | _parent = parent 36 | _state = parent._initialState 37 | super.init(observer: observer, cancel: cancel) 38 | } 39 | 40 | func run() -> Disposable { 41 | return _parent._scheduler.scheduleRecursive(true) { (isFirst, recurse) -> Void in 42 | do { 43 | if !isFirst { 44 | self._state = try self._parent._iterate(self._state) 45 | } 46 | 47 | if try self._parent._condition(self._state) { 48 | let result = try self._parent._resultSelector(self._state) 49 | self.forwardOn(.next(result)) 50 | 51 | recurse(false) 52 | } 53 | else { 54 | self.forwardOn(.completed) 55 | self.dispose() 56 | } 57 | } 58 | catch let error { 59 | self.forwardOn(.error(error)) 60 | self.dispose() 61 | } 62 | } 63 | } 64 | } 65 | 66 | final fileprivate class Generate : Producer { 67 | fileprivate let _initialState: S 68 | fileprivate let _condition: (S) throws -> Bool 69 | fileprivate let _iterate: (S) throws -> S 70 | fileprivate let _resultSelector: (S) throws -> E 71 | fileprivate let _scheduler: ImmediateSchedulerType 72 | 73 | init(initialState: S, condition: @escaping (S) throws -> Bool, iterate: @escaping (S) throws -> S, resultSelector: @escaping (S) throws -> E, scheduler: ImmediateSchedulerType) { 74 | _initialState = initialState 75 | _condition = condition 76 | _iterate = iterate 77 | _resultSelector = resultSelector 78 | _scheduler = scheduler 79 | super.init() 80 | } 81 | 82 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { 83 | let sink = GenerateSink(parent: self, observer: observer, cancel: cancel) 84 | let subscription = sink.run() 85 | return (sink: sink, subscription: subscription) 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Just.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Just.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Returns an observable sequence that contains a single element. 12 | 13 | - seealso: [just operator on reactivex.io](http://reactivex.io/documentation/operators/just.html) 14 | 15 | - parameter element: Single element in the resulting observable sequence. 16 | - returns: An observable sequence containing the single specified element. 17 | */ 18 | public static func just(_ element: E) -> Observable { 19 | return Just(element: element) 20 | } 21 | 22 | /** 23 | Returns an observable sequence that contains a single element. 24 | 25 | - seealso: [just operator on reactivex.io](http://reactivex.io/documentation/operators/just.html) 26 | 27 | - parameter element: Single element in the resulting observable sequence. 28 | - parameter: Scheduler to send the single element on. 29 | - returns: An observable sequence containing the single specified element. 30 | */ 31 | public static func just(_ element: E, scheduler: ImmediateSchedulerType) -> Observable { 32 | return JustScheduled(element: element, scheduler: scheduler) 33 | } 34 | } 35 | 36 | final fileprivate class JustScheduledSink : Sink { 37 | typealias Parent = JustScheduled 38 | 39 | private let _parent: Parent 40 | 41 | init(parent: Parent, observer: O, cancel: Cancelable) { 42 | _parent = parent 43 | super.init(observer: observer, cancel: cancel) 44 | } 45 | 46 | func run() -> Disposable { 47 | let scheduler = _parent._scheduler 48 | return scheduler.schedule(_parent._element) { element in 49 | self.forwardOn(.next(element)) 50 | return scheduler.schedule(()) { _ in 51 | self.forwardOn(.completed) 52 | self.dispose() 53 | return Disposables.create() 54 | } 55 | } 56 | } 57 | } 58 | 59 | final fileprivate class JustScheduled : Producer { 60 | fileprivate let _scheduler: ImmediateSchedulerType 61 | fileprivate let _element: Element 62 | 63 | init(element: Element, scheduler: ImmediateSchedulerType) { 64 | _scheduler = scheduler 65 | _element = element 66 | } 67 | 68 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { 69 | let sink = JustScheduledSink(parent: self, observer: observer, cancel: cancel) 70 | let subscription = sink.run() 71 | return (sink: sink, subscription: subscription) 72 | } 73 | } 74 | 75 | final fileprivate class Just : Producer { 76 | private let _element: Element 77 | 78 | init(element: Element) { 79 | _element = element 80 | } 81 | 82 | override func subscribe(_ observer: O) -> Disposable where O.E == Element { 83 | observer.on(.next(_element)) 84 | observer.on(.completed) 85 | return Disposables.create() 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Materialize.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Materialize.swift 3 | // RxSwift 4 | // 5 | // Created by sergdort on 08/03/2017. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Convert any Observable into an Observable of its events. 12 | - seealso: [materialize operator on reactivex.io](http://reactivex.io/documentation/operators/materialize-dematerialize.html) 13 | - returns: An observable sequence that wraps events in an Event. The returned Observable never errors, but it does complete after observing all of the events of the underlying Observable. 14 | */ 15 | public func materialize() -> Observable> { 16 | return Materialize(source: self.asObservable()) 17 | } 18 | } 19 | 20 | fileprivate final class MaterializeSink: Sink, ObserverType where O.E == Event { 21 | 22 | func on(_ event: Event) { 23 | forwardOn(.next(event)) 24 | if event.isStopEvent { 25 | forwardOn(.completed) 26 | dispose() 27 | } 28 | } 29 | } 30 | 31 | final fileprivate class Materialize: Producer> { 32 | private let _source: Observable 33 | 34 | init(source: Observable) { 35 | _source = source 36 | } 37 | 38 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { 39 | let sink = MaterializeSink(observer: observer, cancel: cancel) 40 | let subscription = _source.subscribe(sink) 41 | 42 | return (sink: sink, subscription: subscription) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Never.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Never.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Returns a non-terminating observable sequence, which can be used to denote an infinite duration. 13 | 14 | - seealso: [never operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) 15 | 16 | - returns: An observable sequence whose observers will never get called. 17 | */ 18 | public static func never() -> Observable { 19 | return NeverProducer() 20 | } 21 | } 22 | 23 | final fileprivate class NeverProducer : Producer { 24 | override func subscribe(_ observer: O) -> Disposable where O.E == Element { 25 | return Disposables.create() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Optional.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Optional.swift 3 | // RxSwift 4 | // 5 | // Created by tarunon on 2016/12/13. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Converts a optional to an observable sequence. 12 | 13 | - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) 14 | 15 | - parameter optional: Optional element in the resulting observable sequence. 16 | - returns: An observable sequence containing the wrapped value or not from given optional. 17 | */ 18 | public static func from(optional: E?) -> Observable { 19 | return ObservableOptional(optional: optional) 20 | } 21 | 22 | /** 23 | Converts a optional to an observable sequence. 24 | 25 | - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) 26 | 27 | - parameter optional: Optional element in the resulting observable sequence. 28 | - parameter: Scheduler to send the optional element on. 29 | - returns: An observable sequence containing the wrapped value or not from given optional. 30 | */ 31 | public static func from(optional: E?, scheduler: ImmediateSchedulerType) -> Observable { 32 | return ObservableOptionalScheduled(optional: optional, scheduler: scheduler) 33 | } 34 | } 35 | 36 | final fileprivate class ObservableOptionalScheduledSink : Sink { 37 | typealias E = O.E 38 | typealias Parent = ObservableOptionalScheduled 39 | 40 | private let _parent: Parent 41 | 42 | init(parent: Parent, observer: O, cancel: Cancelable) { 43 | _parent = parent 44 | super.init(observer: observer, cancel: cancel) 45 | } 46 | 47 | func run() -> Disposable { 48 | return _parent._scheduler.schedule(_parent._optional) { (optional: E?) -> Disposable in 49 | if let next = optional { 50 | self.forwardOn(.next(next)) 51 | return self._parent._scheduler.schedule(()) { _ in 52 | self.forwardOn(.completed) 53 | self.dispose() 54 | return Disposables.create() 55 | } 56 | } else { 57 | self.forwardOn(.completed) 58 | self.dispose() 59 | return Disposables.create() 60 | } 61 | } 62 | } 63 | } 64 | 65 | final fileprivate class ObservableOptionalScheduled : Producer { 66 | fileprivate let _optional: E? 67 | fileprivate let _scheduler: ImmediateSchedulerType 68 | 69 | init(optional: E?, scheduler: ImmediateSchedulerType) { 70 | _optional = optional 71 | _scheduler = scheduler 72 | } 73 | 74 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { 75 | let sink = ObservableOptionalScheduledSink(parent: self, observer: observer, cancel: cancel) 76 | let subscription = sink.run() 77 | return (sink: sink, subscription: subscription) 78 | } 79 | } 80 | 81 | final fileprivate class ObservableOptional: Producer { 82 | private let _optional: E? 83 | 84 | init(optional: E?) { 85 | _optional = optional 86 | } 87 | 88 | override func subscribe(_ observer: O) -> Disposable where O.E == E { 89 | if let element = _optional { 90 | observer.on(.next(element)) 91 | } 92 | observer.on(.completed) 93 | return Disposables.create() 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Producer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Producer.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/20/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | class Producer : Observable { 10 | override init() { 11 | super.init() 12 | } 13 | 14 | override func subscribe(_ observer: O) -> Disposable where O.E == Element { 15 | if !CurrentThreadScheduler.isScheduleRequired { 16 | // The returned disposable needs to release all references once it was disposed. 17 | let disposer = SinkDisposer() 18 | let sinkAndSubscription = run(observer, cancel: disposer) 19 | disposer.setSinkAndSubscription(sink: sinkAndSubscription.sink, subscription: sinkAndSubscription.subscription) 20 | 21 | return disposer 22 | } 23 | else { 24 | return CurrentThreadScheduler.instance.schedule(()) { _ in 25 | let disposer = SinkDisposer() 26 | let sinkAndSubscription = self.run(observer, cancel: disposer) 27 | disposer.setSinkAndSubscription(sink: sinkAndSubscription.sink, subscription: sinkAndSubscription.subscription) 28 | 29 | return disposer 30 | } 31 | } 32 | } 33 | 34 | func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 35 | rxAbstractMethod() 36 | } 37 | } 38 | 39 | fileprivate final class SinkDisposer: Cancelable { 40 | fileprivate enum DisposeState: UInt32 { 41 | case disposed = 1 42 | case sinkAndSubscriptionSet = 2 43 | } 44 | 45 | // Jeej, swift API consistency rules 46 | fileprivate enum DisposeStateInt32: Int32 { 47 | case disposed = 1 48 | case sinkAndSubscriptionSet = 2 49 | } 50 | 51 | private var _state: AtomicInt = 0 52 | private var _sink: Disposable? = nil 53 | private var _subscription: Disposable? = nil 54 | 55 | var isDisposed: Bool { 56 | return AtomicFlagSet(DisposeState.disposed.rawValue, &_state) 57 | } 58 | 59 | func setSinkAndSubscription(sink: Disposable, subscription: Disposable) { 60 | _sink = sink 61 | _subscription = subscription 62 | 63 | let previousState = AtomicOr(DisposeState.sinkAndSubscriptionSet.rawValue, &_state) 64 | if (previousState & DisposeStateInt32.sinkAndSubscriptionSet.rawValue) != 0 { 65 | rxFatalError("Sink and subscription were already set") 66 | } 67 | 68 | if (previousState & DisposeStateInt32.disposed.rawValue) != 0 { 69 | sink.dispose() 70 | subscription.dispose() 71 | _sink = nil 72 | _subscription = nil 73 | } 74 | } 75 | 76 | func dispose() { 77 | let previousState = AtomicOr(DisposeState.disposed.rawValue, &_state) 78 | 79 | if (previousState & DisposeStateInt32.disposed.rawValue) != 0 { 80 | return 81 | } 82 | 83 | if (previousState & DisposeStateInt32.sinkAndSubscriptionSet.rawValue) != 0 { 84 | guard let sink = _sink else { 85 | rxFatalError("Sink not set") 86 | } 87 | guard let subscription = _subscription else { 88 | rxFatalError("Subscription not set") 89 | } 90 | 91 | sink.dispose() 92 | subscription.dispose() 93 | 94 | _sink = nil 95 | _subscription = nil 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Range.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Range.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType where E : RxAbstractInteger { 10 | /** 11 | Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to generate and send out observer messages. 12 | 13 | - seealso: [range operator on reactivex.io](http://reactivex.io/documentation/operators/range.html) 14 | 15 | - parameter start: The value of the first integer in the sequence. 16 | - parameter count: The number of sequential integers to generate. 17 | - parameter scheduler: Scheduler to run the generator loop on. 18 | - returns: An observable sequence that contains a range of sequential integral numbers. 19 | */ 20 | public static func range(start: E, count: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { 21 | return RangeProducer(start: start, count: count, scheduler: scheduler) 22 | } 23 | } 24 | 25 | final fileprivate class RangeProducer : Producer { 26 | fileprivate let _start: E 27 | fileprivate let _count: E 28 | fileprivate let _scheduler: ImmediateSchedulerType 29 | 30 | init(start: E, count: E, scheduler: ImmediateSchedulerType) { 31 | if count < 0 { 32 | rxFatalError("count can't be negative") 33 | } 34 | 35 | if start &+ (count - 1) < start { 36 | rxFatalError("overflow of count") 37 | } 38 | 39 | _start = start 40 | _count = count 41 | _scheduler = scheduler 42 | } 43 | 44 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { 45 | let sink = RangeSink(parent: self, observer: observer, cancel: cancel) 46 | let subscription = sink.run() 47 | return (sink: sink, subscription: subscription) 48 | } 49 | } 50 | 51 | final fileprivate class RangeSink : Sink where O.E: RxAbstractInteger { 52 | typealias Parent = RangeProducer 53 | 54 | private let _parent: Parent 55 | 56 | init(parent: Parent, observer: O, cancel: Cancelable) { 57 | _parent = parent 58 | super.init(observer: observer, cancel: cancel) 59 | } 60 | 61 | func run() -> Disposable { 62 | return _parent._scheduler.scheduleRecursive(0 as O.E) { i, recurse in 63 | if i < self._parent._count { 64 | self.forwardOn(.next(self._parent._start + i)) 65 | recurse(i + 1) 66 | } 67 | else { 68 | self.forwardOn(.completed) 69 | self.dispose() 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Repeat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Repeat.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages. 12 | 13 | - seealso: [repeat operator on reactivex.io](http://reactivex.io/documentation/operators/repeat.html) 14 | 15 | - parameter element: Element to repeat. 16 | - parameter scheduler: Scheduler to run the producer loop on. 17 | - returns: An observable sequence that repeats the given element infinitely. 18 | */ 19 | public static func repeatElement(_ element: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { 20 | return RepeatElement(element: element, scheduler: scheduler) 21 | } 22 | } 23 | 24 | final fileprivate class RepeatElement : Producer { 25 | fileprivate let _element: Element 26 | fileprivate let _scheduler: ImmediateSchedulerType 27 | 28 | init(element: Element, scheduler: ImmediateSchedulerType) { 29 | _element = element 30 | _scheduler = scheduler 31 | } 32 | 33 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 34 | let sink = RepeatElementSink(parent: self, observer: observer, cancel: cancel) 35 | let subscription = sink.run() 36 | 37 | return (sink: sink, subscription: subscription) 38 | } 39 | } 40 | 41 | final fileprivate class RepeatElementSink : Sink { 42 | typealias Parent = RepeatElement 43 | 44 | private let _parent: Parent 45 | 46 | init(parent: Parent, observer: O, cancel: Cancelable) { 47 | _parent = parent 48 | super.init(observer: observer, cancel: cancel) 49 | } 50 | 51 | func run() -> Disposable { 52 | return _parent._scheduler.scheduleRecursive(_parent._element) { e, recurse in 53 | self.forwardOn(.next(e)) 54 | recurse(e) 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Scan.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Scan.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value. 13 | 14 | For aggregation behavior with no intermediate results, see `reduce`. 15 | 16 | - seealso: [scan operator on reactivex.io](http://reactivex.io/documentation/operators/scan.html) 17 | 18 | - parameter seed: The initial accumulator value. 19 | - parameter accumulator: An accumulator function to be invoked on each element. 20 | - returns: An observable sequence containing the accumulated values. 21 | */ 22 | public func scan(_ seed: A, accumulator: @escaping (A, E) throws -> A) 23 | -> Observable { 24 | return Scan(source: self.asObservable(), seed: seed, accumulator: accumulator) 25 | } 26 | } 27 | 28 | final fileprivate class ScanSink : Sink, ObserverType { 29 | typealias Accumulate = O.E 30 | typealias Parent = Scan 31 | typealias E = ElementType 32 | 33 | fileprivate let _parent: Parent 34 | fileprivate var _accumulate: Accumulate 35 | 36 | init(parent: Parent, observer: O, cancel: Cancelable) { 37 | _parent = parent 38 | _accumulate = parent._seed 39 | super.init(observer: observer, cancel: cancel) 40 | } 41 | 42 | func on(_ event: Event) { 43 | switch event { 44 | case .next(let element): 45 | do { 46 | _accumulate = try _parent._accumulator(_accumulate, element) 47 | forwardOn(.next(_accumulate)) 48 | } 49 | catch let error { 50 | forwardOn(.error(error)) 51 | dispose() 52 | } 53 | case .error(let error): 54 | forwardOn(.error(error)) 55 | dispose() 56 | case .completed: 57 | forwardOn(.completed) 58 | dispose() 59 | } 60 | } 61 | 62 | } 63 | 64 | final fileprivate class Scan: Producer { 65 | typealias Accumulator = (Accumulate, Element) throws -> Accumulate 66 | 67 | fileprivate let _source: Observable 68 | fileprivate let _seed: Accumulate 69 | fileprivate let _accumulator: Accumulator 70 | 71 | init(source: Observable, seed: Accumulate, accumulator: @escaping Accumulator) { 72 | _source = source 73 | _seed = seed 74 | _accumulator = accumulator 75 | } 76 | 77 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Accumulate { 78 | let sink = ScanSink(parent: self, observer: observer, cancel: cancel) 79 | let subscription = _source.subscribe(sink) 80 | return (sink: sink, subscription: subscription) 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Sequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sequence.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 11/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | // MARK: of 11 | 12 | /** 13 | This method creates a new Observable instance with a variable number of elements. 14 | 15 | - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) 16 | 17 | - parameter elements: Elements to generate. 18 | - parameter scheduler: Scheduler to send elements on. If `nil`, elements are sent immediately on subscription. 19 | - returns: The observable sequence whose elements are pulled from the given arguments. 20 | */ 21 | public static func of(_ elements: E ..., scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { 22 | return ObservableSequence(elements: elements, scheduler: scheduler) 23 | } 24 | } 25 | 26 | extension ObservableType { 27 | /** 28 | Converts an array to an observable sequence. 29 | 30 | - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) 31 | 32 | - returns: The observable sequence whose elements are pulled from the given enumerable sequence. 33 | */ 34 | public static func from(_ array: [E], scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { 35 | return ObservableSequence(elements: array, scheduler: scheduler) 36 | } 37 | 38 | /** 39 | Converts a sequence to an observable sequence. 40 | 41 | - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) 42 | 43 | - returns: The observable sequence whose elements are pulled from the given enumerable sequence. 44 | */ 45 | public static func from(_ sequence: S, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable where S.Iterator.Element == E { 46 | return ObservableSequence(elements: sequence, scheduler: scheduler) 47 | } 48 | } 49 | 50 | final fileprivate class ObservableSequenceSink : Sink where S.Iterator.Element == O.E { 51 | typealias Parent = ObservableSequence 52 | 53 | private let _parent: Parent 54 | 55 | init(parent: Parent, observer: O, cancel: Cancelable) { 56 | _parent = parent 57 | super.init(observer: observer, cancel: cancel) 58 | } 59 | 60 | func run() -> Disposable { 61 | return _parent._scheduler.scheduleRecursive((_parent._elements.makeIterator(), _parent._elements)) { (iterator, recurse) in 62 | var mutableIterator = iterator 63 | if let next = mutableIterator.0.next() { 64 | self.forwardOn(.next(next)) 65 | recurse(mutableIterator) 66 | } 67 | else { 68 | self.forwardOn(.completed) 69 | self.dispose() 70 | } 71 | } 72 | } 73 | } 74 | 75 | final fileprivate class ObservableSequence : Producer { 76 | fileprivate let _elements: S 77 | fileprivate let _scheduler: ImmediateSchedulerType 78 | 79 | init(elements: S, scheduler: ImmediateSchedulerType) { 80 | _elements = elements 81 | _scheduler = scheduler 82 | } 83 | 84 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { 85 | let sink = ObservableSequenceSink(parent: self, observer: observer, cancel: cancel) 86 | let subscription = sink.run() 87 | return (sink: sink, subscription: subscription) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Sink.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sink.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | class Sink : Disposable { 10 | fileprivate let _observer: O 11 | fileprivate let _cancel: Cancelable 12 | fileprivate var _disposed: Bool 13 | 14 | #if DEBUG 15 | fileprivate let _synchronizationTracker = SynchronizationTracker() 16 | #endif 17 | 18 | init(observer: O, cancel: Cancelable) { 19 | #if TRACE_RESOURCES 20 | let _ = Resources.incrementTotal() 21 | #endif 22 | _observer = observer 23 | _cancel = cancel 24 | _disposed = false 25 | } 26 | 27 | final func forwardOn(_ event: Event) { 28 | #if DEBUG 29 | _synchronizationTracker.register(synchronizationErrorMessage: .default) 30 | defer { _synchronizationTracker.unregister() } 31 | #endif 32 | if _disposed { 33 | return 34 | } 35 | _observer.on(event) 36 | } 37 | 38 | final func forwarder() -> SinkForward { 39 | return SinkForward(forward: self) 40 | } 41 | 42 | final var disposed: Bool { 43 | return _disposed 44 | } 45 | 46 | func dispose() { 47 | _disposed = true 48 | _cancel.dispose() 49 | } 50 | 51 | deinit { 52 | #if TRACE_RESOURCES 53 | let _ = Resources.decrementTotal() 54 | #endif 55 | } 56 | } 57 | 58 | final class SinkForward: ObserverType { 59 | typealias E = O.E 60 | 61 | private let _forward: Sink 62 | 63 | init(forward: Sink) { 64 | _forward = forward 65 | } 66 | 67 | final func on(_ event: Event) { 68 | switch event { 69 | case .next: 70 | _forward._observer.on(event) 71 | case .error, .completed: 72 | _forward._observer.on(event) 73 | _forward._cancel.dispose() 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/SkipWhile.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SkipWhile.swift 3 | // RxSwift 4 | // 5 | // Created by Yury Korolev on 10/9/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. 13 | 14 | - seealso: [skipWhile operator on reactivex.io](http://reactivex.io/documentation/operators/skipwhile.html) 15 | 16 | - parameter predicate: A function to test each element for a condition. 17 | - returns: An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. 18 | */ 19 | public func skipWhile(_ predicate: @escaping (E) throws -> Bool) -> Observable { 20 | return SkipWhile(source: asObservable(), predicate: predicate) 21 | } 22 | } 23 | 24 | final fileprivate class SkipWhileSink : Sink, ObserverType { 25 | 26 | typealias Element = O.E 27 | typealias Parent = SkipWhile 28 | 29 | fileprivate let _parent: Parent 30 | fileprivate var _running = false 31 | 32 | init(parent: Parent, observer: O, cancel: Cancelable) { 33 | _parent = parent 34 | super.init(observer: observer, cancel: cancel) 35 | } 36 | 37 | func on(_ event: Event) { 38 | switch event { 39 | case .next(let value): 40 | if !_running { 41 | do { 42 | _running = try !_parent._predicate(value) 43 | } catch let e { 44 | forwardOn(.error(e)) 45 | dispose() 46 | return 47 | } 48 | } 49 | 50 | if _running { 51 | forwardOn(.next(value)) 52 | } 53 | case .error, .completed: 54 | forwardOn(event) 55 | dispose() 56 | } 57 | } 58 | } 59 | 60 | final fileprivate class SkipWhile: Producer { 61 | typealias Predicate = (Element) throws -> Bool 62 | typealias PredicateWithIndex = (Element, Int) throws -> Bool 63 | 64 | fileprivate let _source: Observable 65 | fileprivate let _predicate: Predicate 66 | 67 | init(source: Observable, predicate: @escaping Predicate) { 68 | _source = source 69 | _predicate = predicate 70 | } 71 | 72 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 73 | let sink = SkipWhileSink(parent: self, observer: observer, cancel: cancel) 74 | let subscription = _source.subscribe(sink) 75 | return (sink: sink, subscription: subscription) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/StartWith.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StartWith.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Prepends a sequence of values to an observable sequence. 13 | 14 | - seealso: [startWith operator on reactivex.io](http://reactivex.io/documentation/operators/startwith.html) 15 | 16 | - parameter elements: Elements to prepend to the specified sequence. 17 | - returns: The source sequence prepended with the specified values. 18 | */ 19 | public func startWith(_ elements: E ...) 20 | -> Observable { 21 | return StartWith(source: self.asObservable(), elements: elements) 22 | } 23 | } 24 | 25 | final fileprivate class StartWith: Producer { 26 | let elements: [Element] 27 | let source: Observable 28 | 29 | init(source: Observable, elements: [Element]) { 30 | self.source = source 31 | self.elements = elements 32 | super.init() 33 | } 34 | 35 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 36 | for e in elements { 37 | observer.on(.next(e)) 38 | } 39 | 40 | return (sink: Disposables.create(), subscription: source.subscribe(observer)) 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/SubscribeOn.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubscribeOn.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Wraps the source sequence in order to run its subscription and unsubscription logic on the specified 13 | scheduler. 14 | 15 | This operation is not commonly used. 16 | 17 | This only performs the side-effects of subscription and unsubscription on the specified scheduler. 18 | 19 | In order to invoke observer callbacks on a `scheduler`, use `observeOn`. 20 | 21 | - seealso: [subscribeOn operator on reactivex.io](http://reactivex.io/documentation/operators/subscribeon.html) 22 | 23 | - parameter scheduler: Scheduler to perform subscription and unsubscription actions on. 24 | - returns: The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. 25 | */ 26 | public func subscribeOn(_ scheduler: ImmediateSchedulerType) 27 | -> Observable { 28 | return SubscribeOn(source: self, scheduler: scheduler) 29 | } 30 | } 31 | 32 | final fileprivate class SubscribeOnSink : Sink, ObserverType where Ob.E == O.E { 33 | typealias Element = O.E 34 | typealias Parent = SubscribeOn 35 | 36 | let parent: Parent 37 | 38 | init(parent: Parent, observer: O, cancel: Cancelable) { 39 | self.parent = parent 40 | super.init(observer: observer, cancel: cancel) 41 | } 42 | 43 | func on(_ event: Event) { 44 | forwardOn(event) 45 | 46 | if event.isStopEvent { 47 | self.dispose() 48 | } 49 | } 50 | 51 | func run() -> Disposable { 52 | let disposeEverything = SerialDisposable() 53 | let cancelSchedule = SingleAssignmentDisposable() 54 | 55 | disposeEverything.disposable = cancelSchedule 56 | 57 | let disposeSchedule = parent.scheduler.schedule(()) { (_) -> Disposable in 58 | let subscription = self.parent.source.subscribe(self) 59 | disposeEverything.disposable = ScheduledDisposable(scheduler: self.parent.scheduler, disposable: subscription) 60 | return Disposables.create() 61 | } 62 | 63 | cancelSchedule.setDisposable(disposeSchedule) 64 | 65 | return disposeEverything 66 | } 67 | } 68 | 69 | final fileprivate class SubscribeOn : Producer { 70 | let source: Ob 71 | let scheduler: ImmediateSchedulerType 72 | 73 | init(source: Ob, scheduler: ImmediateSchedulerType) { 74 | self.source = source 75 | self.scheduler = scheduler 76 | } 77 | 78 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Ob.E { 79 | let sink = SubscribeOnSink(parent: self, observer: observer, cancel: cancel) 80 | let subscription = sink.run() 81 | return (sink: sink, subscription: subscription) 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/SwitchIfEmpty.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwitchIfEmpty.swift 3 | // RxSwift 4 | // 5 | // Created by sergdort on 23/12/2016. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Returns the elements of the specified sequence or `switchTo` sequence if the sequence is empty. 12 | 13 | - seealso: [DefaultIfEmpty operator on reactivex.io](http://reactivex.io/documentation/operators/defaultifempty.html) 14 | 15 | - parameter switchTo: Observable sequence being returned when source sequence is empty. 16 | - returns: Observable sequence that contains elements from switchTo sequence if source is empty, otherwise returns source sequence elements. 17 | */ 18 | public func ifEmpty(switchTo other: Observable) -> Observable { 19 | return SwitchIfEmpty(source: asObservable(), ifEmpty: other) 20 | } 21 | } 22 | 23 | final fileprivate class SwitchIfEmpty: Producer { 24 | 25 | private let _source: Observable 26 | private let _ifEmpty: Observable 27 | 28 | init(source: Observable, ifEmpty: Observable) { 29 | _source = source 30 | _ifEmpty = ifEmpty 31 | } 32 | 33 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 34 | let sink = SwitchIfEmptySink(ifEmpty: _ifEmpty, 35 | observer: observer, 36 | cancel: cancel) 37 | let subscription = sink.run(_source.asObservable()) 38 | 39 | return (sink: sink, subscription: subscription) 40 | } 41 | } 42 | 43 | final fileprivate class SwitchIfEmptySink: Sink 44 | , ObserverType { 45 | typealias E = O.E 46 | 47 | private let _ifEmpty: Observable 48 | private var _isEmpty = true 49 | private let _ifEmptySubscription = SingleAssignmentDisposable() 50 | 51 | init(ifEmpty: Observable, observer: O, cancel: Cancelable) { 52 | _ifEmpty = ifEmpty 53 | super.init(observer: observer, cancel: cancel) 54 | } 55 | 56 | func run(_ source: Observable) -> Disposable { 57 | let subscription = source.subscribe(self) 58 | return Disposables.create(subscription, _ifEmptySubscription) 59 | } 60 | 61 | func on(_ event: Event) { 62 | switch event { 63 | case .next: 64 | _isEmpty = false 65 | forwardOn(event) 66 | case .error: 67 | forwardOn(event) 68 | dispose() 69 | case .completed: 70 | guard _isEmpty else { 71 | forwardOn(.completed) 72 | dispose() 73 | return 74 | } 75 | let ifEmptySink = SwitchIfEmptySinkIter(parent: self) 76 | _ifEmptySubscription.setDisposable(_ifEmpty.subscribe(ifEmptySink)) 77 | } 78 | } 79 | } 80 | 81 | final fileprivate class SwitchIfEmptySinkIter 82 | : ObserverType { 83 | typealias E = O.E 84 | typealias Parent = SwitchIfEmptySink 85 | 86 | private let _parent: Parent 87 | 88 | init(parent: Parent) { 89 | _parent = parent 90 | } 91 | 92 | func on(_ event: Event) { 93 | switch event { 94 | case .next: 95 | _parent.forwardOn(event) 96 | case .error: 97 | _parent.forwardOn(event) 98 | _parent.dispose() 99 | case .completed: 100 | _parent.forwardOn(event) 101 | _parent.dispose() 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/TakeLast.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TakeLast.swift 3 | // RxSwift 4 | // 5 | // Created by Tomi Koskinen on 25/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Returns a specified number of contiguous elements from the end of an observable sequence. 13 | 14 | This operator accumulates a buffer with a length enough to store elements count elements. Upon completion of the source sequence, this buffer is drained on the result sequence. This causes the elements to be delayed. 15 | 16 | - seealso: [takeLast operator on reactivex.io](http://reactivex.io/documentation/operators/takelast.html) 17 | 18 | - parameter count: Number of elements to take from the end of the source sequence. 19 | - returns: An observable sequence containing the specified number of elements from the end of the source sequence. 20 | */ 21 | public func takeLast(_ count: Int) 22 | -> Observable { 23 | return TakeLast(source: asObservable(), count: count) 24 | } 25 | } 26 | 27 | final fileprivate class TakeLastSink : Sink, ObserverType { 28 | typealias E = O.E 29 | typealias Parent = TakeLast 30 | 31 | private let _parent: Parent 32 | 33 | private var _elements: Queue 34 | 35 | init(parent: Parent, observer: O, cancel: Cancelable) { 36 | _parent = parent 37 | _elements = Queue(capacity: parent._count + 1) 38 | super.init(observer: observer, cancel: cancel) 39 | } 40 | 41 | func on(_ event: Event) { 42 | switch event { 43 | case .next(let value): 44 | _elements.enqueue(value) 45 | if _elements.count > self._parent._count { 46 | let _ = _elements.dequeue() 47 | } 48 | case .error: 49 | forwardOn(event) 50 | dispose() 51 | case .completed: 52 | for e in _elements { 53 | forwardOn(.next(e)) 54 | } 55 | forwardOn(.completed) 56 | dispose() 57 | } 58 | } 59 | } 60 | 61 | final fileprivate class TakeLast: Producer { 62 | fileprivate let _source: Observable 63 | fileprivate let _count: Int 64 | 65 | init(source: Observable, count: Int) { 66 | if count < 0 { 67 | rxFatalError("count can't be negative") 68 | } 69 | _source = source 70 | _count = count 71 | } 72 | 73 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 74 | let sink = TakeLastSink(parent: self, observer: observer, cancel: cancel) 75 | let subscription = _source.subscribe(sink) 76 | return (sink: sink, subscription: subscription) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/TakeWhile.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TakeWhile.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | 11 | /** 12 | Returns elements from an observable sequence as long as a specified condition is true. 13 | 14 | - seealso: [takeWhile operator on reactivex.io](http://reactivex.io/documentation/operators/takewhile.html) 15 | 16 | - parameter predicate: A function to test each element for a condition. 17 | - returns: An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. 18 | */ 19 | public func takeWhile(_ predicate: @escaping (E) throws -> Bool) 20 | -> Observable { 21 | return TakeWhile(source: asObservable(), predicate: predicate) 22 | } 23 | } 24 | 25 | final fileprivate class TakeWhileSink 26 | : Sink 27 | , ObserverType { 28 | typealias Element = O.E 29 | typealias Parent = TakeWhile 30 | 31 | fileprivate let _parent: Parent 32 | 33 | fileprivate var _running = true 34 | 35 | init(parent: Parent, observer: O, cancel: Cancelable) { 36 | _parent = parent 37 | super.init(observer: observer, cancel: cancel) 38 | } 39 | 40 | func on(_ event: Event) { 41 | switch event { 42 | case .next(let value): 43 | if !_running { 44 | return 45 | } 46 | 47 | do { 48 | _running = try _parent._predicate(value) 49 | } catch let e { 50 | forwardOn(.error(e)) 51 | dispose() 52 | return 53 | } 54 | 55 | if _running { 56 | forwardOn(.next(value)) 57 | } else { 58 | forwardOn(.completed) 59 | dispose() 60 | } 61 | case .error, .completed: 62 | forwardOn(event) 63 | dispose() 64 | } 65 | } 66 | 67 | } 68 | 69 | final fileprivate class TakeWhile: Producer { 70 | typealias Predicate = (Element) throws -> Bool 71 | 72 | fileprivate let _source: Observable 73 | fileprivate let _predicate: Predicate 74 | 75 | init(source: Observable, predicate: @escaping Predicate) { 76 | _source = source 77 | _predicate = predicate 78 | } 79 | 80 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { 81 | let sink = TakeWhileSink(parent: self, observer: observer, cancel: cancel) 82 | let subscription = _source.subscribe(sink) 83 | return (sink: sink, subscription: subscription) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/ToArray.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ToArray.swift 3 | // RxSwift 4 | // 5 | // Created by Junior B. on 20/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | 10 | extension ObservableType { 11 | 12 | /** 13 | Converts an Observable into another Observable that emits the whole sequence as a single array and then terminates. 14 | 15 | For aggregation behavior see `reduce`. 16 | 17 | - seealso: [toArray operator on reactivex.io](http://reactivex.io/documentation/operators/to.html) 18 | 19 | - returns: An observable sequence containing all the emitted elements as array. 20 | */ 21 | public func toArray() 22 | -> Observable<[E]> { 23 | return ToArray(source: self.asObservable()) 24 | } 25 | } 26 | 27 | final fileprivate class ToArraySink : Sink, ObserverType where O.E == [SourceType] { 28 | typealias Parent = ToArray 29 | 30 | let _parent: Parent 31 | var _list = Array() 32 | 33 | init(parent: Parent, observer: O, cancel: Cancelable) { 34 | _parent = parent 35 | 36 | super.init(observer: observer, cancel: cancel) 37 | } 38 | 39 | func on(_ event: Event) { 40 | switch event { 41 | case .next(let value): 42 | self._list.append(value) 43 | case .error(let e): 44 | forwardOn(.error(e)) 45 | self.dispose() 46 | case .completed: 47 | forwardOn(.next(_list)) 48 | forwardOn(.completed) 49 | self.dispose() 50 | } 51 | } 52 | } 53 | 54 | final fileprivate class ToArray : Producer<[SourceType]> { 55 | let _source: Observable 56 | 57 | init(source: Observable) { 58 | _source = source 59 | } 60 | 61 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == [SourceType] { 62 | let sink = ToArraySink(parent: self, observer: observer, cancel: cancel) 63 | let subscription = _source.subscribe(sink) 64 | return (sink: sink, subscription: subscription) 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observables/Using.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Using.swift 3 | // RxSwift 4 | // 5 | // Created by Yury Korolev on 10/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime. 12 | 13 | - seealso: [using operator on reactivex.io](http://reactivex.io/documentation/operators/using.html) 14 | 15 | - parameter resourceFactory: Factory function to obtain a resource object. 16 | - parameter observableFactory: Factory function to obtain an observable sequence that depends on the obtained resource. 17 | - returns: An observable sequence whose lifetime controls the lifetime of the dependent resource object. 18 | */ 19 | public static func using(_ resourceFactory: @escaping () throws -> Resource, observableFactory: @escaping (Resource) throws -> Observable) -> Observable { 20 | return Using(resourceFactory: resourceFactory, observableFactory: observableFactory) 21 | } 22 | } 23 | 24 | final fileprivate class UsingSink : Sink, ObserverType { 25 | typealias SourceType = O.E 26 | typealias Parent = Using 27 | 28 | private let _parent: Parent 29 | 30 | init(parent: Parent, observer: O, cancel: Cancelable) { 31 | _parent = parent 32 | super.init(observer: observer, cancel: cancel) 33 | } 34 | 35 | func run() -> Disposable { 36 | var disposable = Disposables.create() 37 | 38 | do { 39 | let resource = try _parent._resourceFactory() 40 | disposable = resource 41 | let source = try _parent._observableFactory(resource) 42 | 43 | return Disposables.create( 44 | source.subscribe(self), 45 | disposable 46 | ) 47 | } catch let error { 48 | return Disposables.create( 49 | Observable.error(error).subscribe(self), 50 | disposable 51 | ) 52 | } 53 | } 54 | 55 | func on(_ event: Event) { 56 | switch event { 57 | case let .next(value): 58 | forwardOn(.next(value)) 59 | case let .error(error): 60 | forwardOn(.error(error)) 61 | dispose() 62 | case .completed: 63 | forwardOn(.completed) 64 | dispose() 65 | } 66 | } 67 | } 68 | 69 | final fileprivate class Using: Producer { 70 | 71 | typealias E = SourceType 72 | 73 | typealias ResourceFactory = () throws -> ResourceType 74 | typealias ObservableFactory = (ResourceType) throws -> Observable 75 | 76 | fileprivate let _resourceFactory: ResourceFactory 77 | fileprivate let _observableFactory: ObservableFactory 78 | 79 | 80 | init(resourceFactory: @escaping ResourceFactory, observableFactory: @escaping ObservableFactory) { 81 | _resourceFactory = resourceFactory 82 | _observableFactory = observableFactory 83 | } 84 | 85 | override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { 86 | let sink = UsingSink(parent: self, observer: observer, cancel: cancel) 87 | let subscription = sink.run() 88 | return (sink: sink, subscription: subscription) 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/ObserverType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserverType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Supports push-style iteration over an observable sequence. 10 | public protocol ObserverType { 11 | /// The type of elements in sequence that observer can observe. 12 | associatedtype E 13 | 14 | /// Notify observer about sequence event. 15 | /// 16 | /// - parameter event: Event that occurred. 17 | func on(_ event: Event) 18 | } 19 | 20 | /// Convenience API extensions to provide alternate next, error, completed events 21 | extension ObserverType { 22 | 23 | /// Convenience method equivalent to `on(.next(element: E))` 24 | /// 25 | /// - parameter element: Next element to send to observer(s) 26 | public func onNext(_ element: E) { 27 | on(.next(element)) 28 | } 29 | 30 | /// Convenience method equivalent to `on(.completed)` 31 | public func onCompleted() { 32 | on(.completed) 33 | } 34 | 35 | /// Convenience method equivalent to `on(.error(Swift.Error))` 36 | /// - parameter error: Swift.Error to send to observer(s) 37 | public func onError(_ error: Swift.Error) { 38 | on(.error(error)) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousObserver.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | final class AnonymousObserver : ObserverBase { 10 | typealias Element = ElementType 11 | 12 | typealias EventHandler = (Event) -> Void 13 | 14 | private let _eventHandler : EventHandler 15 | 16 | init(_ eventHandler: @escaping EventHandler) { 17 | #if TRACE_RESOURCES 18 | let _ = Resources.incrementTotal() 19 | #endif 20 | _eventHandler = eventHandler 21 | } 22 | 23 | override func onCore(_ event: Event) { 24 | return _eventHandler(event) 25 | } 26 | 27 | #if TRACE_RESOURCES 28 | deinit { 29 | let _ = Resources.decrementTotal() 30 | } 31 | #endif 32 | } 33 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserverBase.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | class ObserverBase : Disposable, ObserverType { 10 | typealias E = ElementType 11 | 12 | private var _isStopped: AtomicInt = 0 13 | 14 | func on(_ event: Event) { 15 | switch event { 16 | case .next: 17 | if _isStopped == 0 { 18 | onCore(event) 19 | } 20 | case .error, .completed: 21 | if AtomicCompareAndSwap(0, 1, &_isStopped) { 22 | onCore(event) 23 | } 24 | } 25 | } 26 | 27 | func onCore(_ event: Event) { 28 | rxAbstractMethod() 29 | } 30 | 31 | func dispose() { 32 | _ = AtomicCompareAndSwap(0, 1, &_isStopped) 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Reactive.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Reactive.swift 3 | // RxSwift 4 | // 5 | // Created by Yury Korolev on 5/2/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /** 10 | Use `Reactive` proxy as customization point for constrained protocol extensions. 11 | 12 | General pattern would be: 13 | 14 | // 1. Extend Reactive protocol with constrain on Base 15 | // Read as: Reactive Extension where Base is a SomeType 16 | extension Reactive where Base: SomeType { 17 | // 2. Put any specific reactive extension for SomeType here 18 | } 19 | 20 | With this approach we can have more specialized methods and properties using 21 | `Base` and not just specialized on common base type. 22 | 23 | */ 24 | 25 | public struct Reactive { 26 | /// Base object to extend. 27 | public let base: Base 28 | 29 | /// Creates extensions with base object. 30 | /// 31 | /// - parameter base: Base object. 32 | public init(_ base: Base) { 33 | self.base = base 34 | } 35 | } 36 | 37 | /// A type that has reactive extensions. 38 | public protocol ReactiveCompatible { 39 | /// Extended type 40 | associatedtype CompatibleType 41 | 42 | /// Reactive extensions. 43 | static var rx: Reactive.Type { get set } 44 | 45 | /// Reactive extensions. 46 | var rx: Reactive { get set } 47 | } 48 | 49 | extension ReactiveCompatible { 50 | /// Reactive extensions. 51 | public static var rx: Reactive.Type { 52 | get { 53 | return Reactive.self 54 | } 55 | set { 56 | // this enables using Reactive to "mutate" base type 57 | } 58 | } 59 | 60 | /// Reactive extensions. 61 | public var rx: Reactive { 62 | get { 63 | return Reactive(self) 64 | } 65 | set { 66 | // this enables using Reactive to "mutate" base object 67 | } 68 | } 69 | } 70 | 71 | import class Foundation.NSObject 72 | 73 | /// Extend NSObject with `rx` proxy. 74 | extension NSObject: ReactiveCompatible { } 75 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/RxMutableBox.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxMutableBox.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/22/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Creates mutable reference wrapper for any type. 10 | final class RxMutableBox : CustomDebugStringConvertible { 11 | /// Wrapped value 12 | var value : T 13 | 14 | /// Creates reference wrapper for `value`. 15 | /// 16 | /// - parameter value: Value to wrap. 17 | init (_ value: T) { 18 | self.value = value 19 | } 20 | } 21 | 22 | extension RxMutableBox { 23 | /// - returns: Box description. 24 | var debugDescription: String { 25 | return "MutatingBox(\(self.value))" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/SchedulerType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SchedulerType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import struct Foundation.TimeInterval 10 | import struct Foundation.Date 11 | 12 | // Type that represents time interval in the context of RxSwift. 13 | public typealias RxTimeInterval = TimeInterval 14 | 15 | /// Type that represents absolute time in the context of RxSwift. 16 | public typealias RxTime = Date 17 | 18 | /// Represents an object that schedules units of work. 19 | public protocol SchedulerType: ImmediateSchedulerType { 20 | 21 | /// - returns: Current time. 22 | var now : RxTime { 23 | get 24 | } 25 | 26 | /** 27 | Schedules an action to be executed. 28 | 29 | - parameter state: State passed to the action to be executed. 30 | - parameter dueTime: Relative time after which to execute the action. 31 | - parameter action: Action to be executed. 32 | - returns: The disposable object used to cancel the scheduled action (best effort). 33 | */ 34 | func scheduleRelative(_ state: StateType, dueTime: RxTimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable 35 | 36 | /** 37 | Schedules a periodic piece of work. 38 | 39 | - parameter state: State passed to the action to be executed. 40 | - parameter startAfter: Period after which initial work should be run. 41 | - parameter period: Period for running the work periodically. 42 | - parameter action: Action to be executed. 43 | - returns: The disposable object used to cancel the scheduled action (best effort). 44 | */ 45 | func schedulePeriodic(_ state: StateType, startAfter: RxTimeInterval, period: RxTimeInterval, action: @escaping (StateType) -> StateType) -> Disposable 46 | } 47 | 48 | extension SchedulerType { 49 | 50 | /** 51 | Periodic task will be emulated using recursive scheduling. 52 | 53 | - parameter state: Initial state passed to the action upon the first iteration. 54 | - parameter startAfter: Period after which initial work should be run. 55 | - parameter period: Period for running the work periodically. 56 | - returns: The disposable object used to cancel the scheduled recurring action (best effort). 57 | */ 58 | public func schedulePeriodic(_ state: StateType, startAfter: RxTimeInterval, period: RxTimeInterval, action: @escaping (StateType) -> StateType) -> Disposable { 59 | let schedule = SchedulePeriodicRecursive(scheduler: self, startAfter: startAfter, period: period, action: action, state: state) 60 | 61 | return schedule.start() 62 | } 63 | 64 | func scheduleRecursive(_ state: State, dueTime: RxTimeInterval, action: @escaping (State, AnyRecursiveScheduler) -> ()) -> Disposable { 65 | let scheduler = AnyRecursiveScheduler(scheduler: self, action: action) 66 | 67 | scheduler.schedule(state, dueTime: dueTime) 68 | 69 | return Disposables.create(with: scheduler.dispose) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConcurrentDispatchQueueScheduler.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 7/5/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import struct Foundation.Date 10 | import struct Foundation.TimeInterval 11 | import Dispatch 12 | 13 | /// Abstracts the work that needs to be performed on a specific `dispatch_queue_t`. You can also pass a serial dispatch queue, it shouldn't cause any problems. 14 | /// 15 | /// This scheduler is suitable when some work needs to be performed in background. 16 | public class ConcurrentDispatchQueueScheduler: SchedulerType { 17 | public typealias TimeInterval = Foundation.TimeInterval 18 | public typealias Time = Date 19 | 20 | public var now : Date { 21 | return Date() 22 | } 23 | 24 | let configuration: DispatchQueueConfiguration 25 | 26 | /// Constructs new `ConcurrentDispatchQueueScheduler` that wraps `queue`. 27 | /// 28 | /// - parameter queue: Target dispatch queue. 29 | public init(queue: DispatchQueue, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0)) { 30 | configuration = DispatchQueueConfiguration(queue: queue, leeway: leeway) 31 | } 32 | 33 | /// Convenience init for scheduler that wraps one of the global concurrent dispatch queues. 34 | /// 35 | /// - parameter qos: Target global dispatch queue, by quality of service class. 36 | @available(iOS 8, OSX 10.10, *) 37 | public convenience init(qos: DispatchQoS, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0)) { 38 | self.init(queue: DispatchQueue( 39 | label: "rxswift.queue.\(qos)", 40 | qos: qos, 41 | attributes: [DispatchQueue.Attributes.concurrent], 42 | target: nil), 43 | leeway: leeway 44 | ) 45 | } 46 | 47 | /** 48 | Schedules an action to be executed immediately. 49 | 50 | - parameter state: State passed to the action to be executed. 51 | - parameter action: Action to be executed. 52 | - returns: The disposable object used to cancel the scheduled action (best effort). 53 | */ 54 | public final func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { 55 | return self.configuration.schedule(state, action: action) 56 | } 57 | 58 | /** 59 | Schedules an action to be executed. 60 | 61 | - parameter state: State passed to the action to be executed. 62 | - parameter dueTime: Relative time after which to execute the action. 63 | - parameter action: Action to be executed. 64 | - returns: The disposable object used to cancel the scheduled action (best effort). 65 | */ 66 | public final func scheduleRelative(_ state: StateType, dueTime: Foundation.TimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable { 67 | return self.configuration.scheduleRelative(state, dueTime: dueTime, action: action) 68 | } 69 | 70 | /** 71 | Schedules a periodic piece of work. 72 | 73 | - parameter state: State passed to the action to be executed. 74 | - parameter startAfter: Period after which initial work should be run. 75 | - parameter period: Period for running the work periodically. 76 | - parameter action: Action to be executed. 77 | - returns: The disposable object used to cancel the scheduled action (best effort). 78 | */ 79 | public func schedulePeriodic(_ state: StateType, startAfter: TimeInterval, period: TimeInterval, action: @escaping (StateType) -> StateType) -> Disposable { 80 | return self.configuration.schedulePeriodic(state, startAfter: startAfter, period: period, action: action) 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConcurrentMainScheduler.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 10/17/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import struct Foundation.Date 10 | import struct Foundation.TimeInterval 11 | import Dispatch 12 | 13 | /** 14 | Abstracts work that needs to be performed on `MainThread`. In case `schedule` methods are called from main thread, it will perform action immediately without scheduling. 15 | 16 | This scheduler is optimized for `subscribeOn` operator. If you want to observe observable sequence elements on main thread using `observeOn` operator, 17 | `MainScheduler` is more suitable for that purpose. 18 | */ 19 | public final class ConcurrentMainScheduler : SchedulerType { 20 | public typealias TimeInterval = Foundation.TimeInterval 21 | public typealias Time = Date 22 | 23 | private let _mainScheduler: MainScheduler 24 | private let _mainQueue: DispatchQueue 25 | 26 | /// - returns: Current time. 27 | public var now : Date { 28 | return _mainScheduler.now as Date 29 | } 30 | 31 | private init(mainScheduler: MainScheduler) { 32 | _mainQueue = DispatchQueue.main 33 | _mainScheduler = mainScheduler 34 | } 35 | 36 | /// Singleton instance of `ConcurrentMainScheduler` 37 | public static let instance = ConcurrentMainScheduler(mainScheduler: MainScheduler.instance) 38 | 39 | /** 40 | Schedules an action to be executed immediately. 41 | 42 | - parameter state: State passed to the action to be executed. 43 | - parameter action: Action to be executed. 44 | - returns: The disposable object used to cancel the scheduled action (best effort). 45 | */ 46 | public func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { 47 | if DispatchQueue.isMain { 48 | return action(state) 49 | } 50 | 51 | let cancel = SingleAssignmentDisposable() 52 | 53 | _mainQueue.async { 54 | if cancel.isDisposed { 55 | return 56 | } 57 | 58 | cancel.setDisposable(action(state)) 59 | } 60 | 61 | return cancel 62 | } 63 | 64 | /** 65 | Schedules an action to be executed. 66 | 67 | - parameter state: State passed to the action to be executed. 68 | - parameter dueTime: Relative time after which to execute the action. 69 | - parameter action: Action to be executed. 70 | - returns: The disposable object used to cancel the scheduled action (best effort). 71 | */ 72 | public final func scheduleRelative(_ state: StateType, dueTime: Foundation.TimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable { 73 | return _mainScheduler.scheduleRelative(state, dueTime: dueTime, action: action) 74 | } 75 | 76 | /** 77 | Schedules a periodic piece of work. 78 | 79 | - parameter state: State passed to the action to be executed. 80 | - parameter startAfter: Period after which initial work should be run. 81 | - parameter period: Period for running the work periodically. 82 | - parameter action: Action to be executed. 83 | - returns: The disposable object used to cancel the scheduled action (best effort). 84 | */ 85 | public func schedulePeriodic(_ state: StateType, startAfter: TimeInterval, period: TimeInterval, action: @escaping (StateType) -> StateType) -> Disposable { 86 | return _mainScheduler.schedulePeriodic(state, startAfter: startAfter, period: period, action: action) 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HistoricalScheduler.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 12/27/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import struct Foundation.Date 10 | 11 | /// Provides a virtual time scheduler that uses `Date` for absolute time and `NSTimeInterval` for relative time. 12 | public class HistoricalScheduler : VirtualTimeScheduler { 13 | 14 | /** 15 | Creates a new historical scheduler with initial clock value. 16 | 17 | - parameter initialClock: Initial value for virtual clock. 18 | */ 19 | public init(initialClock: RxTime = Date(timeIntervalSince1970: 0)) { 20 | super.init(initialClock: initialClock, converter: HistoricalSchedulerTimeConverter()) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HistoricalSchedulerTimeConverter.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 12/27/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import struct Foundation.Date 10 | 11 | /// Converts historial virtual time into real time. 12 | /// 13 | /// Since historical virtual time is also measured in `Date`, this converter is identity function. 14 | public struct HistoricalSchedulerTimeConverter : VirtualTimeConverterType { 15 | /// Virtual time unit used that represents ticks of virtual clock. 16 | public typealias VirtualTimeUnit = RxTime 17 | 18 | /// Virtual time unit used to represent differences of virtual times. 19 | public typealias VirtualTimeIntervalUnit = RxTimeInterval 20 | 21 | /// Returns identical value of argument passed because historical virtual time is equal to real time, just 22 | /// decoupled from local machine clock. 23 | public func convertFromVirtualTime(_ virtualTime: VirtualTimeUnit) -> RxTime { 24 | return virtualTime 25 | } 26 | 27 | /// Returns identical value of argument passed because historical virtual time is equal to real time, just 28 | /// decoupled from local machine clock. 29 | public func convertToVirtualTime(_ time: RxTime) -> VirtualTimeUnit { 30 | return time 31 | } 32 | 33 | /// Returns identical value of argument passed because historical virtual time is equal to real time, just 34 | /// decoupled from local machine clock. 35 | public func convertFromVirtualTimeInterval(_ virtualTimeInterval: VirtualTimeIntervalUnit) -> RxTimeInterval { 36 | return virtualTimeInterval 37 | } 38 | 39 | /// Returns identical value of argument passed because historical virtual time is equal to real time, just 40 | /// decoupled from local machine clock. 41 | public func convertToVirtualTimeInterval(_ timeInterval: RxTimeInterval) -> VirtualTimeIntervalUnit { 42 | return timeInterval 43 | } 44 | 45 | /** 46 | Offsets `Date` by time interval. 47 | 48 | - parameter time: Time. 49 | - parameter timeInterval: Time interval offset. 50 | - returns: Time offsetted by time interval. 51 | */ 52 | public func offsetVirtualTime(_ time: VirtualTimeUnit, offset: VirtualTimeIntervalUnit) -> VirtualTimeUnit { 53 | return time.addingTimeInterval(offset) 54 | } 55 | 56 | /// Compares two `Date`s. 57 | public func compareVirtualTime(_ lhs: VirtualTimeUnit, _ rhs: VirtualTimeUnit) -> VirtualTimeComparison { 58 | switch lhs.compare(rhs as Date) { 59 | case .orderedAscending: 60 | return .lessThan 61 | case .orderedSame: 62 | return .equal 63 | case .orderedDescending: 64 | return .greaterThan 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InvocableScheduledItem.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | struct InvocableScheduledItem : InvocableType { 10 | 11 | let _invocable: I 12 | let _state: I.Value 13 | 14 | init(invocable: I, state: I.Value) { 15 | _invocable = invocable 16 | _state = state 17 | } 18 | 19 | func invoke() { 20 | _invocable.invoke(_state) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InvocableType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol InvocableType { 10 | func invoke() 11 | } 12 | 13 | protocol InvocableWithValueType { 14 | associatedtype Value 15 | 16 | func invoke(_ value: Value) 17 | } 18 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledItem.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | struct ScheduledItem 10 | : ScheduledItemType 11 | , InvocableType { 12 | typealias Action = (T) -> Disposable 13 | 14 | private let _action: Action 15 | private let _state: T 16 | 17 | private let _disposable = SingleAssignmentDisposable() 18 | 19 | var isDisposed: Bool { 20 | return _disposable.isDisposed 21 | } 22 | 23 | init(action: @escaping Action, state: T) { 24 | _action = action 25 | _state = state 26 | } 27 | 28 | func invoke() { 29 | _disposable.setDisposable(_action(_state)) 30 | } 31 | 32 | func dispose() { 33 | _disposable.dispose() 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledItemType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | protocol ScheduledItemType 10 | : Cancelable 11 | , InvocableType { 12 | func invoke() 13 | } 14 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainScheduler.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Dispatch 10 | 11 | /** 12 | Abstracts work that needs to be performed on `DispatchQueue.main`. In case `schedule` methods are called from `DispatchQueue.main`, it will perform action immediately without scheduling. 13 | 14 | This scheduler is usually used to perform UI work. 15 | 16 | Main scheduler is a specialization of `SerialDispatchQueueScheduler`. 17 | 18 | This scheduler is optimized for `observeOn` operator. To ensure observable sequence is subscribed on main thread using `subscribeOn` 19 | operator please use `ConcurrentMainScheduler` because it is more optimized for that purpose. 20 | */ 21 | public final class MainScheduler : SerialDispatchQueueScheduler { 22 | 23 | private let _mainQueue: DispatchQueue 24 | 25 | var numberEnqueued: AtomicInt = 0 26 | 27 | /// Initializes new instance of `MainScheduler`. 28 | public init() { 29 | _mainQueue = DispatchQueue.main 30 | super.init(serialQueue: _mainQueue) 31 | } 32 | 33 | /// Singleton instance of `MainScheduler` 34 | public static let instance = MainScheduler() 35 | 36 | /// Singleton instance of `MainScheduler` that always schedules work asynchronously 37 | /// and doesn't perform optimizations for calls scheduled from main queue. 38 | public static let asyncInstance = SerialDispatchQueueScheduler(serialQueue: DispatchQueue.main) 39 | 40 | /// In case this method is called on a background thread it will throw an exception. 41 | public class func ensureExecutingOnScheduler(errorMessage: String? = nil) { 42 | if !DispatchQueue.isMain { 43 | rxFatalError(errorMessage ?? "Executing on backgound thread. Please use `MainScheduler.instance.schedule` to schedule work on main thread.") 44 | } 45 | } 46 | 47 | override func scheduleInternal(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { 48 | let currentNumberEnqueued = AtomicIncrement(&numberEnqueued) 49 | 50 | if DispatchQueue.isMain && currentNumberEnqueued == 1 { 51 | let disposable = action(state) 52 | _ = AtomicDecrement(&numberEnqueued) 53 | return disposable 54 | } 55 | 56 | let cancel = SingleAssignmentDisposable() 57 | 58 | _mainQueue.async { 59 | if !cancel.isDisposed { 60 | _ = action(state) 61 | } 62 | 63 | _ = AtomicDecrement(&self.numberEnqueued) 64 | } 65 | 66 | return cancel 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OperationQueueScheduler.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import class Foundation.OperationQueue 10 | import class Foundation.BlockOperation 11 | import Dispatch 12 | 13 | /// Abstracts the work that needs to be performed on a specific `NSOperationQueue`. 14 | /// 15 | /// This scheduler is suitable for cases when there is some bigger chunk of work that needs to be performed in background and you want to fine tune concurrent processing using `maxConcurrentOperationCount`. 16 | public class OperationQueueScheduler: ImmediateSchedulerType { 17 | public let operationQueue: OperationQueue 18 | 19 | /// Constructs new instance of `OperationQueueScheduler` that performs work on `operationQueue`. 20 | /// 21 | /// - parameter operationQueue: Operation queue targeted to perform work on. 22 | public init(operationQueue: OperationQueue) { 23 | self.operationQueue = operationQueue 24 | } 25 | 26 | /** 27 | Schedules an action to be executed recursively. 28 | 29 | - parameter state: State passed to the action to be executed. 30 | - parameter action: Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. 31 | - returns: The disposable object used to cancel the scheduled action (best effort). 32 | */ 33 | public func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { 34 | let cancel = SingleAssignmentDisposable() 35 | 36 | let operation = BlockOperation { 37 | if cancel.isDisposed { 38 | return 39 | } 40 | 41 | 42 | cancel.setDisposable(action(state)) 43 | } 44 | 45 | self.operationQueue.addOperation(operation) 46 | 47 | return cancel 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SchedulerServices+Emulation.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | enum SchedulePeriodicRecursiveCommand { 10 | case tick 11 | case dispatchStart 12 | } 13 | 14 | final class SchedulePeriodicRecursive { 15 | typealias RecursiveAction = (State) -> State 16 | typealias RecursiveScheduler = AnyRecursiveScheduler 17 | 18 | private let _scheduler: SchedulerType 19 | private let _startAfter: RxTimeInterval 20 | private let _period: RxTimeInterval 21 | private let _action: RecursiveAction 22 | 23 | private var _state: State 24 | private var _pendingTickCount: AtomicInt = 0 25 | 26 | init(scheduler: SchedulerType, startAfter: RxTimeInterval, period: RxTimeInterval, action: @escaping RecursiveAction, state: State) { 27 | _scheduler = scheduler 28 | _startAfter = startAfter 29 | _period = period 30 | _action = action 31 | _state = state 32 | } 33 | 34 | func start() -> Disposable { 35 | return _scheduler.scheduleRecursive(SchedulePeriodicRecursiveCommand.tick, dueTime: _startAfter, action: self.tick) 36 | } 37 | 38 | func tick(_ command: SchedulePeriodicRecursiveCommand, scheduler: RecursiveScheduler) -> Void { 39 | // Tries to emulate periodic scheduling as best as possible. 40 | // The problem that could arise is if handling periodic ticks take too long, or 41 | // tick interval is short. 42 | switch command { 43 | case .tick: 44 | scheduler.schedule(.tick, dueTime: _period) 45 | 46 | // The idea is that if on tick there wasn't any item enqueued, schedule to perform work immediately. 47 | // Else work will be scheduled after previous enqueued work completes. 48 | if AtomicIncrement(&_pendingTickCount) == 1 { 49 | self.tick(.dispatchStart, scheduler: scheduler) 50 | } 51 | 52 | case .dispatchStart: 53 | _state = _action(_state) 54 | // Start work and schedule check is this last batch of work 55 | if AtomicDecrement(&_pendingTickCount) > 0 { 56 | // This gives priority to scheduler emulation, it's not perfect, but helps 57 | scheduler.schedule(SchedulePeriodicRecursiveCommand.dispatchStart) 58 | } 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // VirtualTimeConverterType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 12/23/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Parametrization for virtual time used by `VirtualTimeScheduler`s. 10 | public protocol VirtualTimeConverterType { 11 | /// Virtual time unit used that represents ticks of virtual clock. 12 | associatedtype VirtualTimeUnit 13 | 14 | /// Virtual time unit used to represent differences of virtual times. 15 | associatedtype VirtualTimeIntervalUnit 16 | 17 | /** 18 | Converts virtual time to real time. 19 | 20 | - parameter virtualTime: Virtual time to convert to `Date`. 21 | - returns: `Date` corresponding to virtual time. 22 | */ 23 | func convertFromVirtualTime(_ virtualTime: VirtualTimeUnit) -> RxTime 24 | 25 | /** 26 | Converts real time to virtual time. 27 | 28 | - parameter time: `Date` to convert to virtual time. 29 | - returns: Virtual time corresponding to `Date`. 30 | */ 31 | func convertToVirtualTime(_ time: RxTime) -> VirtualTimeUnit 32 | 33 | /** 34 | Converts from virtual time interval to `NSTimeInterval`. 35 | 36 | - parameter virtualTimeInterval: Virtual time interval to convert to `NSTimeInterval`. 37 | - returns: `NSTimeInterval` corresponding to virtual time interval. 38 | */ 39 | func convertFromVirtualTimeInterval(_ virtualTimeInterval: VirtualTimeIntervalUnit) -> RxTimeInterval 40 | 41 | /** 42 | Converts from virtual time interval to `NSTimeInterval`. 43 | 44 | - parameter timeInterval: `NSTimeInterval` to convert to virtual time interval. 45 | - returns: Virtual time interval corresponding to time interval. 46 | */ 47 | func convertToVirtualTimeInterval(_ timeInterval: RxTimeInterval) -> VirtualTimeIntervalUnit 48 | 49 | /** 50 | Offsets virtual time by virtual time interval. 51 | 52 | - parameter time: Virtual time. 53 | - parameter offset: Virtual time interval. 54 | - returns: Time corresponding to time offsetted by virtual time interval. 55 | */ 56 | func offsetVirtualTime(_ time: VirtualTimeUnit, offset: VirtualTimeIntervalUnit) -> VirtualTimeUnit 57 | 58 | /** 59 | This is aditional abstraction because `Date` is unfortunately not comparable. 60 | Extending `Date` with `Comparable` would be too risky because of possible collisions with other libraries. 61 | */ 62 | func compareVirtualTime(_ lhs: VirtualTimeUnit, _ rhs: VirtualTimeUnit) -> VirtualTimeComparison 63 | } 64 | 65 | /** 66 | Virtual time comparison result. 67 | 68 | This is aditional abstraction because `Date` is unfortunately not comparable. 69 | Extending `Date` with `Comparable` would be too risky because of possible collisions with other libraries. 70 | */ 71 | public enum VirtualTimeComparison { 72 | /// lhs < rhs. 73 | case lessThan 74 | /// lhs == rhs. 75 | case equal 76 | /// lhs > rhs. 77 | case greaterThan 78 | } 79 | 80 | extension VirtualTimeComparison { 81 | /// lhs < rhs. 82 | var lessThen: Bool { 83 | return self == .lessThan 84 | } 85 | 86 | /// lhs > rhs 87 | var greaterThan: Bool { 88 | return self == .greaterThan 89 | } 90 | 91 | /// lhs == rhs 92 | var equal: Bool { 93 | return self == .equal 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Subjects/SubjectType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubjectType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | /// Represents an object that is both an observable sequence as well as an observer. 10 | public protocol SubjectType : ObservableType { 11 | /// The type of the observer that represents this subject. 12 | /// 13 | /// Usually this type is type of subject itself, but it doesn't have to be. 14 | associatedtype SubjectObserverType : ObserverType 15 | 16 | /// Returns observer interface for subject. 17 | /// 18 | /// - returns: Observer interface for subject. 19 | func asObserver() -> SubjectObserverType 20 | 21 | } 22 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/SwiftSupport/SwiftSupport.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftSupport.swift 3 | // RxSwift 4 | // 5 | // Created by Volodymyr Gorbenko on 3/6/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if swift(>=4.0) 12 | typealias IntMax = Int64 13 | public typealias RxAbstractInteger = FixedWidthInteger 14 | 15 | extension SignedInteger { 16 | func toIntMax() -> IntMax { 17 | return IntMax(self) 18 | } 19 | } 20 | #else 21 | public typealias RxAbstractInteger = SignedInteger 22 | 23 | extension Array { 24 | public mutating func swapAt(_ i: Int, _ j: Int) { 25 | swap(&self[i], &self[j]) 26 | } 27 | } 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /Example/Pods/RxSwift/RxSwift/Traits/ObservableType+PrimitiveSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableType+PrimitiveSequence.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 9/17/17. 6 | // Copyright © 2017 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension ObservableType { 10 | /** 11 | The `asSingle` operator throws a `RxError.noElements` or `RxError.moreThanOneElement` 12 | if the source Observable does not emit exactly one element before successfully completing. 13 | 14 | - seealso: [single operator on reactivex.io](http://reactivex.io/documentation/operators/first.html) 15 | 16 | - returns: An observable sequence that emits a single element or throws an exception if more (or none) of them are emitted. 17 | */ 18 | public func asSingle() -> Single { 19 | return PrimitiveSequence(raw: AsSingle(source: self.asObservable())) 20 | } 21 | 22 | /** 23 | The `asMaybe` operator throws a ``RxError.moreThanOneElement` 24 | if the source Observable does not emit at most one element before successfully completing. 25 | 26 | - seealso: [single operator on reactivex.io](http://reactivex.io/documentation/operators/first.html) 27 | 28 | - returns: An observable sequence that emits a single element, completes or throws an exception if more of them are emitted. 29 | */ 30 | public func asMaybe() -> Maybe { 31 | return PrimitiveSequence(raw: AsMaybe(source: self.asObservable())) 32 | } 33 | } 34 | 35 | extension ObservableType where E == Never { 36 | /** 37 | - returns: An observable sequence that completes. 38 | */ 39 | public func asCompletable() 40 | -> Completable { 41 | return PrimitiveSequence(raw: self.asObservable()) 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Example/Pods-RxSmartBag_Example-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## RxSmartBag 5 | 6 | MIT License 7 | 8 | Copyright (c) 2017 rinov 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in all 18 | copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | SOFTWARE. 27 | 28 | ## RxSwift 29 | 30 | **The MIT License** 31 | **Copyright © 2015 Krunoslav Zaher** 32 | **All rights reserved.** 33 | 34 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 35 | 36 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 37 | 38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 39 | Generated by CocoaPods - https://cocoapods.org 40 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Example/Pods-RxSmartBag_Example-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | MIT License 18 | 19 | Copyright (c) 2017 rinov 20 | 21 | Permission is hereby granted, free of charge, to any person obtaining a copy 22 | of this software and associated documentation files (the "Software"), to deal 23 | in the Software without restriction, including without limitation the rights 24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 25 | copies of the Software, and to permit persons to whom the Software is 26 | furnished to do so, subject to the following conditions: 27 | 28 | The above copyright notice and this permission notice shall be included in all 29 | copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 | SOFTWARE. 38 | License 39 | MIT 40 | Title 41 | RxSmartBag 42 | Type 43 | PSGroupSpecifier 44 | 45 | 46 | FooterText 47 | **The MIT License** 48 | **Copyright © 2015 Krunoslav Zaher** 49 | **All rights reserved.** 50 | 51 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 52 | 53 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 54 | 55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 56 | License 57 | MIT 58 | Title 59 | RxSwift 60 | Type 61 | PSGroupSpecifier 62 | 63 | 64 | FooterText 65 | Generated by CocoaPods - https://cocoapods.org 66 | Title 67 | 68 | Type 69 | PSGroupSpecifier 70 | 71 | 72 | StringsTable 73 | Acknowledgements 74 | Title 75 | Acknowledgements 76 | 77 | 78 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Example/Pods-RxSmartBag_Example-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RxSmartBag_Example : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RxSmartBag_Example 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Example/Pods-RxSmartBag_Example-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_RxSmartBag_ExampleVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_RxSmartBag_ExampleVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Example/Pods-RxSmartBag_Example.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RxSmartBag" "$PODS_CONFIGURATION_BUILD_DIR/RxSwift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RxSmartBag/RxSmartBag.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RxSwift/RxSwift.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "RxSmartBag" -framework "RxSwift" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Example/Pods-RxSmartBag_Example.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_RxSmartBag_Example { 2 | umbrella header "Pods-RxSmartBag_Example-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Example/Pods-RxSmartBag_Example.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RxSmartBag" "$PODS_CONFIGURATION_BUILD_DIR/RxSwift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RxSmartBag/RxSmartBag.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RxSwift/RxSwift.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "RxSmartBag" -framework "RxSwift" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_BUILD_DIR = $BUILD_DIR 9 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 10 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Pods-RxSmartBag_Tests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | Generated by CocoaPods - https://cocoapods.org 4 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Pods-RxSmartBag_Tests-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Generated by CocoaPods - https://cocoapods.org 18 | Title 19 | 20 | Type 21 | PSGroupSpecifier 22 | 23 | 24 | StringsTable 25 | Acknowledgements 26 | Title 27 | Acknowledgements 28 | 29 | 30 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Pods-RxSmartBag_Tests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RxSmartBag_Tests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RxSmartBag_Tests 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Pods-RxSmartBag_Tests-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements '$1'" 63 | 64 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 65 | code_sign_cmd="$code_sign_cmd &" 66 | fi 67 | echo "$code_sign_cmd" 68 | eval "$code_sign_cmd" 69 | fi 70 | } 71 | 72 | # Strip invalid architectures 73 | strip_invalid_archs() { 74 | binary="$1" 75 | # Get architectures for current file 76 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 77 | stripped="" 78 | for arch in $archs; do 79 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 80 | # Strip non-valid architectures in-place 81 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 82 | stripped="$stripped $arch" 83 | fi 84 | done 85 | if [[ "$stripped" ]]; then 86 | echo "Stripped $binary of architectures:$stripped" 87 | fi 88 | } 89 | 90 | if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then 91 | wait 92 | fi 93 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Pods-RxSmartBag_Tests-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double Pods_RxSmartBag_TestsVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char Pods_RxSmartBag_TestsVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Pods-RxSmartBag_Tests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RxSmartBag" "$PODS_CONFIGURATION_BUILD_DIR/RxSwift" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RxSmartBag/RxSmartBag.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RxSwift/RxSwift.framework/Headers" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Pods-RxSmartBag_Tests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_RxSmartBag_Tests { 2 | umbrella header "Pods-RxSmartBag_Tests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/Pods-RxSmartBag_Tests/Pods-RxSmartBag_Tests.release.xcconfig: -------------------------------------------------------------------------------- 1 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RxSmartBag" "$PODS_CONFIGURATION_BUILD_DIR/RxSwift" 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 4 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/RxSmartBag/RxSmartBag.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/RxSwift/RxSwift.framework/Headers" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_PODFILE_DIR_PATH = ${SRCROOT}/. 8 | PODS_ROOT = ${SRCROOT}/Pods 9 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSmartBag/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSmartBag/RxSmartBag-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_RxSmartBag : NSObject 3 | @end 4 | @implementation PodsDummy_RxSmartBag 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSmartBag/RxSmartBag-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSmartBag/RxSmartBag-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double RxSmartBagVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char RxSmartBagVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSmartBag/RxSmartBag.modulemap: -------------------------------------------------------------------------------- 1 | framework module RxSmartBag { 2 | umbrella header "RxSmartBag-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSmartBag/RxSmartBag.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/RxSmartBag 2 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/RxSwift" 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 5 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 6 | PODS_BUILD_DIR = $BUILD_DIR 7 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 8 | PODS_ROOT = ${SRCROOT} 9 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/../.. 10 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | SKIP_INSTALL = YES 12 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | ${PRODUCT_BUNDLE_IDENTIFIER} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 4.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_RxSwift : NSObject 3 | @end 4 | @implementation PodsDummy_RxSwift 5 | @end 6 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #else 4 | #ifndef FOUNDATION_EXPORT 5 | #if defined(__cplusplus) 6 | #define FOUNDATION_EXPORT extern "C" 7 | #else 8 | #define FOUNDATION_EXPORT extern 9 | #endif 10 | #endif 11 | #endif 12 | 13 | 14 | FOUNDATION_EXPORT double RxSwiftVersionNumber; 15 | FOUNDATION_EXPORT const unsigned char RxSwiftVersionString[]; 16 | 17 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift.modulemap: -------------------------------------------------------------------------------- 1 | framework module RxSwift { 2 | umbrella header "RxSwift-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Example/Pods/Target Support Files/RxSwift/RxSwift.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/RxSwift 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PODS_TARGET_SRCROOT = ${PODS_ROOT}/RxSwift 9 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 10 | SKIP_INSTALL = YES 11 | -------------------------------------------------------------------------------- /Example/RxSmartBag.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/RxSmartBag.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Example/RxSmartBag/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // RxSmartBag 4 | // 5 | // Created by rinov on 05/11/2017. 6 | // Copyright (c) 2017 rinov. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 17 | return true 18 | } 19 | 20 | func applicationWillResignActive(_ application: UIApplication) { 21 | } 22 | 23 | func applicationDidEnterBackground(_ application: UIApplication) { 24 | } 25 | 26 | func applicationWillEnterForeground(_ application: UIApplication) { 27 | } 28 | 29 | func applicationDidBecomeActive(_ application: UIApplication) { 30 | } 31 | 32 | func applicationWillTerminate(_ application: UIApplication) { 33 | } 34 | 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Example/RxSmartBag/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/RxSmartBag/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Example/RxSmartBag/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Example/RxSmartBag/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/RxSmartBag/UIViewControllerExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewControllerExtension.swift 3 | // RxSmartBag 4 | // 5 | // Created by 石川 諒 on 2017/05/13. 6 | // Copyright © 2017年 CocoaPods. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import RxSmartBag 11 | 12 | // Extension for Adding `smartBag` into `UIViewController`. 13 | extension UIViewController: SmartBagManagerable {} 14 | -------------------------------------------------------------------------------- /Example/RxSmartBag/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // RxSmartBag 4 | // 5 | // Created by rinov on 05/11/2017. 6 | // Copyright (c) 2017 rinov. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import RxSwift 11 | 12 | // Use `smartBag` 13 | import RxSmartBag 14 | 15 | final class ViewController: UIViewController { 16 | 17 | let text = Variable("RxSmartBag") 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | // `smartBag` is a dispose bag and automatically released when `ViewController` is deinit. 23 | 24 | // Example1: 25 | text 26 | .asObservable() 27 | .map { "Text(1) = \($0)" } 28 | .subscribe(onNext: { message in 29 | print(message) 30 | }) 31 | .disposed(by: smartBag) 32 | 33 | // Example2: 34 | text 35 | .asObservable() 36 | .map { "Text(2) = \($0)" } 37 | .subscribe(onNext: { message in 38 | print(message) 39 | }) 40 | .disposed(by: self) 41 | 42 | // Example3: 43 | smartBag += text 44 | .asObservable() 45 | .map { "Text(3) = \($0)" } 46 | .subscribe(onNext: { message in 47 | print(message) 48 | }) 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Example/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 rinov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RxSmartBag 2 | 3 | [![Language](https://img.shields.io/badge/Language-Swift-blue.svg)](https://img.shields.io/badge/Language-Swift-blue.svg) 4 | [![License](https://img.shields.io/badge/LICENSE-MIT-orange.svg)](https://img.shields.io/badge/LICENSE-MIT-orange.svg) 5 | [![Platform](https://img.shields.io/badge/Platform-iOS-lightgrey.svg)](https://img.shields.io/badge/Platform-iOS-lightgrey.svg) 6 | 7 | ## About 8 | 9 | A simple way to omit declararing `DisposeBag`. 10 | 11 | ## Example 12 | 13 | ```swift 14 | import UIKit 15 | import RxSmartBag 16 | 17 | extension UIViewController: SmartBagManagerable {} 18 | ``` 19 | 20 | ```swift 21 | import RxSmartBag 22 | 23 | class ViewController: UIViewController { 24 | override func viewDidLoad() { 25 | super.viewDidLoad() 26 | 27 | // `smartBag` is able to use without declararing, and can bind simply by operator. 28 | 29 | // Example 1: 30 | observable.subscribe(...).disposed(by: smartBag) 31 | 32 | // Example 2: 33 | observable.subscribe(...).disposed(by: self) 34 | 35 | // Example 3: 36 | smartBag += observable.subscribe(...) 37 | 38 | } 39 | ``` 40 | 41 | ## Installation 42 | 43 | RxSmartBag is available through [CocoaPods](http://cocoapods.org). To install 44 | it, simply add the following line to your Podfile: 45 | 46 | ```ruby 47 | pod "RxSmartBag" 48 | ``` 49 | 50 | Swift3: `pod "RxSmartBag", "~> 1.0.2"` 51 | 52 | Swift4: `pod "RxSmartBag", "~> 2.0.0"` 53 | 54 | ## Author 55 | 56 | rinov, rinov@rinov.jp 57 | 58 | ## License 59 | 60 | RxSmartBag is available under the MIT license. See the LICENSE file for more info. 61 | -------------------------------------------------------------------------------- /RxSmartBag.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = 'RxSmartBag' 3 | s.version = '2.0.0' 4 | s.summary = 'A useful dispose bag for RxSwift.' 5 | s.description = <<-DESC 6 | A simple way to omit declararing DisposeBag. 7 | DESC 8 | 9 | s.homepage = 'https://github.com/rinov/RxSmartBag' 10 | s.license = { :type => 'MIT', :file => 'LICENSE' } 11 | s.author = { 'rinov' => 'rinov@rinov.jp' } 12 | s.source = { :git => 'https://github.com/rinov/RxSmartBag.git', :tag => s.version.to_s } 13 | s.ios.deployment_target = '8.0' 14 | s.source_files = 'RxSmartBag/Classes/**/*' 15 | s.dependency 'RxSwift', '~> 4.0' 16 | end 17 | -------------------------------------------------------------------------------- /RxSmartBag/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rinov/RxSmartBag/d37b53cf05e0f74b0e65f7d2cda6d99ce0ee8814/RxSmartBag/Assets/.gitkeep -------------------------------------------------------------------------------- /RxSmartBag/Classes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rinov/RxSmartBag/d37b53cf05e0f74b0e65f7d2cda6d99ce0ee8814/RxSmartBag/Classes/.gitkeep -------------------------------------------------------------------------------- /RxSmartBag/Classes/RxSmartBag.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxSmartBag.swift 3 | // Pods 4 | // 5 | // Created by Ryo Ishikawa on 2017/05/11. 6 | // 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | 12 | // `AllocatedObject` is used for associated object. 13 | extension DisposeBag { 14 | struct AllocatedObject { 15 | static var instance = DisposeBag() 16 | } 17 | } 18 | 19 | //`SmartBagManagerable` represents that having a stored property of dispose bag by automatically. 20 | public protocol SmartBagManagerable { 21 | var smartBag: DisposeBag { get set } 22 | } 23 | 24 | // Implements smartBag by objective-c runtime functions. 25 | extension SmartBagManagerable { 26 | public var smartBag: DisposeBag { 27 | get { 28 | var disposeBag: DisposeBag! 29 | synchronized { 30 | if let lookup = objc_getAssociatedObject(self, &DisposeBag.AllocatedObject.instance) as? DisposeBag { 31 | disposeBag = lookup 32 | } else { 33 | // If a new dispose bag were setted,`smartBag` will release current disposable reference immediately. 34 | disposeBag = associateObject(newValue: DisposeBag()) 35 | } 36 | } 37 | return disposeBag 38 | } 39 | set { 40 | associateObject(newValue: newValue) 41 | } 42 | } 43 | 44 | private func synchronized(_ closure: () -> ()) { 45 | objc_sync_enter(self) 46 | defer { objc_sync_exit(self) } 47 | closure() 48 | } 49 | 50 | @discardableResult 51 | private func associateObject(newValue: DisposeBag) -> DisposeBag { 52 | synchronized { 53 | objc_setAssociatedObject(self, &DisposeBag.AllocatedObject.instance, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) 54 | } 55 | return newValue 56 | } 57 | } 58 | 59 | // For more simply syntax, like `smartBag += A.subscribe(...)`. 60 | public func += (lhs: DisposeBag, rhs: Disposable) { 61 | rhs.disposed(by: lhs) 62 | } 63 | 64 | extension Disposable { 65 | public func disposed(by bag: SmartBagManagerable) { 66 | bag.smartBag.insert(self) 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj --------------------------------------------------------------------------------