From 67ee0c5b3f3ed88f0644f9a48c95b6d1d9af5a8c Mon Sep 17 00:00:00 2001 From: fe9lix Date: Sun, 9 Oct 2016 23:02:31 +0200 Subject: [PATCH] Add first version of Protium v3 example. --- .gitignore | 68 + Podfile | 29 + Podfile.lock | 30 + Pods/JASON/LICENSE | 19 + Pods/JASON/README.md | 305 + Pods/JASON/Source/JSON.swift | 159 + Pods/JASON/Source/JSONKey.swift | 436 + Pods/JASON/Source/LiteralConvertible.swift | 163 + Pods/JASON/Source/Properties.swift | 138 + Pods/JASON/Source/SequenceType.swift | 47 + Pods/JASON/Source/Supporting Files/JASON.h | 29 + .../Source/Supporting Files/Utilities.swift | 48 + Pods/Kingfisher/LICENSE | 22 + Pods/Kingfisher/README.md | 86 + .../Sources/AnimatedImageView.swift | 331 + Pods/Kingfisher/Sources/Box.swift | 16 + Pods/Kingfisher/Sources/CacheSerializer.swift | 85 + Pods/Kingfisher/Sources/Filter.swift | 145 + Pods/Kingfisher/Sources/Image.swift | 938 ++ Pods/Kingfisher/Sources/ImageCache.swift | 683 + Pods/Kingfisher/Sources/ImageDownloader.swift | 538 + Pods/Kingfisher/Sources/ImagePrefetcher.swift | 267 + Pods/Kingfisher/Sources/ImageProcessor.swift | 365 + Pods/Kingfisher/Sources/ImageTransition.swift | 128 + .../Sources/ImageView+Kingfisher.swift | 292 + Pods/Kingfisher/Sources/Indicator.swift | 191 + Pods/Kingfisher/Sources/Kingfisher.h | 37 + Pods/Kingfisher/Sources/Kingfisher.swift | 72 + .../Sources/KingfisherManager.swift | 213 + .../Sources/KingfisherOptionsInfo.swift | 255 + Pods/Kingfisher/Sources/RequrstModifier.swift | 53 + Pods/Kingfisher/Sources/Resource.swift | 74 + Pods/Kingfisher/Sources/String+MD5.swift | 288 + Pods/Kingfisher/Sources/ThreadHelper.swift | 40 + .../Sources/UIButton+Kingfisher.swift | 399 + Pods/Manifest.lock | 30 + Pods/Pods.xcodeproj/project.pbxproj | 10766 ++++++++++++++++ Pods/RxBlocking/LICENSE.md | 9 + Pods/RxBlocking/README.md | 198 + .../BlockingObservable+Operators.swift | 253 + .../RxBlocking/BlockingObservable.swift | 25 + .../ObservableConvertibleType+Blocking.swift | 25 + Pods/RxBlocking/RxBlocking/RunLoopLock.swift | 88 + Pods/RxCocoa/LICENSE.md | 9 + Pods/RxCocoa/README.md | 198 + .../Common/CocoaUnits/ControlEvent.swift | 86 + .../Common/CocoaUnits/ControlProperty.swift | 110 + .../Driver/ControlEvent+Driver.swift | 30 + .../Driver/ControlProperty+Driver.swift | 30 + .../Driver/Driver+Subscription.swift | 116 + .../Common/CocoaUnits/Driver/Driver.swift | 83 + .../ObservableConvertibleType+Driver.swift | 63 + .../CocoaUnits/Driver/Variable+Driver.swift | 26 + ...rvableConvertibleType+SharedSequence.swift | 63 + .../SharedSequence+Operators+arity.swift | 365 + .../SharedSequence+Operators.swift | 579 + .../SharedSequence/SharedSequence.swift | 202 + .../Variable+SharedSequence.swift | 26 + .../Common/CocoaUnits/UIBindingObserver.swift | 62 + .../RxCocoa/Common/DelegateProxy.swift | 273 + .../RxCocoa/Common/DelegateProxyType.swift | 280 + .../KVORepresentable+CoreGraphics.swift | 71 + .../Common/KVORepresentable+Swift.swift | 104 + .../RxCocoa/Common/KVORepresentable.swift | 38 + Pods/RxCocoa/RxCocoa/Common/Logging.swift | 27 + .../Common/NSLayoutConstraint+Rx.swift | 43 + .../RxCocoa/Common/Observable+Bind.swift | 107 + .../Implementations/ControlTarget.swift | 92 + .../Observables/NSNotificationCenter+Rx.swift | 34 + .../NSObject+Rx+KVORepresentable.swift | 45 + .../NSObject+Rx+RawRepresentable.swift | 51 + .../Common/Observables/NSObject+Rx.swift | 519 + .../Common/Observables/NSURLSession+Rx.swift | 238 + Pods/RxCocoa/RxCocoa/Common/RxCocoa.swift | 345 + Pods/RxCocoa/RxCocoa/Common/RxTarget.swift | 44 + .../Common/SectionedViewDataSourceType.swift | 39 + Pods/RxCocoa/RxCocoa/Common/TextInput.swift | 152 + Pods/RxCocoa/RxCocoa/Common/_RX.h | 139 + Pods/RxCocoa/RxCocoa/Common/_RX.m | 10 + .../RxCocoa/RxCocoa/Common/_RXDelegateProxy.h | 26 + .../RxCocoa/RxCocoa/Common/_RXDelegateProxy.m | 153 + Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.h | 28 + Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.m | 54 + Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.h | 128 + Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.m | 1039 ++ Pods/RxCocoa/RxCocoa/RxCocoa.h | 19 + ...ollectionViewReactiveArrayDataSource.swift | 108 + .../RxTableViewReactiveArrayDataSource.swift | 104 + .../RxCocoa/iOS/Events/ItemEvents.swift | 16 + .../RxCocoa/iOS/NSTextStorage+Rx.swift | 43 + .../RxCollectionViewDataSourceType.swift | 36 + .../Protocols/RxTableViewDataSourceType.swift | 36 + .../RxCollectionViewDataSourceProxy.swift | 120 + .../RxCollectionViewDelegateProxy.swift | 41 + .../Proxies/RxPickerViewDelegateProxy.swift | 38 + .../Proxies/RxScrollViewDelegateProxy.swift | 101 + .../Proxies/RxSearchBarDelegateProxy.swift | 56 + .../RxSearchControllerDelegateProxy.swift | 44 + .../iOS/Proxies/RxTabBarDelegateProxy.swift | 52 + .../Proxies/RxTableViewDataSourceProxy.swift | 218 + .../Proxies/RxTableViewDelegateProxy.swift | 42 + .../Proxies/RxTextStorageDelegateProxy.swift | 41 + .../iOS/Proxies/RxTextViewDelegateProxy.swift | 56 + .../iOS/UIActivityIndicatorView+Rx.swift | 33 + .../RxCocoa/iOS/UIAlertAction+Rx.swift | 33 + .../RxCocoa/iOS/UIApplication+Rx.swift | 30 + .../RxCocoa/iOS/UIBarButtonItem+Rx.swift | 86 + Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift | 68 + .../RxCocoa/iOS/UICollectionView+Rx.swift | 450 + Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift | 92 + .../RxCocoa/RxCocoa/iOS/UIDatePicker+Rx.swift | 35 + .../RxCocoa/iOS/UIGestureRecognizer+Rx.swift | 81 + Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift | 74 + Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift | 39 + .../RxCocoa/iOS/UINavigationItem+Rx.swift | 29 + .../RxCocoa/iOS/UIPageControl+Rx.swift | 29 + .../RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift | 36 + .../RxCocoa/iOS/UIProgressView+Rx.swift | 30 + .../RxCocoa/iOS/UIRefreshControl+Rx.swift | 33 + .../RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift | 78 + Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift | 155 + .../RxCocoa/iOS/UISearchController+Rx.swift | 71 + .../RxCocoa/iOS/UISegmentedControl+Rx.swift | 35 + Pods/RxCocoa/RxCocoa/iOS/UISlider+Rx.swift | 35 + Pods/RxCocoa/RxCocoa/iOS/UIStepper+Rx.swift | 36 + Pods/RxCocoa/RxCocoa/iOS/UISwitch+Rx.swift | 40 + Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift | 119 + .../RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift | 30 + Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift | 543 + Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift | 40 + Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift | 111 + Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift | 37 + .../RxCocoa/iOS/UIViewController+Rx.swift | 29 + Pods/RxSwift/LICENSE.md | 9 + Pods/RxSwift/README.md | 198 + Pods/RxSwift/RxSwift/AnyObserver.swift | 75 + Pods/RxSwift/RxSwift/Cancelable.swift | 28 + .../RxSwift/Concurrency/AsyncLock.swift | 104 + Pods/RxSwift/RxSwift/Concurrency/Lock.swift | 107 + .../RxSwift/Concurrency/LockOwnerType.swift | 23 + .../Concurrency/SynchronizedDisposeType.swift | 20 + .../Concurrency/SynchronizedOnType.swift | 20 + .../SynchronizedSubscribeType.swift | 20 + .../SynchronizedUnsubscribeType.swift | 15 + .../RxSwift/ConnectableObservableType.swift | 21 + Pods/RxSwift/RxSwift/DataStructures/Bag.swift | 336 + .../DataStructures/InfiniteSequence.swift | 30 + .../DataStructures/PriorityQueue.swift | 120 + .../RxSwift/DataStructures/Queue.swift | 168 + Pods/RxSwift/RxSwift/Disposable.swift | 15 + .../Disposables/AnonymousDisposable.swift | 74 + .../Disposables/BinaryDisposable.swift | 65 + .../Disposables/BooleanDisposable.swift | 45 + .../Disposables/CompositeDisposable.swift | 157 + .../RxSwift/Disposables/Disposables.swift | 61 + .../RxSwift/Disposables/DisposeBag.swift | 104 + .../RxSwift/Disposables/DisposeBase.swift | 26 + .../RxSwift/Disposables/NopDisposable.swift | 33 + .../Disposables/RefCountDisposable.swift | 127 + .../Disposables/ScheduledDisposable.swift | 58 + .../Disposables/SerialDisposable.swift | 85 + .../SingleAssignmentDisposable.swift | 86 + .../StableCompositeDisposable.swift | 16 + .../Disposables/SubscriptionDisposable.swift | 23 + Pods/RxSwift/RxSwift/Errors.swift | 72 + Pods/RxSwift/RxSwift/Event.swift | 66 + .../RxSwift/Extensions/String+Rx.swift | 26 + .../RxSwift/ImmediateSchedulerType.swift | 40 + Pods/RxSwift/RxSwift/Observable.swift | 52 + .../RxSwift/ObservableConvertibleType.swift | 26 + .../RxSwift/ObservableType+Extensions.swift | 179 + Pods/RxSwift/RxSwift/ObservableType.swift | 60 + .../Observables/Implementations/AddRef.swift | 47 + .../Observables/Implementations/Amb.swift | 122 + .../Implementations/AnonymousObservable.swift | 56 + .../Observables/Implementations/Buffer.swift | 121 + .../Observables/Implementations/Catch.swift | 162 + .../CombineLatest+CollectionType.swift | 127 + .../Implementations/CombineLatest+arity.swift | 726 ++ .../Implementations/CombineLatest.swift | 134 + .../Observables/Implementations/Concat.swift | 63 + .../ConnectableObservable.swift | 96 + .../Observables/Implementations/Debug.swift | 81 + .../Observables/Implementations/Debunce.swift | 104 + .../Implementations/Deferred.swift | 61 + .../Observables/Implementations/Delay.swift | 164 + .../Implementations/DelaySubscription.swift | 52 + .../DistinctUntilChanged.swift | 70 + .../Observables/Implementations/Do.swift | 63 + .../Implementations/ElementAt.swift | 79 + .../Observables/Implementations/Empty.swift | 16 + .../Observables/Implementations/Error.swift | 22 + .../Observables/Implementations/Filter.swift | 58 + .../Implementations/Generate.swift | 71 + .../Observables/Implementations/Just.swift | 61 + .../Observables/Implementations/Map.swift | 140 + .../Observables/Implementations/Merge.swift | 424 + .../Implementations/Multicast.swift | 71 + .../Observables/Implementations/Never.swift | 15 + .../Implementations/ObserveOn.swift | 129 + .../ObserveOnSerialDispatchQueue.swift | 82 + .../Implementations/Producer.swift | 99 + .../Observables/Implementations/Range.swift | 59 + .../Observables/Implementations/Reduce.swift | 74 + .../Implementations/RefCount.swift | 84 + .../Observables/Implementations/Repeat.swift | 44 + .../Implementations/RetryWhen.swift | 150 + .../Observables/Implementations/Sample.swift | 129 + .../Observables/Implementations/Scan.swift | 64 + .../Implementations/Sequence.swift | 49 + .../Implementations/ShareReplay1.swift | 101 + .../ShareReplay1WhileConnected.swift | 92 + .../Implementations/SingleAsync.swift | 76 + .../Observables/Implementations/Sink.swift | 66 + .../Observables/Implementations/Skip.swift | 128 + .../Implementations/SkipUntil.swift | 125 + .../Implementations/SkipWhile.swift | 115 + .../Implementations/StartWith.swift | 28 + .../Implementations/SubscribeOn.swift | 62 + .../Observables/Implementations/Switch.swift | 193 + .../Observables/Implementations/Take.swift | 144 + .../Implementations/TakeLast.swift | 63 + .../Implementations/TakeUntil.swift | 120 + .../Implementations/TakeWhile.swift | 132 + .../Implementations/Throttle.swift | 143 + .../Observables/Implementations/Timeout.swift | 122 + .../Observables/Implementations/Timer.swift | 72 + .../Observables/Implementations/ToArray.swift | 50 + .../Observables/Implementations/Using.swift | 78 + .../Observables/Implementations/Window.swift | 154 + .../Implementations/WithLatestFrom.swift | 122 + .../Implementations/Zip+CollectionType.swift | 139 + .../Implementations/Zip+arity.swift | 831 ++ .../Observables/Implementations/Zip.swift | 157 + .../Observables/Observable+Aggregate.swift | 64 + .../Observables/Observable+Binding.swift | 190 + .../Observables/Observable+Concurrency.swift | 62 + .../Observables/Observable+Creation.swift | 237 + .../Observables/Observable+Debug.swift | 28 + .../Observables/Observable+Multiple.swift | 440 + .../Observables/Observable+Single.swift | 294 + ...Observable+StandardSequenceOperators.swift | 323 + .../RxSwift/Observables/Observable+Time.swift | 293 + Pods/RxSwift/RxSwift/ObserverType.swift | 56 + .../RxSwift/Observers/AnonymousObserver.swift | 34 + .../RxSwift/Observers/ObserverBase.swift | 39 + .../RxSwift/Observers/TailRecursiveSink.swift | 152 + .../RxSwift/Platform/Platform.Darwin.swift | 46 + .../RxSwift/Platform/Platform.Linux.swift | 222 + Pods/RxSwift/RxSwift/Reactive.swift | 78 + Pods/RxSwift/RxSwift/Rx.swift | 42 + Pods/RxSwift/RxSwift/RxMutableBox.swift | 37 + Pods/RxSwift/RxSwift/SchedulerType.swift | 78 + .../ConcurrentDispatchQueueScheduler.swift | 87 + .../Schedulers/ConcurrentMainScheduler.swift | 90 + .../Schedulers/CurrentThreadScheduler.swift | 150 + .../DispatchQueueSchedulerQOS.swift | 54 + .../Schedulers/HistoricalScheduler.swift | 25 + .../HistoricalSchedulerTimeConverter.swift | 83 + .../Schedulers/ImmediateScheduler.swift | 39 + .../Internal/AnonymousInvocable.swift | 21 + .../Internal/DispatchQueueConfiguration.swift | 103 + .../Internal/InvocableScheduledItem.swift | 24 + .../Schedulers/Internal/InvocableType.swift | 19 + .../Schedulers/Internal/ScheduledItem.swift | 37 + .../Internal/ScheduledItemType.swift | 15 + .../RxSwift/Schedulers/MainScheduler.swift | 76 + .../Schedulers/OperationQueueScheduler.swift | 57 + .../Schedulers/RecursiveScheduler.swift | 193 + .../SchedulerServices+Emulation.swift | 63 + .../SerialDispatchQueueScheduler.swift | 124 + .../Schedulers/VirtualTimeConverterType.swift | 115 + .../Schedulers/VirtualTimeScheduler.swift | 292 + .../RxSwift/Subjects/BehaviorSubject.swift | 161 + .../RxSwift/Subjects/PublishSubject.swift | 139 + .../RxSwift/Subjects/ReplaySubject.swift | 263 + .../RxSwift/Subjects/SubjectType.swift | 29 + Pods/RxSwift/RxSwift/Subjects/Variable.swift | 69 + Pods/RxTests/LICENSE.md | 9 + Pods/RxTests/README.md | 198 + Pods/RxTests/RxTests/Any+Equatable.swift | 43 + Pods/RxTests/RxTests/ColdObservable.swift | 45 + Pods/RxTests/RxTests/Event+Equatable.swift | 40 + Pods/RxTests/RxTests/HotObservable.swift | 58 + Pods/RxTests/RxTests/Recorded.swift | 50 + Pods/RxTests/RxTests/RxTests.swift | 15 + .../RxTests/Schedulers/TestScheduler.swift | 161 + .../TestSchedulerVirtualTimeConverter.swift | 98 + Pods/RxTests/RxTests/Subscription.swift | 69 + Pods/RxTests/RxTests/TestableObservable.swift | 44 + Pods/RxTests/RxTests/TestableObserver.swift | 38 + Pods/RxTests/RxTests/XCTest+Rx.swift | 123 + Pods/Target Support Files/JASON/Info.plist | 26 + Pods/Target Support Files/JASON/JASON-dummy.m | 5 + .../JASON/JASON-prefix.pch | 4 + .../JASON/JASON-umbrella.h | 7 + .../JASON/JASON.modulemap | 6 + .../Target Support Files/JASON/JASON.xcconfig | 9 + .../Kingfisher/Info.plist | 26 + .../Kingfisher/Kingfisher-dummy.m | 5 + .../Kingfisher/Kingfisher-prefix.pch | 4 + .../Kingfisher/Kingfisher-umbrella.h | 7 + .../Kingfisher/Kingfisher.modulemap | 6 + .../Kingfisher/Kingfisher.xcconfig | 11 + .../Pods-Protium/Info.plist | 26 + .../Pods-Protium-acknowledgements.markdown | 76 + .../Pods-Protium-acknowledgements.plist | 118 + .../Pods-Protium/Pods-Protium-dummy.m | 5 + .../Pods-Protium/Pods-Protium-frameworks.sh | 97 + .../Pods-Protium/Pods-Protium-resources.sh | 102 + .../Pods-Protium/Pods-Protium-umbrella.h | 6 + .../Pods-Protium/Pods-Protium.debug.xcconfig | 10 + .../Pods-Protium/Pods-Protium.modulemap | 6 + .../Pods-Protium.release.xcconfig | 10 + .../Pods-ProtiumTests/Info.plist | 26 + ...ods-ProtiumTests-acknowledgements.markdown | 39 + .../Pods-ProtiumTests-acknowledgements.plist | 77 + .../Pods-ProtiumTests-dummy.m | 5 + .../Pods-ProtiumTests-frameworks.sh | 95 + .../Pods-ProtiumTests-resources.sh | 102 + .../Pods-ProtiumTests-umbrella.h | 6 + .../Pods-ProtiumTests.debug.xcconfig | 10 + .../Pods-ProtiumTests.modulemap | 6 + .../Pods-ProtiumTests.release.xcconfig | 10 + .../Pods-ProtiumUITests/Info.plist | 26 + ...s-ProtiumUITests-acknowledgements.markdown | 3 + ...Pods-ProtiumUITests-acknowledgements.plist | 29 + .../Pods-ProtiumUITests-dummy.m | 5 + .../Pods-ProtiumUITests-frameworks.sh | 84 + .../Pods-ProtiumUITests-resources.sh | 102 + .../Pods-ProtiumUITests-umbrella.h | 6 + .../Pods-ProtiumUITests.debug.xcconfig | 7 + .../Pods-ProtiumUITests.modulemap | 6 + .../Pods-ProtiumUITests.release.xcconfig | 7 + .../RxBlocking/Info.plist | 26 + .../RxBlocking/RxBlocking-dummy.m | 5 + .../RxBlocking/RxBlocking-prefix.pch | 4 + .../RxBlocking/RxBlocking-umbrella.h | 6 + .../RxBlocking/RxBlocking.modulemap | 6 + .../RxBlocking/RxBlocking.xcconfig | 10 + Pods/Target Support Files/RxCocoa/Info.plist | 26 + .../RxCocoa/RxCocoa-dummy.m | 5 + .../RxCocoa/RxCocoa-prefix.pch | 4 + .../RxCocoa/RxCocoa-umbrella.h | 11 + .../RxCocoa/RxCocoa.modulemap | 6 + .../RxCocoa/RxCocoa.xcconfig | 10 + Pods/Target Support Files/RxSwift/Info.plist | 26 + .../RxSwift/RxSwift-dummy.m | 5 + .../RxSwift/RxSwift-prefix.pch | 4 + .../RxSwift/RxSwift-umbrella.h | 6 + .../RxSwift/RxSwift.modulemap | 6 + .../RxSwift/RxSwift.xcconfig | 9 + Pods/Target Support Files/RxTests/Info.plist | 26 + .../RxTests/RxTests-dummy.m | 5 + .../RxTests/RxTests-prefix.pch | 4 + .../RxTests/RxTests-umbrella.h | 6 + .../RxTests/RxTests.modulemap | 6 + .../RxTests/RxTests.xcconfig | 12 + Protium.xcodeproj/project.pbxproj | 855 ++ .../contents.xcworkspacedata | 7 + Protium.xcworkspace/contents.xcworkspacedata | 10 + .../AppIcon.appiconset/Contents.json | 98 + .../AppIcon.appiconset/Icon-60@2x.png | Bin 0 -> 4268 bytes .../AppIcon.appiconset/Icon-60@3x.png | Bin 0 -> 7270 bytes .../AppIcon.appiconset/Icon-76.png | Bin 0 -> 2376 bytes .../AppIcon.appiconset/Icon-76@2x.png | Bin 0 -> 5765 bytes .../AppIcon.appiconset/Icon-83.5@2x.png | Bin 0 -> 11793 bytes Protium/Assets.xcassets/Contents.json | 6 + .../iconLink.imageset/Contents.json | 12 + .../iconLink.imageset/link.pdf | Bin 0 -> 6666 bytes .../iconOpen.imageset/Contents.json | 12 + .../iconOpen.imageset/open.pdf | Bin 0 -> 6424 bytes .../protiumLogo.imageset/Contents.json | 12 + .../protiumLogo.imageset/protiumLogo.pdf | Bin 0 -> 8868 bytes Protium/Base.lproj/LaunchScreen.storyboard | 42 + Protium/Base.lproj/Localizable.strings | 3 + Protium/Info.plist | 47 + Protium/src/base/Context.swift | 5 + Protium/src/base/InteractableUI.swift | 35 + Protium/src/base/NavigationContext.swift | 39 + Protium/src/base/NibLoadableView.swift | 9 + Protium/src/base/ReusableView.swift | 9 + Protium/src/base/StringExtensions.swift | 7 + Protium/src/base/Theme.swift | 15 + .../src/base/UICollectionViewExtensions.swift | 16 + Protium/src/base/WindowContext.swift | 28 + Protium/src/gifs/Gif.swift | 28 + Protium/src/gifs/GifCell.swift | 17 + Protium/src/gifs/GifCell.xib | 31 + Protium/src/gifs/GifDetails.storyboard | 81 + Protium/src/gifs/GifDetailsInteractor.swift | 25 + Protium/src/gifs/GifDetailsScene.swift | 31 + Protium/src/gifs/GifDetailsUI.swift | 74 + Protium/src/gifs/GifGateway.swift | 63 + Protium/src/gifs/GifPM.swift | 19 + .../src/gifs/GifPlayerViewController.swift | 40 + Protium/src/gifs/GifSearch.storyboard | 67 + Protium/src/gifs/GifSearchInteractor.swift | 58 + Protium/src/gifs/GifSearchScene.swift | 28 + Protium/src/gifs/GifSearchUI.swift | 74 + Protium/src/main/AppDelegate.swift | 41 + Protium/src/main/MainScene.swift | 15 + ProtiumTests/Info.plist | 22 + ProtiumTests/ProtiumTests.swift | 36 + ProtiumUITests/Info.plist | 22 + ProtiumUITests/ProtiumUITests.swift | 36 + README.md | 1 + 407 files changed, 48057 insertions(+) create mode 100755 .gitignore create mode 100644 Podfile create mode 100644 Podfile.lock create mode 100644 Pods/JASON/LICENSE create mode 100644 Pods/JASON/README.md create mode 100644 Pods/JASON/Source/JSON.swift create mode 100644 Pods/JASON/Source/JSONKey.swift create mode 100644 Pods/JASON/Source/LiteralConvertible.swift create mode 100644 Pods/JASON/Source/Properties.swift create mode 100644 Pods/JASON/Source/SequenceType.swift create mode 100644 Pods/JASON/Source/Supporting Files/JASON.h create mode 100644 Pods/JASON/Source/Supporting Files/Utilities.swift create mode 100644 Pods/Kingfisher/LICENSE create mode 100644 Pods/Kingfisher/README.md create mode 100755 Pods/Kingfisher/Sources/AnimatedImageView.swift create mode 100644 Pods/Kingfisher/Sources/Box.swift create mode 100644 Pods/Kingfisher/Sources/CacheSerializer.swift create mode 100644 Pods/Kingfisher/Sources/Filter.swift create mode 100755 Pods/Kingfisher/Sources/Image.swift create mode 100755 Pods/Kingfisher/Sources/ImageCache.swift create mode 100755 Pods/Kingfisher/Sources/ImageDownloader.swift create mode 100755 Pods/Kingfisher/Sources/ImagePrefetcher.swift create mode 100644 Pods/Kingfisher/Sources/ImageProcessor.swift create mode 100755 Pods/Kingfisher/Sources/ImageTransition.swift create mode 100755 Pods/Kingfisher/Sources/ImageView+Kingfisher.swift create mode 100644 Pods/Kingfisher/Sources/Indicator.swift create mode 100644 Pods/Kingfisher/Sources/Kingfisher.h create mode 100644 Pods/Kingfisher/Sources/Kingfisher.swift create mode 100755 Pods/Kingfisher/Sources/KingfisherManager.swift create mode 100755 Pods/Kingfisher/Sources/KingfisherOptionsInfo.swift create mode 100644 Pods/Kingfisher/Sources/RequrstModifier.swift create mode 100755 Pods/Kingfisher/Sources/Resource.swift create mode 100755 Pods/Kingfisher/Sources/String+MD5.swift create mode 100755 Pods/Kingfisher/Sources/ThreadHelper.swift create mode 100755 Pods/Kingfisher/Sources/UIButton+Kingfisher.swift create mode 100644 Pods/Manifest.lock create mode 100644 Pods/Pods.xcodeproj/project.pbxproj create mode 100644 Pods/RxBlocking/LICENSE.md create mode 100644 Pods/RxBlocking/README.md create mode 100644 Pods/RxBlocking/RxBlocking/BlockingObservable+Operators.swift create mode 100644 Pods/RxBlocking/RxBlocking/BlockingObservable.swift create mode 100644 Pods/RxBlocking/RxBlocking/ObservableConvertibleType+Blocking.swift create mode 100644 Pods/RxBlocking/RxBlocking/RunLoopLock.swift create mode 100644 Pods/RxCocoa/LICENSE.md create mode 100644 Pods/RxCocoa/README.md create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/ControlEvent.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/ControlProperty.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ControlEvent+Driver.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ControlProperty+Driver.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Driver.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Variable+Driver.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/ObservableConvertibleType+SharedSequence.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators+arity.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/Variable+SharedSequence.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/CocoaUnits/UIBindingObserver.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/DelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/DelegateProxyType.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/KVORepresentable+CoreGraphics.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/KVORepresentable+Swift.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/KVORepresentable.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/Logging.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/Observable+Bind.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/Observables/Implementations/ControlTarget.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx+KVORepresentable.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx+RawRepresentable.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/Observables/NSURLSession+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/RxCocoa.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/RxTarget.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/SectionedViewDataSourceType.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/TextInput.swift create mode 100644 Pods/RxCocoa/RxCocoa/Common/_RX.h create mode 100644 Pods/RxCocoa/RxCocoa/Common/_RX.m create mode 100644 Pods/RxCocoa/RxCocoa/Common/_RXDelegateProxy.h create mode 100644 Pods/RxCocoa/RxCocoa/Common/_RXDelegateProxy.m create mode 100644 Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.h create mode 100644 Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.m create mode 100644 Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.h create mode 100644 Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.m create mode 100644 Pods/RxCocoa/RxCocoa/RxCocoa.h create mode 100644 Pods/RxCocoa/RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Events/ItemEvents.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIBarButtonItem+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UICollectionView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIDatePicker+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIGestureRecognizer+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UISegmentedControl+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UISlider+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIStepper+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UISwitch+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift create mode 100644 Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift create mode 100644 Pods/RxSwift/LICENSE.md create mode 100644 Pods/RxSwift/README.md create mode 100644 Pods/RxSwift/RxSwift/AnyObserver.swift create mode 100644 Pods/RxSwift/RxSwift/Cancelable.swift create mode 100644 Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift create mode 100644 Pods/RxSwift/RxSwift/Concurrency/Lock.swift create mode 100644 Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift create mode 100644 Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift create mode 100644 Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift create mode 100644 Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift create mode 100644 Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift create mode 100644 Pods/RxSwift/RxSwift/ConnectableObservableType.swift create mode 100644 Pods/RxSwift/RxSwift/DataStructures/Bag.swift create mode 100644 Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift create mode 100644 Pods/RxSwift/RxSwift/DataStructures/PriorityQueue.swift create mode 100644 Pods/RxSwift/RxSwift/DataStructures/Queue.swift create mode 100644 Pods/RxSwift/RxSwift/Disposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/Disposables.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift create mode 100644 Pods/RxSwift/RxSwift/Errors.swift create mode 100644 Pods/RxSwift/RxSwift/Event.swift create mode 100644 Pods/RxSwift/RxSwift/Extensions/String+Rx.swift create mode 100644 Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift create mode 100644 Pods/RxSwift/RxSwift/Observable.swift create mode 100644 Pods/RxSwift/RxSwift/ObservableConvertibleType.swift create mode 100644 Pods/RxSwift/RxSwift/ObservableType+Extensions.swift create mode 100644 Pods/RxSwift/RxSwift/ObservableType.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Debunce.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Zip+CollectionType.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+Single.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift create mode 100644 Pods/RxSwift/RxSwift/Observables/Observable+Time.swift create mode 100644 Pods/RxSwift/RxSwift/ObserverType.swift create mode 100644 Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift create mode 100644 Pods/RxSwift/RxSwift/Observers/ObserverBase.swift create mode 100644 Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift create mode 100644 Pods/RxSwift/RxSwift/Platform/Platform.Darwin.swift create mode 100644 Pods/RxSwift/RxSwift/Platform/Platform.Linux.swift create mode 100644 Pods/RxSwift/RxSwift/Reactive.swift create mode 100644 Pods/RxSwift/RxSwift/Rx.swift create mode 100644 Pods/RxSwift/RxSwift/RxMutableBox.swift create mode 100644 Pods/RxSwift/RxSwift/SchedulerType.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift create mode 100644 Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift create mode 100644 Pods/RxSwift/RxSwift/Subjects/BehaviorSubject.swift create mode 100644 Pods/RxSwift/RxSwift/Subjects/PublishSubject.swift create mode 100644 Pods/RxSwift/RxSwift/Subjects/ReplaySubject.swift create mode 100644 Pods/RxSwift/RxSwift/Subjects/SubjectType.swift create mode 100644 Pods/RxSwift/RxSwift/Subjects/Variable.swift create mode 100644 Pods/RxTests/LICENSE.md create mode 100644 Pods/RxTests/README.md create mode 100644 Pods/RxTests/RxTests/Any+Equatable.swift create mode 100644 Pods/RxTests/RxTests/ColdObservable.swift create mode 100644 Pods/RxTests/RxTests/Event+Equatable.swift create mode 100644 Pods/RxTests/RxTests/HotObservable.swift create mode 100644 Pods/RxTests/RxTests/Recorded.swift create mode 100644 Pods/RxTests/RxTests/RxTests.swift create mode 100644 Pods/RxTests/RxTests/Schedulers/TestScheduler.swift create mode 100644 Pods/RxTests/RxTests/Schedulers/TestSchedulerVirtualTimeConverter.swift create mode 100644 Pods/RxTests/RxTests/Subscription.swift create mode 100644 Pods/RxTests/RxTests/TestableObservable.swift create mode 100644 Pods/RxTests/RxTests/TestableObserver.swift create mode 100644 Pods/RxTests/RxTests/XCTest+Rx.swift create mode 100644 Pods/Target Support Files/JASON/Info.plist create mode 100644 Pods/Target Support Files/JASON/JASON-dummy.m create mode 100644 Pods/Target Support Files/JASON/JASON-prefix.pch create mode 100644 Pods/Target Support Files/JASON/JASON-umbrella.h create mode 100644 Pods/Target Support Files/JASON/JASON.modulemap create mode 100644 Pods/Target Support Files/JASON/JASON.xcconfig create mode 100644 Pods/Target Support Files/Kingfisher/Info.plist create mode 100644 Pods/Target Support Files/Kingfisher/Kingfisher-dummy.m create mode 100644 Pods/Target Support Files/Kingfisher/Kingfisher-prefix.pch create mode 100644 Pods/Target Support Files/Kingfisher/Kingfisher-umbrella.h create mode 100644 Pods/Target Support Files/Kingfisher/Kingfisher.modulemap create mode 100644 Pods/Target Support Files/Kingfisher/Kingfisher.xcconfig create mode 100644 Pods/Target Support Files/Pods-Protium/Info.plist create mode 100644 Pods/Target Support Files/Pods-Protium/Pods-Protium-acknowledgements.markdown create mode 100644 Pods/Target Support Files/Pods-Protium/Pods-Protium-acknowledgements.plist create mode 100644 Pods/Target Support Files/Pods-Protium/Pods-Protium-dummy.m create mode 100755 Pods/Target Support Files/Pods-Protium/Pods-Protium-frameworks.sh create mode 100755 Pods/Target Support Files/Pods-Protium/Pods-Protium-resources.sh create mode 100644 Pods/Target Support Files/Pods-Protium/Pods-Protium-umbrella.h create mode 100644 Pods/Target Support Files/Pods-Protium/Pods-Protium.debug.xcconfig create mode 100644 Pods/Target Support Files/Pods-Protium/Pods-Protium.modulemap create mode 100644 Pods/Target Support Files/Pods-Protium/Pods-Protium.release.xcconfig create mode 100644 Pods/Target Support Files/Pods-ProtiumTests/Info.plist create mode 100644 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests-acknowledgements.markdown create mode 100644 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests-acknowledgements.plist create mode 100644 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests-dummy.m create mode 100755 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests-frameworks.sh create mode 100755 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests-resources.sh create mode 100644 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests-umbrella.h create mode 100644 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests.debug.xcconfig create mode 100644 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests.modulemap create mode 100644 Pods/Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests.release.xcconfig create mode 100644 Pods/Target Support Files/Pods-ProtiumUITests/Info.plist create mode 100644 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests-acknowledgements.markdown create mode 100644 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests-acknowledgements.plist create mode 100644 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests-dummy.m create mode 100755 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests-frameworks.sh create mode 100755 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests-resources.sh create mode 100644 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests-umbrella.h create mode 100644 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests.debug.xcconfig create mode 100644 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests.modulemap create mode 100644 Pods/Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests.release.xcconfig create mode 100644 Pods/Target Support Files/RxBlocking/Info.plist create mode 100644 Pods/Target Support Files/RxBlocking/RxBlocking-dummy.m create mode 100644 Pods/Target Support Files/RxBlocking/RxBlocking-prefix.pch create mode 100644 Pods/Target Support Files/RxBlocking/RxBlocking-umbrella.h create mode 100644 Pods/Target Support Files/RxBlocking/RxBlocking.modulemap create mode 100644 Pods/Target Support Files/RxBlocking/RxBlocking.xcconfig create mode 100644 Pods/Target Support Files/RxCocoa/Info.plist create mode 100644 Pods/Target Support Files/RxCocoa/RxCocoa-dummy.m create mode 100644 Pods/Target Support Files/RxCocoa/RxCocoa-prefix.pch create mode 100644 Pods/Target Support Files/RxCocoa/RxCocoa-umbrella.h create mode 100644 Pods/Target Support Files/RxCocoa/RxCocoa.modulemap create mode 100644 Pods/Target Support Files/RxCocoa/RxCocoa.xcconfig create mode 100644 Pods/Target Support Files/RxSwift/Info.plist create mode 100644 Pods/Target Support Files/RxSwift/RxSwift-dummy.m create mode 100644 Pods/Target Support Files/RxSwift/RxSwift-prefix.pch create mode 100644 Pods/Target Support Files/RxSwift/RxSwift-umbrella.h create mode 100644 Pods/Target Support Files/RxSwift/RxSwift.modulemap create mode 100644 Pods/Target Support Files/RxSwift/RxSwift.xcconfig create mode 100644 Pods/Target Support Files/RxTests/Info.plist create mode 100644 Pods/Target Support Files/RxTests/RxTests-dummy.m create mode 100644 Pods/Target Support Files/RxTests/RxTests-prefix.pch create mode 100644 Pods/Target Support Files/RxTests/RxTests-umbrella.h create mode 100644 Pods/Target Support Files/RxTests/RxTests.modulemap create mode 100644 Pods/Target Support Files/RxTests/RxTests.xcconfig create mode 100644 Protium.xcodeproj/project.pbxproj create mode 100644 Protium.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Protium.xcworkspace/contents.xcworkspacedata create mode 100644 Protium/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Protium/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png create mode 100644 Protium/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png create mode 100644 Protium/Assets.xcassets/AppIcon.appiconset/Icon-76.png create mode 100644 Protium/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png create mode 100644 Protium/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png create mode 100644 Protium/Assets.xcassets/Contents.json create mode 100644 Protium/Assets.xcassets/iconLink.imageset/Contents.json create mode 100644 Protium/Assets.xcassets/iconLink.imageset/link.pdf create mode 100644 Protium/Assets.xcassets/iconOpen.imageset/Contents.json create mode 100644 Protium/Assets.xcassets/iconOpen.imageset/open.pdf create mode 100644 Protium/Assets.xcassets/protiumLogo.imageset/Contents.json create mode 100644 Protium/Assets.xcassets/protiumLogo.imageset/protiumLogo.pdf create mode 100644 Protium/Base.lproj/LaunchScreen.storyboard create mode 100644 Protium/Base.lproj/Localizable.strings create mode 100644 Protium/Info.plist create mode 100644 Protium/src/base/Context.swift create mode 100644 Protium/src/base/InteractableUI.swift create mode 100644 Protium/src/base/NavigationContext.swift create mode 100644 Protium/src/base/NibLoadableView.swift create mode 100644 Protium/src/base/ReusableView.swift create mode 100644 Protium/src/base/StringExtensions.swift create mode 100644 Protium/src/base/Theme.swift create mode 100644 Protium/src/base/UICollectionViewExtensions.swift create mode 100644 Protium/src/base/WindowContext.swift create mode 100644 Protium/src/gifs/Gif.swift create mode 100644 Protium/src/gifs/GifCell.swift create mode 100644 Protium/src/gifs/GifCell.xib create mode 100644 Protium/src/gifs/GifDetails.storyboard create mode 100644 Protium/src/gifs/GifDetailsInteractor.swift create mode 100644 Protium/src/gifs/GifDetailsScene.swift create mode 100644 Protium/src/gifs/GifDetailsUI.swift create mode 100644 Protium/src/gifs/GifGateway.swift create mode 100644 Protium/src/gifs/GifPM.swift create mode 100644 Protium/src/gifs/GifPlayerViewController.swift create mode 100644 Protium/src/gifs/GifSearch.storyboard create mode 100644 Protium/src/gifs/GifSearchInteractor.swift create mode 100644 Protium/src/gifs/GifSearchScene.swift create mode 100644 Protium/src/gifs/GifSearchUI.swift create mode 100644 Protium/src/main/AppDelegate.swift create mode 100644 Protium/src/main/MainScene.swift create mode 100644 ProtiumTests/Info.plist create mode 100644 ProtiumTests/ProtiumTests.swift create mode 100644 ProtiumUITests/Info.plist create mode 100644 ProtiumUITests/ProtiumUITests.swift create mode 100755 README.md diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..1c191f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,68 @@ +# MacOS +.DS_Store + +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xcuserstate + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output diff --git a/Podfile b/Podfile new file mode 100644 index 0000000..50fd342 --- /dev/null +++ b/Podfile @@ -0,0 +1,29 @@ +platform :ios, "9.0" + +target "Protium" do + use_frameworks! + + pod "RxSwift", "3.0.0-beta.2" + pod "RxCocoa", "3.0.0-beta.2" + pod "JASON", "3.0" + pod "Kingfisher", "3.1.1" + + target "ProtiumTests" do + inherit! :search_paths + pod "RxBlocking", "3.0.0-beta.2" + pod "RxTests", "3.0.0-beta.2" + end + + target "ProtiumUITests" do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings["SWIFT_VERSION"] = "3.0" + config.build_settings["MACOSX_DEPLOYMENT_TARGET"] = "10.10" + end + end +end diff --git a/Podfile.lock b/Podfile.lock new file mode 100644 index 0000000..3a3752d --- /dev/null +++ b/Podfile.lock @@ -0,0 +1,30 @@ +PODS: + - JASON (3.0) + - Kingfisher (3.1.1) + - RxBlocking (3.0.0-beta.2): + - RxSwift (~> 3.0.0-beta.2) + - RxCocoa (3.0.0-beta.2): + - RxSwift (~> 3.0.0-beta.2) + - RxSwift (3.0.0-beta.2) + - RxTests (3.0.0-beta.2): + - RxSwift (~> 3.0.0-beta.2) + +DEPENDENCIES: + - JASON + - Kingfisher (= 3.1.1) + - RxBlocking (= 3.0.0-beta.2) + - RxCocoa (= 3.0.0-beta.2) + - RxSwift (= 3.0.0-beta.2) + - RxTests (= 3.0.0-beta.2) + +SPEC CHECKSUMS: + JASON: cf4d762e61428a20db8eaef2acb6a569a10c1801 + Kingfisher: 12b755ae697cc9f0fd3e550db8417fa1233e09ab + RxBlocking: 75dad8ed874b732da94780fdf7cf48eabf0d5d2b + RxCocoa: 1dd105d8a4e18034ccd7bd6d136445363ce67c8e + RxSwift: 0ea939d7d97cb70657190ffde8dc2a9b455778fc + RxTests: 9b696439878a1c7653bb55853af027fc261d0635 + +PODFILE CHECKSUM: 6f0018b65760ac7a8f462654e4fd7e3f3c05aae8 + +COCOAPODS: 1.0.1 diff --git a/Pods/JASON/LICENSE b/Pods/JASON/LICENSE new file mode 100644 index 0000000..c567f8e --- /dev/null +++ b/Pods/JASON/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2015-2016 Damien (http://delba.io) + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/Pods/JASON/README.md b/Pods/JASON/README.md new file mode 100644 index 0000000..ff8f92d --- /dev/null +++ b/Pods/JASON/README.md @@ -0,0 +1,305 @@ +

+ +

+ +

+ Travis Status + CocoaPods compatible + Carthage compatible + Platform +

+ +**JASON** is a [faster](https://github.com/delba/JASON/tree/benchmarks) `JSON` deserializer written in Swift. + +```md +JASON is the best framework we found to manage JSON at Swapcard. This is by far the fastest and +the most convenient out there, it made our code clearer and improved the global performance +of the app when dealing with large amount of data. +``` +> *[Gautier Gédoux](https://github.com/gautier-gdx), lead iOS developer at [Swapcard](https://www.swapcard.com/)* + +

+FeaturesUsageExampleReferencesInstallationLicense +

+ +## Features + +- [x] Very fast - [`benchmarks`](https://github.com/delba/JASON/tree/benchmarks) +- [x] Fully tested +- [x] Fully documented +

+- [x] Clean code +- [x] Beautiful API +- [x] Regular updates +

+- [x] Support for iOS, OSX, tvOS, watchOS +- [x] Compatible with [Carthage](https://github.com/delba/JASON#carthage) / [CocoaPods](https://github.com/delba/JASON#cocoapods) +- [x] Provide extensions - [`Extensions/`](https://github.com/delba/JASON/tree/master/Extensions) + +## Usage + +#### Initialization + +```swift +let json = JSON(anything) // where `anything` is `AnyObject?` +``` + +If you're using [`Alamofire`](https://github.com/Alamofire/Alamofire), include [`JASON+Alamofire.swift`](https://github.com/delba/JASON/blob/master/Extensions/JASON%2BAlamofire.swift) in your project for even more awesomeness: + +```swift +Alamofire.request(.GET, peopleURL).responseJASON { response in + if let json = response.result.value { + let people = json.map(Person.init) + print("people: \(people)") + } +} +``` + +If you're using [`Moya`](https://github.com/Moya/Moya), check out [`Moya-JASON`](https://github.com/DroidsOnRoids/Moya-JASON)! + +#### Parsing + +Use subscripts to parse the `JSON` object: + +```swift +json["people"][0]["name"] + +// Or with a path: + +json[path: "people", 0, "name"] +``` + +#### Type casting + +Cast `JSON` value to its appropriate type by using the computed property `json.`: + +```swift +let name = json["name"].string // the name as String? +``` + +The non-optional variant `json.Value` will return a default value if not present/convertible: + +```swift +let name = json["wrong"].stringValue // the name will be "" +``` + +You can also access the internal value as `AnyObject?` if you want to cast it yourself: + +```swift +let something = json["something"].object +``` + +*See the [References section](https://github.com/delba/JASON#references) for the full list of properties.* + +#### `JSONKey`: + +> This idea is stolen from [`SwiftyUserDefaults`](https://github.com/radex/SwiftyUserDefaults) by **Radek Pietruszewski** ([GitHub](https://github.com/radex), [Twitter](https://twitter.com/radexp), [Blog](http://radex.io)). +
+> I can't recommend enough to read his article about it! :boom: [Statically-typed NSUserDefaults](http://radex.io/swift/nsuserdefaults/static/) :boom: + +Define and use your `JSONKey` as follow: + +```swift +// With a int key: + +let personKey = JSONKey(0) +let personJSON = peopleJSON[personKey] + +// With a string key: + +let nameKey = JSONKey("name") +let name = personJSON[nameKey] + +// With a path: + +let twitterURLKey = JSONKey(path: 0, "twitter") +let twitterURL = peopleJSON[twitterURLKey] +``` + +You might find more convenient to extend `JSONKeys` as shown in the [Example section](https://github.com/delba/JASON#example). + +*See the [References section](https://github.com/delba/JASON#references) for the full list of `JSONKey` types.* + +#### Third-party libraries: + +- [DroidsOnRoids/**Moya-JASON**](https://github.com/DroidsOnRoids/Moya-JASON) JASON bindings for Moya. + +## Example + +> This example uses the **Dribbble API** ([docs](http://developer.dribbble.com/v1/)). +
+> An example of the server response can be found in [`Tests/Supporting Files/shots.json`](https://github.com/delba/JASON/blob/master/Tests/Supporting%20Files/shots.json) + +- **Step 1:** Extend `JSONKeys` to define your `JSONKey` + +```swift +JSON.dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ" + +extension JSONKeys { + static let id = JSONKey("id") + static let createdAt = JSONKey("created_at") + static let updatedAt = JSONKey("updated_at") + + static let title = JSONKey("title") + + static let normalImageURL = JSONKey(path: "images", "normal") + static let hidpiImageURL = JSONKey(path: "images", "hidpi") + + static let user = JSONKey("user") + static let name = JSONKey("name") +} +``` + +- **Step 2:** Create the `Shot` and `User` models + +```swift +struct Shot { + let id: Int + let title: String + + let normalImageURL: NSURL + var hidpiImageURL: NSURL? + + let createdAt: NSDate + let updatedAt: NSDate + + let user: User + + init(_ json: JSON) { + id = json[.id] + title = json[.title] + + normalImageURL = json[.normalImageURL]! + hidpiImageURL = json[.hidpiImageURL] + + createdAt = json[.createdAt]! + updatedAt = json[.updatedAt]! + + user = User(json[.user]) + } +} +``` + +```swift +struct User { + let id: Int + let name: String + + let createdAt: NSDate + let updatedAt: NSDate + + init(_ json: JSON) { + id = json[.id] + name = json[.name] + + createdAt = json[.createdAt]! + updatedAt = json[.updatedAt]! + } +} +``` + +- **Step 3:** Use the [`JASON+Alamofire.swift`](https://github.com/delba/JASON/blob/master/Extensions/JASON%2BAlamofire.swift) extension to fetch the shots + +```swift +Alamofire.request(.GET, shotsURL).responseJASON { response in + if let json = response.result.value { + let shots = json.map(Shot.init) + } +} +``` + +## References + +> Include [`JASON+Properties.swift`](https://github.com/delba/JASON/blob/master/Extensions/JASON%2BProperties.swift) for even more types! + +Property | JSONKey Type | Default value +--------------------- | ---------------------- | ------------- +`string` | `String?` | +`stringValue` | `String` | `""` +`int` | `Int?` | +`intValue` | `Int` | `0` +`double` | `Double?` | +`doubleValue` | `Double` | `0.0` +`float` | `Float?` | +`floatValue` | `Float` | `0.0` +`nsNumber` | `NSNumber?` | +`nsNumberValue` | `NSNumber` | `0` +`cgFloat` | `CGFloat?` | +`cgFloatValue` | `CGFloat` | `0.0` +`bool` | `Bool?` | +`boolValue` | `Bool` | `false` +`nsDate` | `NSDate?` | +`nsURL` | `NSURL?` | +`dictionary` | `[String: AnyObject]?` | +`dictionaryValue` | `[String: AnyObject]` | `[:]` +`jsonDictionary` | `[String: JSON]?` | +`jsonDictionaryValue` | `[String: JSON]` | `[:]` +`nsDictionary` | `NSDictionary?` | +`nsDictionaryValue` | `NSDictionary` | `NSDictionary()` +`array` | `[AnyObject]?` | +`arrayValue` | `[AnyObject]` | `[]` +`jsonArray` | `[JSON]?` | +`jsonArrayValue` | `[JSON]` | `[]` +`nsArray` | `NSArray?` | +`nsArrayValue` | `NSArray` | `NSArray()` + +> Configure JSON.dateFormatter if needed for `nsDate` parsing + +## Installation + +#### Carthage + +[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application. + +You can install Carthage with [Homebrew](http://brew.sh/) using the following command: + +```bash +$ brew update +$ brew install carthage +``` + +To integrate **`JASON`** into your Xcode project using Carthage, specify it in your `Cartfile`: + +```ogdl +github "delba/JASON" >= 2.2 +``` + +#### CocoaPods + +[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. + +You can install it with the following command: + +```bash +$ gem install cocoapods +``` + +To integrate **`JASON`** into your Xcode project using CocoaPods, specify it in your `Podfile`: + +```ruby +use_frameworks! + +pod 'JASON', '~> 2.2' +``` + +## License + +Copyright (c) 2015-2016 Damien (http://delba.io) + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. diff --git a/Pods/JASON/Source/JSON.swift b/Pods/JASON/Source/JSON.swift new file mode 100644 index 0000000..aab6cf0 --- /dev/null +++ b/Pods/JASON/Source/JSON.swift @@ -0,0 +1,159 @@ +// +// JSON.swift +// +// Copyright (c) 2015-2016 Damien (http://delba.io) +// +// 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: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// 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. +// + +// MARK: - Initializers + +public struct JSON { + /// The date formatter used for date conversions + public static var dateFormatter = DateFormatter() + + /// The object on which any subsequent method operates + public let object: AnyObject? + + /** + Creates an instance of JSON from AnyObject. + + - parameter object: An instance of any class + + - returns: the created JSON + */ + public init(_ object: Any?) { + self.init(object: object) + } + + /** + Creates an instance of JSON from NSData. + + - parameter data: An instance of NSData + + - returns: the created JSON + */ + public init(_ data: Data?) { + self.init(object: JSON.objectWithData(data)) + } + + /** + Creates an instance of JSON from AnyObject. + Takes an explicit parameter name to prevent calls to init(_:) with NSData? when nil is passed. + + - parameter object: An instance of any class + + - returns: the created JSON + */ + internal init(object: Any?) { + self.object = object as AnyObject? + } +} + +// MARK: - Subscript + +extension JSON { + /** + Creates a new instance of JSON. + + - parameter index: A string + + - returns: a new instance of JSON or itself if its object is nil. + */ + public subscript(index: String) -> JSON { + if object == nil { return self } + + if let nsDictionary = nsDictionary { + return JSON(nsDictionary[index]) + } + + return JSON(object: nil) + } + + /** + Creates a new instance of JSON. + + - parameter index: A string + + - returns: a new instance of JSON or itself if its object is nil. + */ + public subscript(index: Int) -> JSON { + if object == nil { return self } + + if let nsArray = nsArray { + return JSON(nsArray[safe: index]) + } + + return JSON(object: nil) + } + + /** + Creates a new instance of JSON. + + - parameter indexes: Any + + - returns: a new instance of JSON or itself if its object is nil + */ + public subscript(path indexes: Any...) -> JSON { + return self[indexes] + } + + internal subscript(indexes: [Any]) -> JSON { + if object == nil { return self } + + var json = self + + for index in indexes { + if let string = index as? String, let object = json.nsDictionary?[string] { + json = JSON(object) + continue + } + + if let int = index as? Int, let object = json.nsArray?[safe: int] { + json = JSON(object) + continue + } + + else { + json = JSON(nil) + break + } + } + + return json + } +} + +// MARK: - Private extensions + +private extension JSON { + /** + Converts an instance of NSData to AnyObject. + + - parameter data: An instance of NSData or nil + + - returns: An instance of AnyObject or nil + */ + static func objectWithData(_ data: Data?) -> Any? { + guard let data = data else { return nil } + + return try? JSONSerialization.jsonObject(with: data, options: []) + } +} + diff --git a/Pods/JASON/Source/JSONKey.swift b/Pods/JASON/Source/JSONKey.swift new file mode 100644 index 0000000..0fd961b --- /dev/null +++ b/Pods/JASON/Source/JSONKey.swift @@ -0,0 +1,436 @@ +// +// JSONKey.swift +// +// Copyright (c) 2015-2016 Damien (http://delba.io) +// +// 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: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// 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. +// + +// MARK: - JSONKey + +private enum KeyType { + case string(Swift.String) + case int(Swift.Int) + case path([Any]) +} + +open class JSONKeys { + fileprivate init() {} +} + +open class JSONKey: JSONKeys { + fileprivate let type: KeyType + + /** + Creates a new instance of JSONKey. + + - parameter key: A string. + + - returns: A new instance of JSONKey. + */ + public init(_ key: String) { + self.type = .string(key) + } + + /** + Creates a new instance of JSONKey. + + - parameter key: An integer. + + - returns: A new instance of JSONKey. + */ + public init(_ key: Int) { + self.type = .int(key) + } + + /** + Creates a new instance of JSONKey. + + - parameter key: Any + + - returns: A new instance of JSONKey. + */ + public init(path indexes: Any...) { + self.type = .path(indexes) + } +} + +private extension JSON { + subscript(type: KeyType) -> JSON { + switch type { + case .string(let key): return self[key] + case .int(let key): return self[key] + case .path(let indexes): return self[indexes] + } + } +} + +// MARK: - JSON + +extension JSON { + /** + Returns the value associated with the given key as JSON. + + - parameter key: The key. + + - returns: The value associated with the given key as JSON. + */ + public subscript(key: JSONKey) -> JSON { + return self[key.type] + } +} + +// MARK: - String + +extension JSON { + /** + Returns the value associated with the given key as a string or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a string or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> String? { + return self[key.type].string + } + + /** + Returns the value associated with the given key as a string or "" if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a string or "" if not present/convertible. + */ + public subscript(key: JSONKey) -> String { + return self[key.type].stringValue + } +} + +// MARK: - Integer + +extension JSON { + /** + Returns the value associated with the given key as a 64-bit signed integer or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a 64-bit signed integer or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> Int? { + return self[key.type].int + } + + /** + Returns the value associated with the given key as a 64-bit signed integer or 0 if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a 64-bit signed integer or 0 if not present/convertible. + */ + public subscript(key: JSONKey) -> Int { + return self[key.type].intValue + } +} + +// MARK: - FloatingPointType + +extension JSON { + /** + Returns the value associated with the given key as a 64-bit floating-point number or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a 64-bit floating-point number or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> Double? { + return self[key.type].double + } + + /** + Returns the value associated with the given key as a 64-bit floating-point number or 0.0 if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a 64-bit floating-point number or 0.0 if not present/convertible. + */ + public subscript(key: JSONKey) -> Double { + return self[key.type].doubleValue + } + + /** + Returns the value associated with the given key as a 32-bit floating-point number or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a 32-bit floating-point number or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> Float? { + return self[key.type].float + } + + /** + Returns the value associated with the given key as a 32-bit floating-point number or 0.0 if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a 32-bit floating-point number or 0.0 if not present/convertible. + */ + public subscript(key: JSONKey) -> Float { + return self[key.type].floatValue + } + + /** + Returns the value associated with the given key as a NSNumber or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a NSNumber or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> NSNumber? { + return self[key.type].nsNumber + } + + /** + Returns the value associated with the given key as a NSNumber or 0 if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a NSNumber or 0 if not present/convertible. + */ + public subscript(key: JSONKey) -> NSNumber { + return self[key.type].nsNumberValue + } + + /** + Returns the value associated with the given key as a CGFloat or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a CGFloat or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> CGFloat? { + return self[key.type].cgFloat + } + + /** + Returns the value associated with the given key as a CGFloat or 0.0 if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a CGFloat or 0.0 if not present/convertible. + */ + public subscript(key: JSONKey) -> CGFloat { + return self[key.type].cgFloatValue + } +} + +// MARK: - Bool + +extension JSON { + /** + Returns the value associated with the given key as a Bool or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a Bool or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> Bool? { + return self[key.type].bool + } + + /** + Returns the value associated with the given key as a Bool or false if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a Bool or false if not present/convertible. + */ + public subscript(key: JSONKey) -> Bool { + return self[key.type].boolValue + } +} + +// MARK: - NSDate + +extension JSON { + /** + Returns the value associated with the given key as a NSDate or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a NSDate or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> Date? { + return self[key.type].nsDate + } +} + +// MARK: - NSURL + +extension JSON { + /** + Returns the value associated with the given key as a NSURL or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a NSURL or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> URL? { + return self[key.type].nsURL + } +} + +// MARK: - Dictionary + +extension JSON { + /** + Returns the value associated with the given key as a dictionary or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a dictionary or nil if not present/convertible. + */ + public subscript(key: JSONKey<[String: AnyObject]?>) -> [String: AnyObject]? { + return self[key.type].dictionary + } + + /** + Returns the value associated with the given key as a dictionary or an empty dictionary if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a dictionary or an empty dictionary if not present/convertible. + */ + public subscript(key: JSONKey<[String: AnyObject]>) -> [String: AnyObject] { + return self[key.type].dictionaryValue + } + + /** + Returns the value associated with the given key as a dictionary or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a dictionary or nil if not present/convertible. + */ + public subscript(key: JSONKey<[String: JSON]?>) -> [String: JSON]? { + return self[key.type].jsonDictionary + } + + /** + Returns the value associated with the given key as a dictionary or an empty dictionary if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a dictionary or an empty dictionary if not present/convertible. + */ + public subscript(key: JSONKey<[String: JSON]>) -> [String: JSON] { + return self[key.type].jsonDictionaryValue + } + /** + Returns the value associated with the given key as a dictionary or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a dictionary or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> NSDictionary? { + return self[key.type].nsDictionary + } + + /** + Returns the value associated with the given key as a NSDictionary or an empty NSDictionary if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a NSDictionary or an empty NSDictionary if not present/convertible. + */ + public subscript(key: JSONKey) -> NSDictionary { + return self[key.type].nsDictionaryValue + } +} + +// MARK: - Array + +extension JSON { + /** + Returns the value associated with the given key as an array or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as an array or nil if not present/convertible. + */ + public subscript(key: JSONKey<[AnyObject]?>) -> [AnyObject]? { + return self[key.type].array + } + + /** + Returns the value associated with the given key as an array or an empty array if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as an array or an empty array if not present/convertible. + */ + public subscript(key: JSONKey<[AnyObject]>) -> [AnyObject] { + return self[key.type].arrayValue + } + + /** + Returns the value associated with the given key as an array or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as an array or nil if not present/convertible. + */ + public subscript(key: JSONKey<[JSON]?>) -> [JSON]? { + return self[key.type].jsonArray + } + + /** + Returns the value associated with the given key as an array or an empty array if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as an array or an empty array if not present/convertible. + */ + public subscript(key: JSONKey<[JSON]>) -> [JSON] { + return self[key.type].jsonArrayValue + } + + /** + Returns the value associated with the given key as a NSArray or nil if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a NSArray or nil if not present/convertible. + */ + public subscript(key: JSONKey) -> NSArray? { + return self[key.type].nsArray + } + + /** + Returns the value associated with the given key as a NSArray or an empty NSArray if not present/convertible. + + - parameter key: The key. + + - returns: The value associated with the given key as a NSArray or an empty NSArray if not present/convertible. + */ + public subscript(key: JSONKey) -> NSArray { + return self[key.type].nsArrayValue + } +} diff --git a/Pods/JASON/Source/LiteralConvertible.swift b/Pods/JASON/Source/LiteralConvertible.swift new file mode 100644 index 0000000..342a90e --- /dev/null +++ b/Pods/JASON/Source/LiteralConvertible.swift @@ -0,0 +1,163 @@ +// +// LiteralConvertible.swift +// +// Copyright (c) 2015-2016 Damien (http://delba.io) +// +// 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: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// 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. +// + +// MARK: - StringLiteralConvertible + +/// Conforming types can be initialized with arbitrary string literals. +extension JSON: ExpressibleByStringLiteral { + /** + Creates an instance of JSON from a string literal + + - parameter stringLiteral: A string literal + + - returns: An instance of JSON + */ + public init(stringLiteral value: StringLiteralType) { + self.init(value) + } + + /** + Creates an instance of JSON from a string literal + + - parameter extendedGraphemeClusterLiteral: A string literal + + - returns: An instance of JSON + */ + public init(extendedGraphemeClusterLiteral value: StringLiteralType) { + self.init(value) + } + + /** + Creates an instance of JSON from a string literal + + - parameter unicodeScalarLiteral: A string literal + + - returns: An instance of JSON + */ + public init(unicodeScalarLiteral value: StringLiteralType) { + self.init(value) + } +} + +// MARK: - IntegerLiteralConvertible + +/// Conforming types can be initialized with integer literals. +extension JSON: ExpressibleByIntegerLiteral { + /** + Creates an instance of JSON from an integer literal. + + - parameter integerLiteral: An integer literal + + - returns: An instance of JSON + */ + public init(integerLiteral value: IntegerLiteralType) { + self.init(value) + } +} + +// MARK: - FloatLiteralConvertible + +/// Conforming types can be initialized with float literals. +extension JSON: ExpressibleByFloatLiteral { + /** + Creates an instance of JSON from a float literal. + + - parameter floatLiteral: A float literal + + - returns: An instance of JSON + */ + public init(floatLiteral value: FloatLiteralType) { + self.init(value) + } +} + +// MARK: - BooleanLiteralConvertible + +/// Conforming types can be initialized with the Boolean literals true and false. +extension JSON: ExpressibleByBooleanLiteral { + /** + Creates an instance of JSON from a boolean literal. + + - parameter booleanLiteral: A boolean literal + + - returns: An instance of JSON + */ + public init(booleanLiteral value: BooleanLiteralType) { + self.init(value) + } +} + +// MARK: - DictionaryLiteralConvertible + +/// Conforming types can be initialized with dictionary literals. +extension JSON: ExpressibleByDictionaryLiteral { + /** + Creates an instance of JSON from a dictionary literal. + + - parameter dictionaryLiteral: A dictionary literal + + - returns: An instance of JSON + */ + public init(dictionaryLiteral elements: (String, Any)...) { + var dictionary = [String: Any]() + + for (key, value) in elements { + dictionary[key] = value + } + + self.init(dictionary) + } +} + +// MARK: - ArrayLiteralConvertible + +/// Conforming types can be initialized with array literals. +extension JSON: ExpressibleByArrayLiteral { + /** + Creates an instance of JSON from an array literal. + + - parameter arrayLiteral: An array literal + + - returns: An instance of JSON + */ + public init(arrayLiteral elements: Any...) { + self.init(elements) + } +} + +// MARK: - NilLiteralConvertible + +/// Conforming types can be initialized with nil. +extension JSON: ExpressibleByNilLiteral { + /** + Creates an instance of JSON from a nil literal. + + - parameter nilLiteral: A nil literal + + - returns: An instance of JSON + */ + public init(nilLiteral: ()) { + self.init(object: nil) + } +} diff --git a/Pods/JASON/Source/Properties.swift b/Pods/JASON/Source/Properties.swift new file mode 100644 index 0000000..6e3f711 --- /dev/null +++ b/Pods/JASON/Source/Properties.swift @@ -0,0 +1,138 @@ +// +// Properties.swift +// +// Copyright (c) 2015-2016 Damien (http://delba.io) +// +// 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: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// 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. +// + +// MARK: - JSON + +extension JSON { + /// The value as JSON + public var json: JSON { return self } +} + +// MARK: - String + +extension JSON { + /// The value as a string or nil if not present/convertible + public var string: String? { return object as? String } + /// The value as a string or "" if not present/convertible + public var stringValue: String { return string ?? "" } +} + +// MARK: - Integer + +extension JSON { + /// The value as a 64-bit signed integer or nil if not present/convertible + public var int: Int? { return object as? Int } + /// The value as a 64-bit signed integer or 0 if not present/convertible + public var intValue: Int { return int ?? 0 } +} + +// MARK: - FloatingPointType + +extension JSON { + /// The value as a 64-bit floating-point number or nil if not present/convertible + public var double: Double? { return object as? Double } + /// The value as a 64-bit floating-point number or 0.0 if not present/convertible + public var doubleValue: Double { return double ?? 0 } + + /// The value as a 32-bit floating-point number or nil if not present/convertible + public var float: Float? { return object as? Float } + /// The value as a 32-bit floating-point number or 0.0 if not present/convertible + public var floatValue: Float { return float ?? 0 } + + /// The value as a NSNumber or nil if not present/convertible + public var nsNumber: NSNumber? { return object as? NSNumber } + /// The value as a NSNumber or 0 if not present/convertible + public var nsNumberValue: NSNumber { return nsNumber ?? 0 } + + /// The value as a CGFloat or nil if not present/convertible + public var cgFloat: CGFloat? { return object as? CGFloat } + /// The value as a CGFloat or 0.0 if not present/convertible + public var cgFloatValue: CGFloat { return cgFloat ?? 0 } +} + +// MARK: - Bool + +extension JSON { + /// The value as a boolean or nil if not present/convertible + public var bool: Bool? { return object as? Bool } + /// The value as a boolean or false if not present/convertible + public var boolValue: Bool { return bool ?? false } +} + +// MARK: - NSDate + +extension JSON { + /// The value as a NSDate or nil if not present/convertible + public var nsDate: Date? { return JSON.dateFormatter.date(from: stringValue) } +} + +// MARK: - NSURL + +extension JSON { + /// The value as an instance of NSURL or nil if not convertible + public var nsURL: URL? { + if let string = string?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) { + return URL(string: string) + } + return nil + } +} + +// MARK: - Dictionary + +extension JSON { + /// The value as a dictionary or nil if not present/convertible + public var dictionary: [String: AnyObject]? { return object as? [String: AnyObject] } + /// The value as a dictionary or an empty dictionary if not present/convertible + public var dictionaryValue: [String: AnyObject] { return dictionary ?? [:] } + + /// The value as a dictionary (NSDictionary) or nil if not present/convertible + public var nsDictionary: NSDictionary? { return object as? NSDictionary } + /// The value as a dictionary (NSDictionary) or an empty dictionary if not present/convertible + public var nsDictionaryValue: NSDictionary { return nsDictionary ?? NSDictionary() } + + /// The value as a dictionary or nil if not present/convertible + public var jsonDictionary: [String: JSON]? { return dictionary?.reduceValues{ JSON($0) }} + /// The value as a dictionary or an empty dictionary if not present/convertible + public var jsonDictionaryValue: [String: JSON] { return jsonDictionary ?? [:] } +} + +// MARK: - Array + +extension JSON { + /// The value as an array or nil if not present/convertible + public var array: [AnyObject]? { return object as? [AnyObject] } + /// The value as an array or an empty array if not present/convertible + public var arrayValue: [AnyObject] { return array ?? [] } + + /// The value as an array (NSArray) or nil if not present/convertible + public var nsArray: NSArray? { return object as? NSArray } + /// The value as an array (NSArray) or an empty array if not present/convertible + public var nsArrayValue: NSArray { return nsArray ?? NSArray() } + + /// The value as an array or nil if not present/convertible + public var jsonArray: [JSON]? { return array?.map{ JSON($0) } } + /// The value as an array or an empty array if not present/convertible + public var jsonArrayValue: [JSON] { return jsonArray ?? [] } +} diff --git a/Pods/JASON/Source/SequenceType.swift b/Pods/JASON/Source/SequenceType.swift new file mode 100644 index 0000000..e8c27af --- /dev/null +++ b/Pods/JASON/Source/SequenceType.swift @@ -0,0 +1,47 @@ +// +// SequenceType.swift +// +// Copyright (c) 2015-2016 Damien (http://delba.io) +// +// 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: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// 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. +// + +/// Conforming types gain access to reduce, map, filter et al. +extension JSON: Sequence { + /** + The required method to conform to the SequenceType protocol. + + - returns: a generator over the elements of arrayValue converted to JSON + */ + public func makeIterator() -> AnyIterator { + guard let array = nsArray else { + return AnyIterator { nil } + } + + var index = 0 + + return AnyIterator { + guard let object = array[safe: index] else { return nil } + + index += 1 + + return JSON(object) + } + } +} diff --git a/Pods/JASON/Source/Supporting Files/JASON.h b/Pods/JASON/Source/Supporting Files/JASON.h new file mode 100644 index 0000000..2e5453a --- /dev/null +++ b/Pods/JASON/Source/Supporting Files/JASON.h @@ -0,0 +1,29 @@ +// +// JASON.h +// +// Copyright (c) 2015-2016 Damien (http://delba.io) +// +// 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: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// 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. +// + +@import Foundation; +@import CoreGraphics.CGBase; + +FOUNDATION_EXPORT double JASONVersionNumber; +FOUNDATION_EXPORT const unsigned char JASONVersionString[]; diff --git a/Pods/JASON/Source/Supporting Files/Utilities.swift b/Pods/JASON/Source/Supporting Files/Utilities.swift new file mode 100644 index 0000000..3b38afe --- /dev/null +++ b/Pods/JASON/Source/Supporting Files/Utilities.swift @@ -0,0 +1,48 @@ +// +// Utilities.swift +// +// Copyright (c) 2015-2016 Damien (http://delba.io) +// +// 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: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// 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. +// + +internal extension NSArray { + /** + Returns the element at the given index or nil if the index is out of bounds. + + - parameter index: An integer + + - returns: The element at the given index or nil + */ + @nonobjc subscript(safe index: Int) -> Any? { + guard index >= 0 && index < count else { return nil } + + return self[index] + } +} + +internal extension Dictionary { + func reduceValues (_ transform: (Value) -> T) -> [Key: T] { + return reduce([Key: T]()) { (dictionary, kv) in + var dictionary = dictionary + dictionary[kv.0] = transform(kv.1) + return dictionary + } + } +} diff --git a/Pods/Kingfisher/LICENSE b/Pods/Kingfisher/LICENSE new file mode 100644 index 0000000..49ec5dd --- /dev/null +++ b/Pods/Kingfisher/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Wei Wang + +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: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +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. + diff --git a/Pods/Kingfisher/README.md b/Pods/Kingfisher/README.md new file mode 100644 index 0000000..a9b5214 --- /dev/null +++ b/Pods/Kingfisher/README.md @@ -0,0 +1,86 @@ +

+ +Kingfisher + +

+ +

+ + + + + + + + + + + + + +codebeat badge + + + + +

+ +Kingfisher is a lightweight, pure-Swift library for downloading and caching images from the web. This project is heavily inspired by the popular [SDWebImage](https://github.com/rs/SDWebImage). It provides you a chance to use a pure-Swift alternative in your next app. + +## Features + +- [x] Asynchronous image downloading and caching. +- [x] `URLSession`-based networking. Basic image processors and filters supplied. +- [x] Multiple-layer cache for both memory and disk. +- [x] Cancelable downloading and processing tasks to improve performance. +- [x] Independent components. Use the downloader or caching system separately as you need. +- [x] Prefetching images and showing them from cache later when necessary. +- [x] Extensions for `UIImageView`, `NSImage` and `UIButton` to directly set an image from a URL. +- [x] Built-in transition animation when setting images. +- [x] Extensible image processing and image format support. + +The simplest use-case is setting an image to an image view with the `UIImageView` extension: + +```swift +let url = URL(string: "url_of_your_image") +imageView.kf.setImage(with: url) +``` + +Kingfisher will download the image from `url`, send it to both the memory cache and the disk cache, and display it in `imageView`. When you use the same code later, the image will be retrieved from cache and shown immediately. + +## Requirements + +- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 2.0+ +- Swift 3 (Kingfisher 3.x), Swift 2.3 (Kingfisher 2.x) + +Main development of Kingfisher will support Swift 3. Only critical bug fixes will be made for Kingfisher 2.x. + +[Kingfisher 3.0 Migration Guide](https://github.com/onevcat/Kingfisher/wiki/Kingfisher-3.0-Migration-Guide) - If you are upgrading to Kingfisher 3.x from an earlier version, please read this for more information. + +## Next Steps + +We prepared a [wiki page](https://github.com/onevcat/Kingfisher/wiki). You can find tons of useful things there. + +* [Installation Guide](https://github.com/onevcat/Kingfisher/wiki/Installation-Guide) - Follow it to integrate Kingfisher into your project. +* [Cheat Sheet](https://github.com/onevcat/Kingfisher/wiki/Cheat-Sheet)- Curious about what Kingfisher could do and how would it look like when used in your project? See this page for useful code snippets. If you are already familiar with Kingfisher, you could also learn new tricks to improve the way you use Kingfisher! +* [API Reference](http://cocoadocs.org/docsets/Kingfisher/) - Lastly, please remember to read the full whenever you may need a more detailed reference. + +## Other + +### Future of Kingfisher + +I want to keep Kingfisher lightweight. This framework will focus on providing a simple solution for downloading and caching images. This doesn’t mean the framework can’t be improved. Kingfisher is far from perfect, so necessary and useful updates will be made to make it better. + +### About the logo + +The logo of Kingfisher is inspired by [Tangram (七巧板)](http://en.wikipedia.org/wiki/Tangram), a dissection puzzle consisting of seven flat shapes from China. I believe she's a kingfisher bird instead of a swift, but someone insists that she is a pigeon. I guess I should give her a name. Hi, guys, do you have any suggestions? + +### Contact + +Follow and contact me on [Twitter](http://twitter.com/onevcat) or [Sina Weibo](http://weibo.com/onevcat). If you find an issue, just [open a ticket](https://github.com/onevcat/Kingfisher/issues/new). Pull requests are warmly welcome as well. + +### License + +Kingfisher is released under the MIT license. See LICENSE for details. + + diff --git a/Pods/Kingfisher/Sources/AnimatedImageView.swift b/Pods/Kingfisher/Sources/AnimatedImageView.swift new file mode 100755 index 0000000..67f2318 --- /dev/null +++ b/Pods/Kingfisher/Sources/AnimatedImageView.swift @@ -0,0 +1,331 @@ +// +// AnimatableImageView.swift +// Kingfisher +// +// Created by bl4ckra1sond3tre on 4/22/16. +// +// The AnimatableImageView, AnimatedFrame and Animator is a modified version of +// some classes from kaishin's Gifu project (https://github.com/kaishin/Gifu) +// +// The MIT License (MIT) +// +// Copyright (c) 2014-2016 Reda Lemeden. +// +// 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: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// 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. +// +// The name and characters used in the demo of this software are property of their +// respective owners. + +import UIKit +import ImageIO + +/// `AnimatedImageView` is a subclass of `UIImageView` for displaying animated image. +open class AnimatedImageView: UIImageView { + + /// Proxy object for prevending a reference cycle between the CADDisplayLink and AnimatedImageView. + class TargetProxy { + private weak var target: AnimatedImageView? + + init(target: AnimatedImageView) { + self.target = target + } + + @objc func onScreenUpdate() { + target?.updateFrame() + } + } + + // MARK: - Public property + /// Whether automatically play the animation when the view become visible. Default is true. + public var autoPlayAnimatedImage = true + + /// The size of the frame cache. + public var framePreloadCount = 10 + + /// Specifies whether the GIF frames should be pre-scaled to save memory. Default is true. + public var needsPrescaling = true + + /// The animation timer's run loop mode. Default is `NSRunLoopCommonModes`. Set this property to `NSDefaultRunLoopMode` will make the animation pause during UIScrollView scrolling. + public var runLoopMode = RunLoopMode.commonModes { + willSet { + if runLoopMode == newValue { + return + } else { + stopAnimating() + displayLink.remove(from: .main, forMode: runLoopMode) + displayLink.add(to: .main, forMode: newValue) + startAnimating() + } + } + } + + // MARK: - Private property + /// `Animator` instance that holds the frames of a specific image in memory. + private var animator: Animator? + + /// A flag to avoid invalidating the displayLink on deinit if it was never created, because displayLink is so lazy. :D + private var isDisplayLinkInitialized: Bool = false + + /// A display link that keeps calling the `updateFrame` method on every screen refresh. + private lazy var displayLink: CADisplayLink = { + self.isDisplayLinkInitialized = true + let displayLink = CADisplayLink(target: TargetProxy(target: self), selector: #selector(TargetProxy.onScreenUpdate)) + displayLink.add(to: .main, forMode: self.runLoopMode) + displayLink.isPaused = true + return displayLink + }() + + // MARK: - Override + override open var image: Image? { + didSet { + if image != oldValue { + reset() + } + setNeedsDisplay() + layer.setNeedsDisplay() + } + } + + deinit { + if isDisplayLinkInitialized { + displayLink.invalidate() + } + } + + override open var isAnimating: Bool { + if isDisplayLinkInitialized { + return !displayLink.isPaused + } else { + return super.isAnimating + } + } + + /// Starts the animation. + override open func startAnimating() { + if self.isAnimating { + return + } else { + displayLink.isPaused = false + } + } + + /// Stops the animation. + override open func stopAnimating() { + super.stopAnimating() + if isDisplayLinkInitialized { + displayLink.isPaused = true + } + } + + override open func display(_ layer: CALayer) { + if let currentFrame = animator?.currentFrame { + layer.contents = currentFrame.cgImage + } else { + layer.contents = image?.cgImage + } + } + + override open func didMoveToWindow() { + super.didMoveToWindow() + didMove() + } + + override open func didMoveToSuperview() { + super.didMoveToSuperview() + didMove() + } + + // This is for back compatibility that using regular UIImageView to show GIF. + override func shouldPreloadAllGIF() -> Bool { + return false + } + + // MARK: - Private method + /// Reset the animator. + private func reset() { + animator = nil + if let imageSource = image?.kf.imageSource?.imageRef { + animator = Animator(imageSource: imageSource, contentMode: contentMode, size: bounds.size, framePreloadCount: framePreloadCount) + animator?.needsPrescaling = needsPrescaling + animator?.prepareFrames() + } + didMove() + } + + private func didMove() { + if autoPlayAnimatedImage && animator != nil { + if let _ = superview, let _ = window { + startAnimating() + } else { + stopAnimating() + } + } + } + + /// Update the current frame with the displayLink duration. + private func updateFrame() { + if animator?.updateCurrentFrame(duration: displayLink.duration) ?? false { + layer.setNeedsDisplay() + } + } +} + +/// Keeps a reference to an `Image` instance and its duration as a GIF frame. +struct AnimatedFrame { + var image: Image? + let duration: TimeInterval + + static let null: AnimatedFrame = AnimatedFrame(image: .none, duration: 0.0) +} + +// MARK: - Animator +class Animator { + // MARK: Private property + fileprivate let size: CGSize + fileprivate let maxFrameCount: Int + fileprivate let imageSource: CGImageSource + + fileprivate var animatedFrames = [AnimatedFrame]() + fileprivate let maxTimeStep: TimeInterval = 1.0 + fileprivate var frameCount = 0 + fileprivate var currentFrameIndex = 0 + fileprivate var currentPreloadIndex = 0 + fileprivate var timeSinceLastFrameChange: TimeInterval = 0.0 + fileprivate var needsPrescaling = true + + /// Loop count of animatd image. + private var loopCount = 0 + + var currentFrame: UIImage? { + return frame(at: currentFrameIndex) + } + + var contentMode = UIViewContentMode.scaleToFill + + /** + Init an animator with image source reference. + + - parameter imageSource: The reference of animated image. + - parameter contentMode: Content mode of AnimatedImageView. + - parameter size: Size of AnimatedImageView. + - parameter framePreloadCount: Frame cache size. + + - returns: The animator object. + */ + init(imageSource source: CGImageSource, contentMode mode: UIViewContentMode, size: CGSize, framePreloadCount count: Int) { + self.imageSource = source + self.contentMode = mode + self.size = size + self.maxFrameCount = count + } + + func frame(at index: Int) -> Image? { + return animatedFrames[index].image + } + + func prepareFrames() { + frameCount = CGImageSourceGetCount(imageSource) + + if let properties = CGImageSourceCopyProperties(imageSource, nil), + let gifInfo = (properties as NSDictionary)[kCGImagePropertyGIFDictionary as String] as? NSDictionary, + let loopCount = gifInfo[kCGImagePropertyGIFLoopCount as String] as? Int + { + self.loopCount = loopCount + } + + let frameToProcess = min(frameCount, maxFrameCount) + animatedFrames.reserveCapacity(frameToProcess) + animatedFrames = (0.. AnimatedFrame { + guard let imageRef = CGImageSourceCreateImageAtIndex(imageSource, index, nil) else { + return AnimatedFrame.null + } + + let frameDuration = imageSource.kf.GIFProperties(at: index).flatMap { + gifInfo -> Double? in + + let unclampedDelayTime = gifInfo[kCGImagePropertyGIFUnclampedDelayTime as String] as Double? + let delayTime = gifInfo[kCGImagePropertyGIFDelayTime as String] as Double? + let duration = unclampedDelayTime ?? delayTime ?? 0.0 + + /** + http://opensource.apple.com/source/WebCore/WebCore-7600.1.25/platform/graphics/cg/ImageSourceCG.cpp + Many annoying ads specify a 0 duration to make an image flash as quickly as + possible. We follow Safari and Firefox's behavior and use a duration of 100 ms + for any frames that specify a duration of <= 10 ms. + See and for more information. + + See also: http://nullsleep.tumblr.com/post/16524517190/animated-gif-minimum-frame-delay-browser. + */ + return duration > 0.011 ? duration : 0.100 + } + + let image = Image(cgImage: imageRef) + let scaledImage: Image? + + if needsPrescaling { + scaledImage = image.kf.resize(to: size, for: contentMode) + } else { + scaledImage = image + } + + return AnimatedFrame(image: scaledImage, duration: frameDuration ?? 0.0) + } + + /** + Updates the current frame if necessary using the frame timer and the duration of each frame in `animatedFrames`. + */ + func updateCurrentFrame(duration: CFTimeInterval) -> Bool { + timeSinceLastFrameChange += min(maxTimeStep, duration) + guard let frameDuration = animatedFrames[safe: currentFrameIndex]?.duration, frameDuration <= timeSinceLastFrameChange else { + return false + } + + timeSinceLastFrameChange -= frameDuration + let lastFrameIndex = currentFrameIndex + currentFrameIndex += 1 + currentFrameIndex = currentFrameIndex % animatedFrames.count + + if animatedFrames.count < frameCount { + animatedFrames[lastFrameIndex] = prepareFrame(at: currentPreloadIndex) + currentPreloadIndex += 1 + currentPreloadIndex = currentPreloadIndex % frameCount + } + return true + } +} + +extension CGImageSource: KingfisherCompatible { } +extension Kingfisher where Base: CGImageSource { + func GIFProperties(at index: Int) -> [String: Double]? { + let properties = CGImageSourceCopyPropertiesAtIndex(base, index, nil) as Dictionary? + return properties?[kCGImagePropertyGIFDictionary] as? [String: Double] + } +} + +extension Array { + subscript(safe index: Int) -> Element? { + return indices ~= index ? self[index] : nil + } +} + +private func pure(_ value: T) -> [T] { + return [value] +} diff --git a/Pods/Kingfisher/Sources/Box.swift b/Pods/Kingfisher/Sources/Box.swift new file mode 100644 index 0000000..7076add --- /dev/null +++ b/Pods/Kingfisher/Sources/Box.swift @@ -0,0 +1,16 @@ +// +// Box.swift +// Kingfisher +// +// Created by WANG WEI on 2016/09/12. +// Copyright © 2016年 Wei Wang. All rights reserved. +// + +import Foundation + +class Box { + let value: T + init(value: T) { + self.value = value + } +} diff --git a/Pods/Kingfisher/Sources/CacheSerializer.swift b/Pods/Kingfisher/Sources/CacheSerializer.swift new file mode 100644 index 0000000..df3c5ce --- /dev/null +++ b/Pods/Kingfisher/Sources/CacheSerializer.swift @@ -0,0 +1,85 @@ +// +// CacheSerializer.swift +// Kingfisher +// +// Created by Wei Wang on 2016/09/02. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +import Foundation + +/// An `CacheSerializer` would be used to convert some data to an image object for +/// retrieving from disk cache and vice versa for storing to disk cache. +public protocol CacheSerializer { + + /// Get the serialized data from a provided image + /// and optional original data for caching to disk. + /// + /// + /// - parameter image: The image needed to be serialized. + /// - parameter original: The original data which is just downloaded. + /// If the image is retrieved from cache instead of + /// downloaded, it will be `nil`. + /// + /// - returns: A data which will be stored to cache, or `nil` when no valid + /// data could be serialized. + func data(with image: Image, original: Data?) -> Data? + + /// Get an image deserialized from provided data. + /// + /// - parameter data: The data from which an image should be deserialized. + /// - parameter options: Options for deserialization. + /// + /// - returns: An image deserialized or `nil` when no valid image + /// could be deserialized. + func image(with data: Data, options: KingfisherOptionsInfo?) -> Image? +} + + +/// `DefaultCacheSerializer` is a basic `CacheSerializer` used in default cache of +/// Kingfisher. It could serialize and deserialize PNG, JEPG and GIF images. For +/// image other than these formats, a normalized `pngRepresentation` will be used. +public struct DefaultCacheSerializer: CacheSerializer { + + public static let `default` = DefaultCacheSerializer() + private init() {} + + public func data(with image: Image, original: Data?) -> Data? { + let imageFormat = original?.kf.imageFormat ?? .unknown + + let data: Data? + switch imageFormat { + case .PNG: data = image.kf.pngRepresentation() + case .JPEG: data = image.kf.jpegRepresentation(compressionQuality: 1.0) + case .GIF: data = image.kf.gifRepresentation() + case .unknown: data = original ?? image.kf.normalized.kf.pngRepresentation() + } + + return data + } + + public func image(with data: Data, options: KingfisherOptionsInfo?) -> Image? { + let scale = (options ?? KingfisherEmptyOptionsInfo).scaleFactor + let preloadAllGIFData = (options ?? KingfisherEmptyOptionsInfo).preloadAllGIFData + + return Kingfisher.image(data: data, scale: scale, preloadAllGIFData: preloadAllGIFData) + } +} diff --git a/Pods/Kingfisher/Sources/Filter.swift b/Pods/Kingfisher/Sources/Filter.swift new file mode 100644 index 0000000..06138ba --- /dev/null +++ b/Pods/Kingfisher/Sources/Filter.swift @@ -0,0 +1,145 @@ +// +// Filter.swift +// Kingfisher +// +// Created by Wei Wang on 2016/08/31. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + + + +import CoreImage +import Accelerate + +// Reuse the same CI Context for all CI drawing. +private let ciContext = CIContext(options: nil) + +/// Transformer method which will be used in to provide a `Filter`. +public typealias Transformer = (CIImage) -> CIImage? + +/// Supply a filter to create an `ImageProcessor`. +public protocol CIImageProcessor: ImageProcessor { + var filter: Filter { get } +} + +extension CIImageProcessor { + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.apply(filter) + case .data(let data): + return Kingfisher.image(data: data, scale: options.scaleFactor, preloadAllGIFData: options.preloadAllGIFData) + } + } +} + +/// Wrapper for a `Transformer` of CIImage filters. +public struct Filter { + + let transform: Transformer + + public init(tranform: @escaping Transformer) { + self.transform = tranform + } + + /// Tint filter which will apply a tint color to images. + public static var tint: (Color) -> Filter = { + color in + Filter { input in + let colorFilter = CIFilter(name: "CIConstantColorGenerator")! + colorFilter.setValue(CIColor(color: color), forKey: kCIInputColorKey) + + let colorImage = colorFilter.outputImage + let filter = CIFilter(name: "CISourceOverCompositing")! + filter.setValue(colorImage, forKey: kCIInputImageKey) + filter.setValue(input, forKey: kCIInputBackgroundImageKey) + return filter.outputImage?.cropping(to: input.extent) + } + } + + public typealias ColorElement = (CGFloat, CGFloat, CGFloat, CGFloat) + + /// Color control filter which will apply color control change to images. + public static var colorControl: (ColorElement) -> Filter = { + brightness, contrast, saturation, inputEV in + Filter { input in + let paramsColor = [kCIInputBrightnessKey: brightness, + kCIInputContrastKey: contrast, + kCIInputSaturationKey: saturation] + + let blackAndWhite = input.applyingFilter("CIColorControls", withInputParameters: paramsColor) + let paramsExposure = [kCIInputEVKey: inputEV] + return blackAndWhite.applyingFilter("CIExposureAdjust", withInputParameters: paramsExposure) + } + + } +} + +extension Kingfisher where Base: Image { + /// Apply a `Filter` containing `CIImage` transformer to `self`. + /// + /// - parameter filter: The filter used to transform `self`. + /// + /// - returns: A transformed image by input `Filter`. + /// + /// - Note: Only CG-based images are supported. If any error happens during transforming, `self` will be returned. + public func apply(_ filter: Filter) -> Image { + + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Tint image only works for CG-based image.") + return base + } + + let inputImage = CIImage(cgImage: cgImage) + guard let outputImage = filter.transform(inputImage) else { + return base + } + + guard let result = ciContext.createCGImage(outputImage, from: outputImage.extent) else { + assertionFailure("[Kingfisher] Can not make an tint image within context.") + return base + } + + #if os(macOS) + return fixedForRetinaPixel(cgImage: result, to: size) + #else + return Image(cgImage: result) + #endif + } + +} + +public extension Image { + + /// Apply a `Filter` containing `CIImage` transformer to `self`. + /// + /// - parameter filter: The filter used to transform `self`. + /// + /// - returns: A transformed image by input `Filter`. + /// + /// - Note: Only CG-based images are supported. If any error happens during transforming, `self` will be returned. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.apply` instead.", + renamed: "kf.apply") + public func kf_apply(_ filter: Filter) -> Image { + return kf.apply(filter) + } +} diff --git a/Pods/Kingfisher/Sources/Image.swift b/Pods/Kingfisher/Sources/Image.swift new file mode 100755 index 0000000..cf29ac4 --- /dev/null +++ b/Pods/Kingfisher/Sources/Image.swift @@ -0,0 +1,938 @@ +// +// Image.swift +// Kingfisher +// +// Created by Wei Wang on 16/1/6. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + + +#if os(macOS) +import AppKit +private var imagesKey: Void? +private var durationKey: Void? +#else +import UIKit +import MobileCoreServices +private var imageSourceKey: Void? +private var animatedImageDataKey: Void? +#endif + +import ImageIO +import CoreGraphics + +#if !os(watchOS) +import Accelerate +import CoreImage +#endif + +// MARK: - Image Properties +extension Kingfisher where Base: Image { + #if os(macOS) + var cgImage: CGImage? { + return base.cgImage(forProposedRect: nil, context: nil, hints: nil) + } + + var scale: CGFloat { + return 1.0 + } + + fileprivate(set) var images: [Image]? { + get { + return objc_getAssociatedObject(base, &imagesKey) as? [Image] + } + set { + objc_setAssociatedObject(base, &imagesKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + fileprivate(set) var duration: TimeInterval { + get { + return objc_getAssociatedObject(base, &durationKey) as? TimeInterval ?? 0.0 + } + set { + objc_setAssociatedObject(base, &durationKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + var size: CGSize { + return base.representations.reduce(CGSize.zero, { size, rep in + return CGSize(width: max(size.width, CGFloat(rep.pixelsWide)), height: max(size.height, CGFloat(rep.pixelsHigh))) + }) + } + + #else + var cgImage: CGImage? { + return base.cgImage + } + + var scale: CGFloat { + return base.scale + } + + var images: [Image]? { + return base.images + } + + var duration: TimeInterval { + return base.duration + } + + fileprivate(set) var imageSource: ImageSource? { + get { + return objc_getAssociatedObject(base, &imageSourceKey) as? ImageSource + } + set { + objc_setAssociatedObject(base, &imageSourceKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + fileprivate(set) var animatedImageData: Data? { + get { + return objc_getAssociatedObject(base, &animatedImageDataKey) as? Data + } + set { + objc_setAssociatedObject(base, &animatedImageDataKey, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + var size: CGSize { + return base.size + } + #endif +} + +// MARK: - Image Conversion +extension Kingfisher where Base: Image { + #if os(macOS) + static func image(cgImage: CGImage, scale: CGFloat, refImage: Image?) -> Image { + return Image(cgImage: cgImage, size: CGSize.zero) + } + + /** + Normalize the image. This method does nothing in OS X. + + - returns: The image itself. + */ + public var normalized: Image { + return base + } + + static func animated(with images: [Image], forDuration forDurationduration: TimeInterval) -> Image? { + return nil + } + #else + static func image(cgImage: CGImage, scale: CGFloat, refImage: Image?) -> Image { + if let refImage = refImage { + return Image(cgImage: cgImage, scale: scale, orientation: refImage.imageOrientation) + } else { + return Image(cgImage: cgImage, scale: scale, orientation: .up) + } + } + + /** + Normalize the image. This method will try to redraw an image with orientation and scale considered. + + - returns: The normalized image with orientation set to up and correct scale. + */ + public var normalized: Image { + // prevent animated image (GIF) lose it's images + guard images == nil else { return base } + // No need to do anything if already up + guard base.imageOrientation != .up else { return base } + + return draw(cgImage: nil, to: size) { + base.draw(in: CGRect(origin: CGPoint.zero, size: size)) + } + } + + static func animated(with images: [Image], forDuration duration: TimeInterval) -> Image? { + return .animatedImage(with: images, duration: duration) + } + #endif +} + +// MARK: - Image Representation +extension Kingfisher where Base: Image { + // MARK: - PNG + func pngRepresentation() -> Data? { + #if os(macOS) + guard let cgimage = cgImage else { + return nil + } + let rep = NSBitmapImageRep(cgImage: cgimage) + return rep.representation(using: .PNG, properties: [:]) + #else + return UIImagePNGRepresentation(base) + #endif + } + + // MARK: - JPEG + func jpegRepresentation(compressionQuality: CGFloat) -> Data? { + #if os(macOS) + guard let cgImage = cgImage else { + return nil + } + let rep = NSBitmapImageRep(cgImage: cgImage) + return rep.representation(using:.JPEG, properties: [NSImageCompressionFactor: compressionQuality]) + #else + return UIImageJPEGRepresentation(base, compressionQuality) + #endif + } + + // MARK: - GIF + func gifRepresentation() -> Data? { + #if os(macOS) + return gifRepresentation(duration: 0.0, repeatCount: 0) + #else + return animatedImageData + #endif + } + + #if os(macOS) + func gifRepresentation(duration: TimeInterval, repeatCount: Int) -> Data? { + guard let images = images else { + return nil + } + + let frameCount = images.count + let gifDuration = duration <= 0.0 ? duration / Double(frameCount) : duration / Double(frameCount) + + let frameProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFDelayTime as String: gifDuration]] + let imageProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: repeatCount]] + + let data = NSMutableData() + + guard let destination = CGImageDestinationCreateWithData(data, kUTTypeGIF, frameCount, nil) else { + return nil + } + CGImageDestinationSetProperties(destination, imageProperties as CFDictionary) + + for image in images { + CGImageDestinationAddImage(destination, image.kf.cgImage!, frameProperties as CFDictionary) + } + + return CGImageDestinationFinalize(destination) ? data.copy() as? Data : nil + } + #endif +} + +// MARK: - Create images from data +extension Kingfisher where Base: Image { + static func animated(with data: Data, scale: CGFloat = 1.0, duration: TimeInterval = 0.0, preloadAll: Bool) -> Image? { + + func decode(from imageSource: CGImageSource, for options: NSDictionary) -> ([Image], TimeInterval)? { + + //Calculates frame duration for a gif frame out of the kCGImagePropertyGIFDictionary dictionary + func frameDuration(from gifInfo: NSDictionary) -> Double { + let gifDefaultFrameDuration = 0.100 + + let unclampedDelayTime = gifInfo[kCGImagePropertyGIFUnclampedDelayTime as String] as? NSNumber + let delayTime = gifInfo[kCGImagePropertyGIFDelayTime as String] as? NSNumber + let duration = unclampedDelayTime ?? delayTime + + guard let frameDuration = duration else { return gifDefaultFrameDuration } + + return frameDuration.doubleValue > 0.011 ? frameDuration.doubleValue : gifDefaultFrameDuration + } + + let frameCount = CGImageSourceGetCount(imageSource) + var images = [Image]() + var gifDuration = 0.0 + for i in 0 ..< frameCount { + + guard let imageRef = CGImageSourceCreateImageAtIndex(imageSource, i, options) else { + return nil + } + + if frameCount == 1 { + // Single frame + gifDuration = Double.infinity + } else { + // Animated GIF + guard let properties = CGImageSourceCopyPropertiesAtIndex(imageSource, i, nil), + let gifInfo = (properties as NSDictionary)[kCGImagePropertyGIFDictionary as String] as? NSDictionary else + { + return nil + } + gifDuration += frameDuration(from: gifInfo) + } + + images.append(Kingfisher.image(cgImage: imageRef, scale: scale, refImage: nil)) + } + + return (images, gifDuration) + } + + // Start of kf.animatedImageWithGIFData + let options: NSDictionary = [kCGImageSourceShouldCache as String: true, kCGImageSourceTypeIdentifierHint as String: kUTTypeGIF] + guard let imageSource = CGImageSourceCreateWithData(data as CFData, options) else { + return nil + } + + #if os(macOS) + guard let (images, gifDuration) = decode(from: imageSource, for: options) else { + return nil + } + var image = Image(data: data) + image?.kf.images = images + image?.kf.duration = gifDuration + + return image + #else + + if preloadAll { + guard let (images, gifDuration) = decode(from: imageSource, for: options) else { + return nil + } + var image = Kingfisher.animated(with: images, forDuration: duration <= 0.0 ? gifDuration : duration) + image?.kf.animatedImageData = data + return image + } else { + var image = Image(data: data) + image?.kf.animatedImageData = data + image?.kf.imageSource = ImageSource(ref: imageSource) + return image + } + #endif + } + + static func image(data: Data, scale: CGFloat, preloadAllGIFData: Bool) -> Image? { + var image: Image? + + #if os(macOS) + switch data.kf.imageFormat { + case .JPEG: image = Image(data: data) + case .PNG: image = Image(data: data) + case .GIF: image = Kingfisher.animated(with: data, scale: scale, duration: 0.0, preloadAll: preloadAllGIFData) + case .unknown: image = Image(data: data) + } + #else + switch data.kf.imageFormat { + case .JPEG: image = Image(data: data, scale: scale) + case .PNG: image = Image(data: data, scale: scale) + case .GIF: image = Kingfisher.animated(with: data, scale: scale, duration: 0.0, preloadAll: preloadAllGIFData) + case .unknown: image = Image(data: data, scale: scale) + } + #endif + + return image + } +} + +// MARK: - Image Transforming +extension Kingfisher where Base: Image { + // MARK: - Round Corner + /// Create a round corner image based on `self`. + /// + /// - parameter radius: The round corner radius of creating image. + /// - parameter size: The target size of creating image. + /// - parameter scale: The image scale of creating image. + /// + /// - returns: An image with round corner of `self`. + /// + /// - Note: This method only works for CG-based image. + public func image(withRoundRadius radius: CGFloat, fit size: CGSize, scale: CGFloat) -> Image { + + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Round corder image only works for CG-based image.") + return base + } + + let rect = CGRect(origin: CGPoint(x: 0, y: 0), size: size) + return draw(cgImage: cgImage, to: size) { + #if os(macOS) + let path = NSBezierPath(roundedRect: rect, xRadius: radius, yRadius: radius) + path.windingRule = .evenOddWindingRule + path.addClip() + base.draw(in: rect) + #else + guard let context = UIGraphicsGetCurrentContext() else { + assertionFailure("[Kingfisher] Failed to create CG context for image.") + return + } + let path = UIBezierPath(roundedRect: rect, byRoundingCorners: .allCorners, cornerRadii: CGSize(width: radius, height: radius)).cgPath + context.addPath(path) + context.clip() + base.draw(in: rect) + #endif + } + } + + #if os(iOS) || os(tvOS) + func resize(to size: CGSize, for contentMode: UIViewContentMode) -> Image { + switch contentMode { + case .scaleAspectFit: + let newSize = self.size.kf.constrained(size) + return resize(to: newSize) + case .scaleAspectFill: + let newSize = self.size.kf.filling(size) + return resize(to: newSize) + default: + return resize(to: size) + } + } + #endif + + // MARK: - Resize + + /// Resize `self` to an image of new size. + /// + /// - parameter size: The target size. + /// + /// - returns: An image with new size. + /// + /// - Note: This method only works for CG-based image. + public func resize(to size: CGSize) -> Image { + + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Resize only works for CG-based image.") + return base + } + + let rect = CGRect(origin: CGPoint(x: 0, y: 0), size: size) + return draw(cgImage: cgImage, to: size) { + #if os(macOS) + base.draw(in: rect, from: NSRect.zero, operation: .copy, fraction: 1.0) + #else + base.draw(in: rect) + #endif + } + } + + // MARK: - Blur + + /// Create an image with blur effect based on `self`. + /// + /// - parameter radius: The blur radius should be used when creating blue. + /// + /// - returns: An image with blur effect applied. + /// + /// - Note: This method only works for CG-based image. + public func blurred(withRadius radius: CGFloat) -> Image { + #if os(watchOS) + return base + #else + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Blur only works for CG-based image.") + return base + } + + // http://www.w3.org/TR/SVG/filters.html#feGaussianBlurElement + // let d = floor(s * 3*sqrt(2*pi)/4 + 0.5) + // if d is odd, use three box-blurs of size 'd', centered on the output pixel. + let s = max(radius, 2.0) + // We will do blur on a resized image (*0.5), so the blur radius could be half as well. + var targetRadius = floor((Double(s * 3.0) * sqrt(2 * M_PI) / 4.0 + 0.5)) + + if targetRadius.isEven { + targetRadius += 1 + } + + let iterations: Int + if radius < 0.5 { + iterations = 1 + } else if radius < 1.5 { + iterations = 2 + } else { + iterations = 3 + } + + let w = Int(size.width) + let h = Int(size.height) + let rowBytes = Int(CGFloat(cgImage.bytesPerRow)) + + let inDataPointer = UnsafeMutablePointer.allocate(capacity: rowBytes * Int(h)) + inDataPointer.initialize(to: 0) + defer { + inDataPointer.deinitialize() + inDataPointer.deallocate(capacity: rowBytes * Int(h)) + } + + let bitmapInfo = cgImage.bitmapInfo.fixed + guard let context = CGContext(data: inDataPointer, + width: w, + height: h, + bitsPerComponent: cgImage.bitsPerComponent, + bytesPerRow: rowBytes, + space: cgImage.colorSpace ?? CGColorSpaceCreateDeviceRGB(), + bitmapInfo: bitmapInfo.rawValue) else + { + assertionFailure("[Kingfisher] Failed to create CG context for blurring image.") + return base + } + + context.draw(cgImage, in: CGRect(x: 0, y: 0, width: w, height: h)) + + + var inBuffer = vImage_Buffer(data: inDataPointer, height: vImagePixelCount(h), width: vImagePixelCount(w), rowBytes: rowBytes) + + let outDataPointer = UnsafeMutablePointer.allocate(capacity: rowBytes * Int(h)) + outDataPointer.initialize(to: 0) + defer { + outDataPointer.deinitialize() + outDataPointer.deallocate(capacity: rowBytes * Int(h)) + } + + var outBuffer = vImage_Buffer(data: outDataPointer, height: vImagePixelCount(h), width: vImagePixelCount(w), rowBytes: rowBytes) + + for _ in 0 ..< iterations { + vImageBoxConvolve_ARGB8888(&inBuffer, &outBuffer, nil, 0, 0, UInt32(targetRadius), UInt32(targetRadius), nil, vImage_Flags(kvImageEdgeExtend)) + (inBuffer, outBuffer) = (outBuffer, inBuffer) + } + + guard let outContext = CGContext(data: inDataPointer, + width: w, + height: h, + bitsPerComponent: cgImage.bitsPerComponent, + bytesPerRow: rowBytes, + space: cgImage.colorSpace ?? CGColorSpaceCreateDeviceRGB(), + bitmapInfo: bitmapInfo.rawValue) else + { + assertionFailure("[Kingfisher] Failed to create CG context for blurring image.") + return base + } + + #if os(macOS) + let result = outContext.makeImage().flatMap { fixedForRetinaPixel(cgImage: $0, to: size) } + #else + let result = outContext.makeImage().flatMap { Image(cgImage: $0) } + #endif + guard let blurredImage = result else { + assertionFailure("[Kingfisher] Can not make an blurred image within this context.") + return base + } + + return blurredImage + #endif + } + + // MARK: - Overlay + + /// Create an image from `self` with a color overlay layer. + /// + /// - parameter color: The color should be use to overlay. + /// - parameter fraction: Fraction of input color. From 0.0 to 1.0. 0.0 means solid color, 1.0 means transparent overlay. + /// + /// - returns: An image with a color overlay applied. + /// + /// - Note: This method only works for CG-based image. + public func overlaying(with color: Color, fraction: CGFloat) -> Image { + + guard let cgImage = cgImage else { + assertionFailure("[Kingfisher] Overlaying only works for CG-based image.") + return base + } + + let rect = CGRect(x: 0, y: 0, width: size.width, height: size.height) + return draw(cgImage: cgImage, to: rect.size) { + #if os(macOS) + base.draw(in: rect) + if fraction > 0 { + color.withAlphaComponent(1 - fraction).set() + NSRectFillUsingOperation(rect, .sourceAtop) + } + #else + color.set() + UIRectFill(rect) + base.draw(in: rect, blendMode: .destinationIn, alpha: 1.0) + + if fraction > 0 { + base.draw(in: rect, blendMode: .sourceAtop, alpha: fraction) + } + #endif + } + } + + // MARK: - Tint + + /// Create an image from `self` with a color tint. + /// + /// - parameter color: The color should be used to tint `self` + /// + /// - returns: An image with a color tint applied. + public func tinted(with color: Color) -> Image { + #if os(watchOS) + return base + #else + return apply(.tint(color)) + #endif + } + + // MARK: - Color Control + + /// Create an image from `self` with color control. + /// + /// - parameter brightness: Brightness changing to image. + /// - parameter contrast: Contrast changing to image. + /// - parameter saturation: Saturation changing to image. + /// - parameter inputEV: InputEV changing to image. + /// + /// - returns: An image with color control applied. + public func adjusted(brightness: CGFloat, contrast: CGFloat, saturation: CGFloat, inputEV: CGFloat) -> Image { + #if os(watchOS) + return base + #else + return apply(.colorControl(brightness, contrast, saturation, inputEV)) + #endif + } +} + +// MARK: - Decode +extension Kingfisher where Base: Image { + var decoded: Image? { + return decoded(scale: scale) + } + + func decoded(scale: CGFloat) -> Image { + // prevent animated image (GIF) lose it's images + #if os(iOS) + if imageSource != nil { return base } + #else + if images != nil { return base } + #endif + + guard let imageRef = self.cgImage else { + assertionFailure("[Kingfisher] Decoding only works for CG-based image.") + return base + } + let colorSpace = CGColorSpaceCreateDeviceRGB() + let bitmapInfo = imageRef.bitmapInfo.fixed + + guard let context = CGContext(data: nil, width: imageRef.width, height: imageRef.height, bitsPerComponent: 8, bytesPerRow: 0, space: colorSpace, bitmapInfo: bitmapInfo.rawValue) else { + assertionFailure("[Kingfisher] Decoding fails to create a valid context.") + return base + } + + let rect = CGRect(x: 0, y: 0, width: imageRef.width, height: imageRef.height) + context.draw(imageRef, in: rect) + let decompressedImageRef = context.makeImage() + return Kingfisher.image(cgImage: decompressedImageRef!, scale: scale, refImage: base) + } +} + +/// Reference the source image reference +class ImageSource { + var imageRef: CGImageSource? + init(ref: CGImageSource) { + self.imageRef = ref + } +} + +// MARK: - Image format +private struct ImageHeaderData { + static var PNG: [UInt8] = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A] + static var JPEG_SOI: [UInt8] = [0xFF, 0xD8] + static var JPEG_IF: [UInt8] = [0xFF] + static var GIF: [UInt8] = [0x47, 0x49, 0x46] +} + +enum ImageFormat { + case unknown, PNG, JPEG, GIF +} + + +// MARK: - Misc Helpers +public struct DataProxy { + fileprivate let base: Data + init(proxy: Data) { + base = proxy + } +} + +extension Data: KingfisherCompatible { + public typealias CompatibleType = DataProxy + public var kf: DataProxy { + return DataProxy(proxy: self) + } +} + +extension DataProxy { + var imageFormat: ImageFormat { + var buffer = [UInt8](repeating: 0, count: 8) + (base as NSData).getBytes(&buffer, length: 8) + if buffer == ImageHeaderData.PNG { + return .PNG + } else if buffer[0] == ImageHeaderData.JPEG_SOI[0] && + buffer[1] == ImageHeaderData.JPEG_SOI[1] && + buffer[2] == ImageHeaderData.JPEG_IF[0] + { + return .JPEG + } else if buffer[0] == ImageHeaderData.GIF[0] && + buffer[1] == ImageHeaderData.GIF[1] && + buffer[2] == ImageHeaderData.GIF[2] + { + return .GIF + } + + return .unknown + } +} + +public struct CGSizeProxy { + fileprivate let base: CGSize + init(proxy: CGSize) { + base = proxy + } +} + +extension CGSize: KingfisherCompatible { + public typealias CompatibleType = CGSizeProxy + public var kf: CGSizeProxy { + return CGSizeProxy(proxy: self) + } +} + +extension CGSizeProxy { + func constrained(_ size: CGSize) -> CGSize { + let aspectWidth = round(aspectRatio * size.height) + let aspectHeight = round(size.width / aspectRatio) + + return aspectWidth > size.width ? CGSize(width: size.width, height: aspectHeight) : CGSize(width: aspectWidth, height: size.height) + } + + func filling(_ size: CGSize) -> CGSize { + let aspectWidth = round(aspectRatio * size.height) + let aspectHeight = round(size.width / aspectRatio) + + return aspectWidth < size.width ? CGSize(width: size.width, height: aspectHeight) : CGSize(width: aspectWidth, height: size.height) + } + + private var aspectRatio: CGFloat { + return base.height == 0.0 ? 1.0 : base.width / base.height + } +} + +extension CGBitmapInfo { + var fixed: CGBitmapInfo { + var fixed = self + let alpha = (rawValue & CGBitmapInfo.alphaInfoMask.rawValue) + if alpha == CGImageAlphaInfo.none.rawValue { + fixed.remove(.alphaInfoMask) + fixed = CGBitmapInfo(rawValue: fixed.rawValue | CGImageAlphaInfo.noneSkipFirst.rawValue) + } else if !(alpha == CGImageAlphaInfo.noneSkipFirst.rawValue) || !(alpha == CGImageAlphaInfo.noneSkipLast.rawValue) { + fixed.remove(.alphaInfoMask) + fixed = CGBitmapInfo(rawValue: fixed.rawValue | CGImageAlphaInfo.premultipliedFirst.rawValue) + } + return fixed + } +} + + +extension Kingfisher where Base: Image { + + func draw(cgImage: CGImage?, to size: CGSize, draw: ()->()) -> Image { + #if os(macOS) + guard let rep = NSBitmapImageRep( + bitmapDataPlanes: nil, + pixelsWide: Int(size.width), + pixelsHigh: Int(size.height), + bitsPerSample: cgImage?.bitsPerComponent ?? 8, + samplesPerPixel: 4, + hasAlpha: true, + isPlanar: false, + colorSpaceName: NSCalibratedRGBColorSpace, + bytesPerRow: 0, + bitsPerPixel: 0) else + { + assertionFailure("[Kingfisher] Image representation cannot be created.") + return base + } + rep.size = size + + NSGraphicsContext.saveGraphicsState() + + let context = NSGraphicsContext(bitmapImageRep: rep) + NSGraphicsContext.setCurrent(context) + draw() + NSGraphicsContext.restoreGraphicsState() + + let outputImage = Image(size: size) + outputImage.addRepresentation(rep) + return outputImage + #else + + UIGraphicsBeginImageContextWithOptions(size, false, scale) + defer { UIGraphicsEndImageContext() } + draw() + return UIGraphicsGetImageFromCurrentImageContext() ?? base + + #endif + } + + #if os(macOS) + func fixedForRetinaPixel(cgImage: CGImage, to size: CGSize) -> Image { + + let image = Image(cgImage: cgImage, size: base.size) + let rect = CGRect(origin: CGPoint(x: 0, y: 0), size: size) + + return draw(cgImage: cgImage, to: self.size) { + image.draw(in: rect, from: NSRect.zero, operation: .copy, fraction: 1.0) + } + } + #endif +} + + +extension CGContext { + static func createARGBContext(from imageRef: CGImage) -> CGContext? { + + let w = imageRef.width + let h = imageRef.height + let bytesPerRow = w * 4 + let colorSpace = CGColorSpaceCreateDeviceRGB() + + let data = malloc(bytesPerRow * h) + defer { + free(data) + } + + let bitmapInfo = imageRef.bitmapInfo.fixed + + // Create the bitmap context. We want pre-multiplied ARGB, 8-bits + // per component. Regardless of what the source image format is + // (CMYK, Grayscale, and so on) it will be converted over to the format + // specified here. + return CGContext(data: data, + width: w, + height: h, + bitsPerComponent: imageRef.bitsPerComponent, + bytesPerRow: bytesPerRow, + space: colorSpace, + bitmapInfo: bitmapInfo.rawValue) + } +} + +extension Double { + var isEven: Bool { + return truncatingRemainder(dividingBy: 2.0) == 0 + } +} + +// MARK: - Deprecated. Only for back compatibility. +extension Image { + /** + Normalize the image. This method does nothing in OS X. + + - returns: The image itself. + */ + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.normalized` instead.", + renamed: "kf.normalized") + public func kf_normalized() -> Image { + return kf.normalized + } + + // MARK: - Round Corner + + /// Create a round corner image based on `self`. + /// + /// - parameter radius: The round corner radius of creating image. + /// - parameter size: The target size of creating image. + /// - parameter scale: The image scale of creating image. + /// + /// - returns: An image with round corner of `self`. + /// + /// - Note: This method only works for CG-based image. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.image(withRoundRadius:fit:scale:)` instead.", + renamed: "kf.image") + public func kf_image(withRoundRadius radius: CGFloat, fit size: CGSize, scale: CGFloat) -> Image { + return kf.image(withRoundRadius: radius, fit: size, scale: scale) + } + + // MARK: - Resize + /// Resize `self` to an image of new size. + /// + /// - parameter size: The target size. + /// + /// - returns: An image with new size. + /// + /// - Note: This method only works for CG-based image. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.resize(to:)` instead.", + renamed: "kf.resize") + public func kf_resize(to size: CGSize) -> Image { + return kf.resize(to: size) + } + + // MARK: - Blur + /// Create an image with blur effect based on `self`. + /// + /// - parameter radius: The blur radius should be used when creating blue. + /// + /// - returns: An image with blur effect applied. + /// + /// - Note: This method only works for CG-based image. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.blurred(withRadius:)` instead.", + renamed: "kf.blurred") + public func kf_blurred(withRadius radius: CGFloat) -> Image { + return kf.blurred(withRadius: radius) + } + + // MARK: - Overlay + /// Create an image from `self` with a color overlay layer. + /// + /// - parameter color: The color should be use to overlay. + /// - parameter fraction: Fraction of input color. From 0.0 to 1.0. 0.0 means solid color, 1.0 means transparent overlay. + /// + /// - returns: An image with a color overlay applied. + /// + /// - Note: This method only works for CG-based image. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.overlaying(with:fraction:)` instead.", + renamed: "kf.overlaying") + public func kf_overlaying(with color: Color, fraction: CGFloat) -> Image { + return kf.overlaying(with: color, fraction: fraction) + } + + // MARK: - Tint + + /// Create an image from `self` with a color tint. + /// + /// - parameter color: The color should be used to tint `self` + /// + /// - returns: An image with a color tint applied. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.tinted(with:)` instead.", + renamed: "kf.tinted") + public func kf_tinted(with color: Color) -> Image { + return kf.tinted(with: color) + } + + // MARK: - Color Control + + /// Create an image from `self` with color control. + /// + /// - parameter brightness: Brightness changing to image. + /// - parameter contrast: Contrast changing to image. + /// - parameter saturation: Saturation changing to image. + /// - parameter inputEV: InputEV changing to image. + /// + /// - returns: An image with color control applied. + @available(*, deprecated, + message: "Extensions directly on Image are deprecated. Use `kf.adjusted` instead.", + renamed: "kf.adjusted") + public func kf_adjusted(brightness: CGFloat, contrast: CGFloat, saturation: CGFloat, inputEV: CGFloat) -> Image { + return kf.adjusted(brightness: brightness, contrast: contrast, saturation: saturation, inputEV: inputEV) + } +} diff --git a/Pods/Kingfisher/Sources/ImageCache.swift b/Pods/Kingfisher/Sources/ImageCache.swift new file mode 100755 index 0000000..bdd9bf5 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageCache.swift @@ -0,0 +1,683 @@ +// +// ImageCache.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +public extension Notification.Name { + /** + This notification will be sent when the disk cache got cleaned either there are cached files expired or the total size exceeding the max allowed size. The manually invoking of `clearDiskCache` method will not trigger this notification. + + The `object` of this notification is the `ImageCache` object which sends the notification. + + A list of removed hashes (files) could be retrieved by accessing the array under `KingfisherDiskCacheCleanedHashKey` key in `userInfo` of the notification object you received. By checking the array, you could know the hash codes of files are removed. + + The main purpose of this notification is supplying a chance to maintain some necessary information on the cached files. See [this wiki](https://github.com/onevcat/Kingfisher/wiki/How-to-implement-ETag-based-304-(Not-Modified)-handling-in-Kingfisher) for a use case on it. + */ + public static var KingfisherDidCleanDiskCache = Notification.Name.init("com.onevcat.Kingfisher.KingfisherDidCleanDiskCache") +} + +/** +Key for array of cleaned hashes in `userInfo` of `KingfisherDidCleanDiskCacheNotification`. +*/ +public let KingfisherDiskCacheCleanedHashKey = "com.onevcat.Kingfisher.cleanedHash" + +/// It represents a task of retrieving image. You can call `cancel` on it to stop the process. +public typealias RetrieveImageDiskTask = DispatchWorkItem + +/** +Cache type of a cached image. + +- None: The image is not cached yet when retrieving it. +- Memory: The image is cached in memory. +- Disk: The image is cached in disk. +*/ +public enum CacheType { + case none, memory, disk +} + +/// `ImageCache` represents both the memory and disk cache system of Kingfisher. +/// While a default image cache object will be used if you prefer the extension methods of Kingfisher, +/// you can create your own cache object and configure it as your need. You could use an `ImageCache` +/// object to manipulate memory and disk cache for Kingfisher. +open class ImageCache { + + //Memory + fileprivate let memoryCache = NSCache() + + /// The largest cache cost of memory cache. The total cost is pixel count of + /// all cached images in memory. + /// Default is unlimited. Memory cache will be purged automatically when a + /// memory warning notification is received. + open var maxMemoryCost: UInt = 0 { + didSet { + self.memoryCache.totalCostLimit = Int(maxMemoryCost) + } + } + + //Disk + fileprivate let ioQueue: DispatchQueue + fileprivate var fileManager: FileManager! + + ///The disk cache location. + open let diskCachePath: String + + /// The default file extension appended to cached files. + open var pathExtension: String? + + /// The longest time duration in second of the cache being stored in disk. + /// Default is 1 week (60 * 60 * 24 * 7 seconds). + open var maxCachePeriodInSecond: TimeInterval = 60 * 60 * 24 * 7 //Cache exists for 1 week + + /// The largest disk size can be taken for the cache. It is the total + /// allocated size of cached files in bytes. + /// Default is no limit. + open var maxDiskCacheSize: UInt = 0 + + fileprivate let processQueue: DispatchQueue + + /// The default cache. + public static let `default` = ImageCache(name: "default") + + /** + Init method. Passing a name for the cache. It represents a cache folder in the memory and disk. + + - parameter name: Name of the cache. It will be used as the memory cache name and the disk cache folder name + appending to the cache path. This value should not be an empty string. + - parameter path: Optional - Location of cache path on disk. If `nil` is passed in (the default value), + the `.cachesDirectory` in of your app will be used. + + - returns: The cache object. + */ + public init(name: String, path: String? = nil) { + + if name.isEmpty { + fatalError("[Kingfisher] You should specify a name for the cache. A cache with empty name is not permitted.") + } + + let cacheName = "com.onevcat.Kingfisher.ImageCache.\(name)" + memoryCache.name = cacheName + + let dstPath = path ?? NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).first! + diskCachePath = (dstPath as NSString).appendingPathComponent(cacheName) + + let ioQueueName = "com.onevcat.Kingfisher.ImageCache.ioQueue.\(name)" + ioQueue = DispatchQueue(label: ioQueueName) + + let processQueueName = "com.onevcat.Kingfisher.ImageCache.processQueue.\(name)" + processQueue = DispatchQueue(label: processQueueName, attributes: .concurrent) + + ioQueue.sync { fileManager = FileManager() } + +#if !os(macOS) && !os(watchOS) + NotificationCenter.default.addObserver( + self, selector: #selector(clearMemoryCache), name: .UIApplicationDidReceiveMemoryWarning, object: nil) + NotificationCenter.default.addObserver( + self, selector: #selector(cleanExpiredDiskCache), name: .UIApplicationWillTerminate, object: nil) + NotificationCenter.default.addObserver( + self, selector: #selector(backgroundCleanExpiredDiskCache), name: .UIApplicationDidEnterBackground, object: nil) +#endif + } + + deinit { + NotificationCenter.default.removeObserver(self) + } +} + +// MARK: - Store & Remove +extension ImageCache { + /** + Store an image to cache. It will be saved to both memory and disk. It is an async operation. + + - parameter image: The image to be stored. + - parameter original: The original data of the image. + Kingfisher will use it to check the format of the image and optimize cache size on disk. + If `nil` is supplied, the image data will be saved as a normalized PNG file. + It is strongly suggested to supply it whenever possible, to get a better performance and disk usage. + - parameter key: Key for the image. + - parameter identifier: The identifier of processor used. If you are using a processor for the image, pass the identifier of + processor to it. + This identifier will be used to generate a corresponding key for the combination of `key` and processor. + - parameter toDisk: Whether this image should be cached to disk or not. If false, the image will be only cached in memory. + - parameter completionHandler: Called when store operation completes. + */ + open func store(_ image: Image, + original: Data? = nil, + forKey key: String, + processorIdentifier identifier: String = "", + cacheSerializer serializer: CacheSerializer = DefaultCacheSerializer.default, + toDisk: Bool = true, + completionHandler: (() -> Void)? = nil) + { + + let computedKey = key.computedKey(with: identifier) + memoryCache.setObject(image, forKey: computedKey as NSString, cost: image.kf.imageCost) + + func callHandlerInMainQueue() { + if let handler = completionHandler { + DispatchQueue.main.async { + handler() + } + } + } + + if toDisk { + ioQueue.async { + + if let data = serializer.data(with: image, original: original) { + if !self.fileManager.fileExists(atPath: self.diskCachePath) { + do { + try self.fileManager.createDirectory(atPath: self.diskCachePath, withIntermediateDirectories: true, attributes: nil) + } catch _ {} + } + + self.fileManager.createFile(atPath: self.cachePath(forComputedKey: computedKey), contents: data, attributes: nil) + } + callHandlerInMainQueue() + } + } else { + callHandlerInMainQueue() + } + } + + /** + Remove the image for key for the cache. It will be opted out from both memory and disk. + It is an async operation. + + - parameter key: Key for the image. + - parameter identifier: The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it. + This identifier will be used to generate a corresponding key for the combination of `key` and processor. + - parameter fromDisk: Whether this image should be removed from disk or not. If false, the image will be only removed from memory. + - parameter completionHandler: Called when removal operation completes. + */ + open func removeImage(forKey key: String, + processorIdentifier identifier: String = "", + fromDisk: Bool = true, + completionHandler: (() -> Void)? = nil) + { + let computedKey = key.computedKey(with: identifier) + memoryCache.removeObject(forKey: computedKey as NSString) + + func callHandlerInMainQueue() { + if let handler = completionHandler { + DispatchQueue.main.async { + handler() + } + } + } + + if fromDisk { + ioQueue.async{ + do { + try self.fileManager.removeItem(atPath: self.cachePath(forComputedKey: computedKey)) + } catch _ {} + callHandlerInMainQueue() + } + } else { + callHandlerInMainQueue() + } + } + +} + +// MARK: - Get data from cache +extension ImageCache { + /** + Get an image for a key from memory or disk. + + - parameter key: Key for the image. + - parameter options: Options of retrieving image. If you need to retrieve an image which was + stored with a specified `ImageProcessor`, pass the processor in the option too. + - parameter completionHandler: Called when getting operation completes with image result and cached type of + this image. If there is no such key cached, the image will be `nil`. + + - returns: The retrieving task. + */ + @discardableResult + open func retrieveImage(forKey key: String, + options: KingfisherOptionsInfo?, + completionHandler: ((Image?, CacheType) -> ())?) -> RetrieveImageDiskTask? + { + // No completion handler. Not start working and early return. + guard let completionHandler = completionHandler else { + return nil + } + + var block: RetrieveImageDiskTask? + let options = options ?? KingfisherEmptyOptionsInfo + + if let image = self.retrieveImageInMemoryCache(forKey: key, options: options) { + options.callbackDispatchQueue.safeAsync { + completionHandler(image, .memory) + } + } else { + var sSelf: ImageCache! = self + block = DispatchWorkItem(block: { + // Begin to load image from disk + if let image = sSelf.retrieveImageInDiskCache(forKey: key, options: options) { + if options.backgroundDecode { + sSelf.processQueue.async { + let result = image.kf.decoded(scale: options.scaleFactor) + + sSelf.store(result, + forKey: key, + processorIdentifier: options.processor.identifier, + cacheSerializer: options.cacheSerializer, + toDisk: false, + completionHandler: nil) + + options.callbackDispatchQueue.safeAsync { + completionHandler(result, .memory) + sSelf = nil + } + } + } else { + sSelf.store(image, + forKey: key, + processorIdentifier: options.processor.identifier, + cacheSerializer: options.cacheSerializer, + toDisk: false, + completionHandler: nil + ) + options.callbackDispatchQueue.safeAsync { + completionHandler(image, .disk) + sSelf = nil + } + } + } else { + // No image found from either memory or disk + options.callbackDispatchQueue.safeAsync { + completionHandler(nil, .none) + sSelf = nil + } + } + }) + + sSelf.ioQueue.async(execute: block!) + } + + return block + } + + /** + Get an image for a key from memory. + + - parameter key: Key for the image. + - parameter options: Options of retrieving image. If you need to retrieve an image which was + stored with a specified `ImageProcessor`, pass the processor in the option too. + - returns: The image object if it is cached, or `nil` if there is no such key in the cache. + */ + open func retrieveImageInMemoryCache(forKey key: String, options: KingfisherOptionsInfo? = nil) -> Image? { + + let options = options ?? KingfisherEmptyOptionsInfo + let computedKey = key.computedKey(with: options.processor.identifier) + + return memoryCache.object(forKey: computedKey as NSString) as? Image + } + + /** + Get an image for a key from disk. + + - parameter key: Key for the image. + - parameter options: Options of retrieving image. If you need to retrieve an image which was + stored with a specified `ImageProcessor`, pass the processor in the option too. + + - returns: The image object if it is cached, or `nil` if there is no such key in the cache. + */ + open func retrieveImageInDiskCache(forKey key: String, options: KingfisherOptionsInfo? = nil) -> Image? { + + let options = options ?? KingfisherEmptyOptionsInfo + let computedKey = key.computedKey(with: options.processor.identifier) + + return diskImage(forComputedKey: computedKey, serializer: options.cacheSerializer, options: options) + } +} + +// MARK: - Clear & Clean +extension ImageCache { + /** + Clear memory cache. + */ + @objc public func clearMemoryCache() { + memoryCache.removeAllObjects() + } + + /** + Clear disk cache. This is an async operation. + + - parameter completionHander: Called after the operation completes. + */ + open func clearDiskCache(completion handler: (()->())? = nil) { + ioQueue.async { + do { + try self.fileManager.removeItem(atPath: self.diskCachePath) + try self.fileManager.createDirectory(atPath: self.diskCachePath, withIntermediateDirectories: true, attributes: nil) + } catch _ { } + + if let handler = handler { + DispatchQueue.main.async { + handler() + } + } + } + } + + /** + Clean expired disk cache. This is an async operation. + */ + @objc fileprivate func cleanExpiredDiskCache() { + cleanExpiredDiskCache(completion: nil) + } + + /** + Clean expired disk cache. This is an async operation. + + - parameter completionHandler: Called after the operation completes. + */ + open func cleanExpiredDiskCache(completion handler: (()->())? = nil) { + + // Do things in cocurrent io queue + ioQueue.async { + + var (URLsToDelete, diskCacheSize, cachedFiles) = self.travelCachedFiles(onlyForCacheSize: false) + + for fileURL in URLsToDelete { + do { + try self.fileManager.removeItem(at: fileURL) + } catch _ { } + } + + if self.maxDiskCacheSize > 0 && diskCacheSize > self.maxDiskCacheSize { + let targetSize = self.maxDiskCacheSize / 2 + + // Sort files by last modify date. We want to clean from the oldest files. + let sortedFiles = cachedFiles.keysSortedByValue { + resourceValue1, resourceValue2 -> Bool in + + if let date1 = resourceValue1.contentAccessDate, + let date2 = resourceValue2.contentAccessDate + { + return date1.compare(date2) == .orderedAscending + } + + // Not valid date information. This should not happen. Just in case. + return true + } + + for fileURL in sortedFiles { + + do { + try self.fileManager.removeItem(at: fileURL) + } catch { } + + URLsToDelete.append(fileURL) + + if let fileSize = cachedFiles[fileURL]?.totalFileAllocatedSize { + diskCacheSize -= UInt(fileSize) + } + + if diskCacheSize < targetSize { + break + } + } + } + + DispatchQueue.main.async { + + if URLsToDelete.count != 0 { + let cleanedHashes = URLsToDelete.map { $0.lastPathComponent } + NotificationCenter.default.post(name: .KingfisherDidCleanDiskCache, object: self, userInfo: [KingfisherDiskCacheCleanedHashKey: cleanedHashes]) + } + + handler?() + } + } + } + + fileprivate func travelCachedFiles(onlyForCacheSize: Bool) -> (urlsToDelete: [URL], diskCacheSize: UInt, cachedFiles: [URL: URLResourceValues]) { + + let diskCacheURL = URL(fileURLWithPath: diskCachePath) + let resourceKeys: Set = [.isDirectoryKey, .contentAccessDateKey, .totalFileAllocatedSizeKey] + let expiredDate = Date(timeIntervalSinceNow: -maxCachePeriodInSecond) + + var cachedFiles = [URL: URLResourceValues]() + var urlsToDelete = [URL]() + var diskCacheSize: UInt = 0 + + if let fileEnumerator = self.fileManager.enumerator(at: diskCacheURL, includingPropertiesForKeys: Array(resourceKeys), options: FileManager.DirectoryEnumerationOptions.skipsHiddenFiles, errorHandler: nil), + let urls = fileEnumerator.allObjects as? [URL] + { + for fileUrl in urls { + + do { + let resourceValues = try fileUrl.resourceValues(forKeys: resourceKeys) + // If it is a Directory. Continue to next file URL. + if resourceValues.isDirectory == true { + continue + } + + if !onlyForCacheSize { + // If this file is expired, add it to URLsToDelete + if let lastAccessData = resourceValues.contentAccessDate { + if (lastAccessData as NSDate).laterDate(expiredDate) == expiredDate { + urlsToDelete.append(fileUrl) + continue + } + } + } + + if let fileSize = resourceValues.totalFileAllocatedSize { + diskCacheSize += UInt(fileSize) + if !onlyForCacheSize { + cachedFiles[fileUrl] = resourceValues + } + } + } catch _ { } + } + } + + return (urlsToDelete, diskCacheSize, cachedFiles) + } + +#if !os(macOS) && !os(watchOS) + /** + Clean expired disk cache when app in background. This is an async operation. + In most cases, you should not call this method explicitly. + It will be called automatically when `UIApplicationDidEnterBackgroundNotification` received. + */ + @objc public func backgroundCleanExpiredDiskCache() { + // if 'sharedApplication()' is unavailable, then return + guard let sharedApplication = Kingfisher.shared else { return } + + func endBackgroundTask(_ task: inout UIBackgroundTaskIdentifier) { + sharedApplication.endBackgroundTask(task) + task = UIBackgroundTaskInvalid + } + + var backgroundTask: UIBackgroundTaskIdentifier! + backgroundTask = sharedApplication.beginBackgroundTask { + endBackgroundTask(&backgroundTask!) + } + + cleanExpiredDiskCache { + endBackgroundTask(&backgroundTask!) + } + } +#endif +} + + +// MARK: - Check cache status +extension ImageCache { + + /** + * Cache result for checking whether an image is cached for a key. + */ + public struct CacheCheckResult { + public let cached: Bool + public let cacheType: CacheType? + } + + /** + Check whether an image is cached for a key. + + - parameter key: Key for the image. + + - returns: The check result. + */ + open func isImageCached(forKey key: String, processorIdentifier identifier: String = "") -> CacheCheckResult { + + let computedKey = key.computedKey(with: identifier) + + if memoryCache.object(forKey: computedKey as NSString) != nil { + return CacheCheckResult(cached: true, cacheType: .memory) + } + + let filePath = cachePath(forComputedKey: computedKey) + + var diskCached = false + ioQueue.sync { + diskCached = fileManager.fileExists(atPath: filePath) + } + + if diskCached { + return CacheCheckResult(cached: true, cacheType: .disk) + } + + return CacheCheckResult(cached: false, cacheType: nil) + } + + /** + Get the hash for the key. This could be used for matching files. + + - parameter key: The key which is used for caching. + - parameter identifier: The identifier of processor used. If you are using a processor for the image, pass the identifier of processor to it. + + - returns: Corresponding hash. + */ + open func hash(forKey key: String, processorIdentifier identifier: String = "") -> String { + let computedKey = key.computedKey(with: identifier) + return cacheFileName(forComputedKey: computedKey) + } + + /** + Calculate the disk size taken by cache. + It is the total allocated size of the cached files in bytes. + + - parameter completionHandler: Called with the calculated size when finishes. + */ + open func calculateDiskCacheSize(completion handler: @escaping ((_ size: UInt) -> ())) { + ioQueue.async { + let (_, diskCacheSize, _) = self.travelCachedFiles(onlyForCacheSize: true) + DispatchQueue.main.async { + handler(diskCacheSize) + } + } + } + + /** + Get the cache path for the key. + It is useful for projects with UIWebView or anyone that needs access to the local file path. + + i.e. Replace the `` tag in your HTML. + + - Note: This method does not guarantee there is an image already cached in the path. It just returns the path + that the image should be. + You could use `isImageCached(forKey:)` method to check whether the image is cached under that key. + */ + open func cachePath(forKey key: String, processorIdentifier identifier: String = "") -> String { + let computedKey = key.computedKey(with: identifier) + return cachePath(forComputedKey: computedKey) + } + + func cachePath(forComputedKey key: String) -> String { + let fileName = cacheFileName(forComputedKey: key) + return (diskCachePath as NSString).appendingPathComponent(fileName) + } +} + +// MARK: - Internal Helper +extension ImageCache { + + func diskImage(forComputedKey key: String, serializer: CacheSerializer, options: KingfisherOptionsInfo) -> Image? { + if let data = diskImageData(forComputedKey: key) { + return serializer.image(with: data, options: options) + } else { + return nil + } + } + + func diskImageData(forComputedKey key: String) -> Data? { + let filePath = cachePath(forComputedKey: key) + return (try? Data(contentsOf: URL(fileURLWithPath: filePath))) + } + + func cacheFileName(forComputedKey key: String) -> String { + if let ext = self.pathExtension { + return (key.kf.md5 as NSString).appendingPathExtension(ext)! + } + return key.kf.md5 + } +} + +extension Kingfisher where Base: Image { + var imageCost: Int { + return images == nil ? + Int(size.height * size.width * scale * scale) : + Int(size.height * size.width * scale * scale) * images!.count + } +} + +extension Dictionary { + func keysSortedByValue(_ isOrderedBefore: (Value, Value) -> Bool) -> [Key] { + return Array(self).sorted{ isOrderedBefore($0.1, $1.1) }.map{ $0.0 } + } +} + +#if !os(macOS) && !os(watchOS) +// MARK: - For App Extensions +extension UIApplication: KingfisherCompatible { } +extension Kingfisher where Base: UIApplication { + public static var shared: UIApplication? { + let selector = NSSelectorFromString("sharedApplication") + guard Base.responds(to: selector) else { return nil } + return Base.perform(selector).takeUnretainedValue() as? UIApplication + } +} +#endif + +extension String { + func computedKey(with identifier: String) -> String { + if identifier.isEmpty { + return self + } else { + return appending("@\(identifier)") + } + } +} diff --git a/Pods/Kingfisher/Sources/ImageDownloader.swift b/Pods/Kingfisher/Sources/ImageDownloader.swift new file mode 100755 index 0000000..e7b25f2 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageDownloader.swift @@ -0,0 +1,538 @@ +// +// ImageDownloader.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +/// Progress update block of downloader. +public typealias ImageDownloaderProgressBlock = DownloadProgressBlock + +/// Completion block of downloader. +public typealias ImageDownloaderCompletionHandler = ((_ image: Image?, _ error: NSError?, _ url: URL?, _ originalData: Data?) -> ()) + +/// Download task. +public struct RetrieveImageDownloadTask { + let internalTask: URLSessionDataTask + + /// Downloader by which this task is intialized. + public private(set) weak var ownerDownloader: ImageDownloader? + + /** + Cancel this download task. It will trigger the completion handler with an NSURLErrorCancelled error. + */ + public func cancel() { + ownerDownloader?.cancelDownloadingTask(self) + } + + /// The original request URL of this download task. + public var url: URL? { + return internalTask.originalRequest?.url + } + + /// The relative priority of this download task. + /// It represents the `priority` property of the internal `NSURLSessionTask` of this download task. + /// The value for it is between 0.0~1.0. Default priority is value of 0.5. + /// See documentation on `priority` of `NSURLSessionTask` for more about it. + public var priority: Float { + get { + return internalTask.priority + } + set { + internalTask.priority = newValue + } + } +} + +///The code of errors which `ImageDownloader` might encountered. +public enum KingfisherError: Int { + + /// badData: The downloaded data is not an image or the data is corrupted. + case badData = 10000 + + /// notModified: The remote server responsed a 304 code. No image data downloaded. + case notModified = 10001 + + /// The HTTP status code in response is not valid. If an invalid + /// code error received, you could check the value under `KingfisherErrorStatusCodeKey` + /// in `userInfo` to see the code. + case invalidStatusCode = 10002 + + /// notCached: The image rquested is not in cache but .onlyFromCache is activated. + case notCached = 10003 + + /// The URL is invalid. + case invalidURL = 20000 + + /// The downloading task is cancelled before started. + case downloadCanelledBeforeStarting = 30000 +} + +/// Key will be used in the `userInfo` of `.invalidStatusCode` +public let KingfisherErrorStatusCodeKey = "statusCode" + +/// Protocol of `ImageDownloader`. +public protocol ImageDownloaderDelegate: class { + /** + Called when the `ImageDownloader` object successfully downloaded an image from specified URL. + + - parameter downloader: The `ImageDownloader` object finishes the downloading. + - parameter image: Downloaded image. + - parameter url: URL of the original request URL. + - parameter response: The response object of the downloading process. + */ + func imageDownloader(_ downloader: ImageDownloader, didDownload image: Image, for url: URL, with response: URLResponse?) + + + /** + Check if a received HTTP status code is valid or not. + By default, a status code between 200 to 400 (excluded) is considered as valid. + If an invalid code is received, the downloader will raise an .invalidStatusCode error. + It has a `userInfo` which includes this statusCode and localizedString error message. + + - parameter code: The received HTTP status code. + - parameter downloader: The `ImageDownloader` object asking for validate status code. + + - returns: Whether this HTTP status code is valid or not. + + - Note: If the default 200 to 400 valid code does not suit your need, + you can implement this method to change that behavior. + */ + func isValidStatusCode(_ code: Int, for downloader: ImageDownloader) -> Bool +} + +extension ImageDownloaderDelegate { + public func imageDownloader(_ downloader: ImageDownloader, didDownload image: Image, for url: URL, with response: URLResponse?) {} + + public func isValidStatusCode(_ code: Int, for downloader: ImageDownloader) -> Bool { + return (200..<400).contains(code) + } +} + +/// Protocol indicates that an authentication challenge could be handled. +public protocol AuthenticationChallengeResponsable: class { + /** + Called when an session level authentication challenge is received. + This method provide a chance to handle and response to the authentication challenge before downloading could start. + + - parameter downloader: The downloader which receives this challenge. + - parameter challenge: An object that contains the request for authentication. + - parameter completionHandler: A handler that your delegate method must call. + + - Note: This method is a forward from `URLSession(:didReceiveChallenge:completionHandler:)`. Please refer to the document of it in `NSURLSessionDelegate`. + */ + func downloader(_ downloader: ImageDownloader, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) +} + +extension AuthenticationChallengeResponsable { + + func downloader(_ downloader: ImageDownloader, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { + + if challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust { + if let trustedHosts = downloader.trustedHosts, trustedHosts.contains(challenge.protectionSpace.host) { + let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!) + completionHandler(.useCredential, credential) + return + } + } + + completionHandler(.performDefaultHandling, nil) + } +} + +/// `ImageDownloader` represents a downloading manager for requesting the image with a URL from server. +open class ImageDownloader: NSObject { + + class ImageFetchLoad { + var contents = [(callback: CallbackPair, options: KingfisherOptionsInfo)]() + var responseData = NSMutableData() + + var downloadTaskCount = 0 + var downloadTask: RetrieveImageDownloadTask? + } + + // MARK: - Public property + /// This closure will be applied to the image download request before it being sent. + /// You can modify the request for some customizing purpose, like adding auth token to the header, do basic HTTP auth or something like url mapping. + @available(*, unavailable, message: "`requestModifier` is removed. Use 'urlRequest(for:byModifying:)' from the 'ImageDownloaderDelegate' instead") + open var requestModifier: ((inout URLRequest) -> Void)? + + /// The duration before the download is timeout. Default is 15 seconds. + open var downloadTimeout: TimeInterval = 15.0 + + /// A set of trusted hosts when receiving server trust challenges. A challenge with host name contained in this set will be ignored. + /// You can use this set to specify the self-signed site. It only will be used if you don't specify the `authenticationChallengeResponder`. + /// If `authenticationChallengeResponder` is set, this property will be ignored and the implemention of `authenticationChallengeResponder` will be used instead. + open var trustedHosts: Set? + + /// Use this to set supply a configuration for the downloader. By default, NSURLSessionConfiguration.ephemeralSessionConfiguration() will be used. + /// You could change the configuration before a downloaing task starts. A configuration without persistent storage for caches is requsted for downloader working correctly. + open var sessionConfiguration = URLSessionConfiguration.ephemeral { + didSet { + session = URLSession(configuration: sessionConfiguration, delegate: sessionHandler, delegateQueue: OperationQueue.main) + } + } + + /// Whether the download requests should use pipeling or not. Default is false. + open var requestsUsePipeling = false + + fileprivate let sessionHandler: ImageDownloaderSessionHandler + fileprivate var session: URLSession? + + /// Delegate of this `ImageDownloader` object. See `ImageDownloaderDelegate` protocol for more. + open weak var delegate: ImageDownloaderDelegate? + + /// A responder for authentication challenge. + /// Downloader will forward the received authentication challenge for the downloading session to this responder. + open weak var authenticationChallengeResponder: AuthenticationChallengeResponsable? + + // MARK: - Internal property + let barrierQueue: DispatchQueue + let processQueue: DispatchQueue + + typealias CallbackPair = (progressBlock: ImageDownloaderProgressBlock?, completionHandler: ImageDownloaderCompletionHandler?) + + var fetchLoads = [URL: ImageFetchLoad]() + + // MARK: - Public method + /// The default downloader. + public static let `default` = ImageDownloader(name: "default") + + /** + Init a downloader with name. + + - parameter name: The name for the downloader. It should not be empty. + + - returns: The downloader object. + */ + public init(name: String) { + if name.isEmpty { + fatalError("[Kingfisher] You should specify a name for the downloader. A downloader with empty name is not permitted.") + } + + barrierQueue = DispatchQueue(label: "com.onevcat.Kingfisher.ImageDownloader.Barrier.\(name)", attributes: .concurrent) + processQueue = DispatchQueue(label: "com.onevcat.Kingfisher.ImageDownloader.Process.\(name)", attributes: .concurrent) + + sessionHandler = ImageDownloaderSessionHandler() + + super.init() + + // Provide a default implement for challenge responder. + authenticationChallengeResponder = sessionHandler + session = URLSession(configuration: sessionConfiguration, delegate: sessionHandler, delegateQueue: .main) + } + + func fetchLoad(for url: URL) -> ImageFetchLoad? { + var fetchLoad: ImageFetchLoad? + barrierQueue.sync { fetchLoad = fetchLoads[url] } + return fetchLoad + } +} + +// MARK: - Download method +extension ImageDownloader { + /** + Download an image with a URL and option. + + - parameter url: Target URL. + - parameter options: The options could control download behavior. See `KingfisherOptionsInfo`. + - parameter progressBlock: Called when the download progress updated. + - parameter completionHandler: Called when the download progress finishes. + + - returns: A downloading task. You could call `cancel` on it to stop the downloading process. + */ + @discardableResult + open func downloadImage(with url: URL, + options: KingfisherOptionsInfo? = nil, + progressBlock: ImageDownloaderProgressBlock? = nil, + completionHandler: ImageDownloaderCompletionHandler? = nil) -> RetrieveImageDownloadTask? + { + return downloadImage(with: url, + retrieveImageTask: nil, + options: options, + progressBlock: progressBlock, + completionHandler: completionHandler) + } + + func downloadImage(with url: URL, + retrieveImageTask: RetrieveImageTask?, + options: KingfisherOptionsInfo?, + progressBlock: ImageDownloaderProgressBlock?, + completionHandler: ImageDownloaderCompletionHandler?) -> RetrieveImageDownloadTask? + { + if let retrieveImageTask = retrieveImageTask, retrieveImageTask.cancelledBeforeDownloadStarting { + return nil + } + + let timeout = self.downloadTimeout == 0.0 ? 15.0 : self.downloadTimeout + + // We need to set the URL as the load key. So before setup progress, we need to ask the `requestModifier` for a final URL. + var request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalCacheData, timeoutInterval: timeout) + request.httpShouldUsePipelining = requestsUsePipeling + + if let modifier = options?.modifier { + guard let r = modifier.modified(for: request) else { + completionHandler?(nil, NSError(domain: KingfisherErrorDomain, code: KingfisherError.downloadCanelledBeforeStarting.rawValue, userInfo: nil), nil, nil) + return nil + } + request = r + } + + // There is a possiblility that request modifier changed the url to `nil` or empty. + guard let url = request.url, !url.absoluteString.isEmpty else { + completionHandler?(nil, NSError(domain: KingfisherErrorDomain, code: KingfisherError.invalidURL.rawValue, userInfo: nil), nil, nil) + return nil + } + + var downloadTask: RetrieveImageDownloadTask? + setup(progressBlock: progressBlock, with: completionHandler, for: url, options: options) {(session, fetchLoad) -> Void in + if fetchLoad.downloadTask == nil { + let dataTask = session.dataTask(with: request) + + fetchLoad.downloadTask = RetrieveImageDownloadTask(internalTask: dataTask, ownerDownloader: self) + + dataTask.priority = options?.downloadPriority ?? URLSessionTask.defaultPriority + dataTask.resume() + + // Hold self while the task is executing. + self.sessionHandler.downloadHolder = self + } + + fetchLoad.downloadTaskCount += 1 + downloadTask = fetchLoad.downloadTask + + retrieveImageTask?.downloadTask = downloadTask + } + return downloadTask + } + + // A single key may have multiple callbacks. Only download once. + func setup(progressBlock: ImageDownloaderProgressBlock?, with completionHandler: ImageDownloaderCompletionHandler?, for url: URL, options: KingfisherOptionsInfo?, started: ((URLSession, ImageFetchLoad) -> Void)) { + + barrierQueue.sync(flags: .barrier) { + let loadObjectForURL = fetchLoads[url] ?? ImageFetchLoad() + let callbackPair = (progressBlock: progressBlock, completionHandler: completionHandler) + + loadObjectForURL.contents.append((callbackPair, options ?? KingfisherEmptyOptionsInfo)) + + fetchLoads[url] = loadObjectForURL + + if let session = session { + started(session, loadObjectForURL) + } + } + } + + func cancelDownloadingTask(_ task: RetrieveImageDownloadTask) { + barrierQueue.sync { + if let URL = task.internalTask.originalRequest?.url, let imageFetchLoad = self.fetchLoads[URL] { + imageFetchLoad.downloadTaskCount -= 1 + if imageFetchLoad.downloadTaskCount == 0 { + task.internalTask.cancel() + } + } + } + } + + func clean(for url: URL) { + barrierQueue.sync(flags: .barrier) { + fetchLoads.removeValue(forKey: url) + return + } + } +} + +// MARK: - NSURLSessionDataDelegate + +/// Delegate class for `NSURLSessionTaskDelegate`. +/// The session object will hold its delegate until it gets invalidated. +/// If we use `ImageDownloader` as the session delegate, it will not be released. +/// So we need an additional handler to break the retain cycle. +// See https://github.com/onevcat/Kingfisher/issues/235 +class ImageDownloaderSessionHandler: NSObject, URLSessionDataDelegate, AuthenticationChallengeResponsable { + + // The holder will keep downloader not released while a data task is being executed. + // It will be set when the task started, and reset when the task finished. + var downloadHolder: ImageDownloader? + + func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) { + + guard let downloader = downloadHolder else { + completionHandler(.cancel) + return + } + + if let statusCode = (response as? HTTPURLResponse)?.statusCode, + let url = dataTask.originalRequest?.url, + !(downloader.delegate ?? downloader).isValidStatusCode(statusCode, for: downloader) + { + let error = NSError(domain: KingfisherErrorDomain, + code: KingfisherError.invalidStatusCode.rawValue, + userInfo: [KingfisherErrorStatusCodeKey: statusCode, NSLocalizedDescriptionKey: HTTPURLResponse.localizedString(forStatusCode: statusCode)]) + callCompletionHandlerFailure(error: error, url: url) + } + + completionHandler(.allow) + } + + func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) { + + guard let downloader = downloadHolder else { + return + } + + if let url = dataTask.originalRequest?.url, let fetchLoad = downloader.fetchLoad(for: url) { + fetchLoad.responseData.append(data) + + if let expectedLength = dataTask.response?.expectedContentLength { + for content in fetchLoad.contents { + DispatchQueue.main.async { + content.callback.progressBlock?(Int64(fetchLoad.responseData.length), expectedLength) + } + } + } + } + } + + func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { + + guard let url = task.originalRequest?.url else { + return + } + + guard error == nil else { + callCompletionHandlerFailure(error: error!, url: url) + return + } + + processImage(for: task, url: url) + } + + /** + This method is exposed since the compiler requests. Do not call it. + */ + func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) { + guard let downloader = downloadHolder else { + return + } + + downloader.authenticationChallengeResponder?.downloader(downloader, didReceive: challenge, completionHandler: completionHandler) + } + + private func cleanFetchLoad(for url: URL) { + guard let downloader = downloadHolder else { + return + } + + downloader.clean(for: url) + + if downloader.fetchLoads.isEmpty { + downloadHolder = nil + } + } + + private func callCompletionHandlerFailure(error: Error, url: URL) { + guard let downloader = downloadHolder, let fetchLoad = downloader.fetchLoad(for: url) else { + return + } + + // We need to clean the fetch load first, before actually calling completion handler. + cleanFetchLoad(for: url) + + for content in fetchLoad.contents { + content.options.callbackDispatchQueue.safeAsync { + content.callback.completionHandler?(nil, error as NSError, url, nil) + } + } + } + + private func processImage(for task: URLSessionTask, url: URL) { + + guard let downloader = downloadHolder else { + return + } + + // We are on main queue when receiving this. + downloader.processQueue.async { + + guard let fetchLoad = downloader.fetchLoad(for: url) else { + return + } + + self.cleanFetchLoad(for: url) + + let data = fetchLoad.responseData as Data + + // Cache the processed images. So we do not need to re-process the image if using the same processor. + // Key is the identifier of processor. + var imageCache: [String: Image] = [:] + for content in fetchLoad.contents { + + let options = content.options + let completionHandler = content.callback.completionHandler + let callbackQueue = options.callbackDispatchQueue + + let processoor = options.processor + + var image = imageCache[processoor.identifier] + if image == nil { + image = processoor.process(item: .data(data), options: options) + + // Add the processed image to cache. + // If `image` is nil, nothing will happen (since the key is not existing before). + imageCache[processoor.identifier] = image + } + + if let image = image { + + downloader.delegate?.imageDownloader(downloader, didDownload: image, for: url, with: task.response) + + if options.backgroundDecode { + let decodedImage = image.kf.decoded(scale: options.scaleFactor) + callbackQueue.safeAsync { completionHandler?(decodedImage, nil, url, data) } + } else { + callbackQueue.safeAsync { completionHandler?(image, nil, url, data) } + } + + } else { + if let res = task.response as? HTTPURLResponse , res.statusCode == 304 { + let notModified = NSError(domain: KingfisherErrorDomain, code: KingfisherError.notModified.rawValue, userInfo: nil) + completionHandler?(nil, notModified, url, nil) + continue + } + + let badData = NSError(domain: KingfisherErrorDomain, code: KingfisherError.badData.rawValue, userInfo: nil) + callbackQueue.safeAsync { completionHandler?(nil, badData, url, nil) } + } + } + } + } +} + +// Placeholder. For retrieving extension methods of ImageDownloaderDelegate +extension ImageDownloader: ImageDownloaderDelegate {} diff --git a/Pods/Kingfisher/Sources/ImagePrefetcher.swift b/Pods/Kingfisher/Sources/ImagePrefetcher.swift new file mode 100755 index 0000000..f699700 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImagePrefetcher.swift @@ -0,0 +1,267 @@ +// +// ImagePrefetcher.swift +// Kingfisher +// +// Created by Claire Knight on 24/02/2016 +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + + +#if os(macOS) + import AppKit +#else + import UIKit +#endif + + +/// Progress update block of prefetcher. +/// +/// - `skippedResources`: An array of resources that are already cached before the prefetching starting. +/// - `failedResources`: An array of resources that fail to be downloaded. It could because of being cancelled while downloading, encountered an error when downloading or the download not being started at all. +/// - `completedResources`: An array of resources that are downloaded and cached successfully. +public typealias PrefetcherProgressBlock = ((_ skippedResources: [Resource], _ failedResources: [Resource], _ completedResources: [Resource]) -> ()) + +/// Completion block of prefetcher. +/// +/// - `skippedResources`: An array of resources that are already cached before the prefetching starting. +/// - `failedResources`: An array of resources that fail to be downloaded. It could because of being cancelled while downloading, encountered an error when downloading or the download not being started at all. +/// - `completedResources`: An array of resources that are downloaded and cached successfully. +public typealias PrefetcherCompletionHandler = ((_ skippedResources: [Resource], _ failedResources: [Resource], _ completedResources: [Resource]) -> ()) + +/// `ImagePrefetcher` represents a downloading manager for requesting many images via URLs, then caching them. +/// This is useful when you know a list of image resources and want to download them before showing. +public class ImagePrefetcher { + + /// The maximum concurrent downloads to use when prefetching images. Default is 5. + public var maxConcurrentDownloads = 5 + + private let prefetchResources: [Resource] + private let optionsInfo: KingfisherOptionsInfo + private var progressBlock: PrefetcherProgressBlock? + private var completionHandler: PrefetcherCompletionHandler? + + private var tasks = [URL: RetrieveImageDownloadTask]() + + private var pendingResources: ArraySlice + private var skippedResources = [Resource]() + private var completedResources = [Resource]() + private var failedResources = [Resource]() + + private var stopped = false + + // The created manager used for prefetch. We will use the helper method in manager. + private let manager: KingfisherManager + + private var finished: Bool { + return failedResources.count + skippedResources.count + completedResources.count == prefetchResources.count && self.tasks.isEmpty + } + + /** + Init an image prefetcher with an array of URLs. + + The prefetcher should be initiated with a list of prefetching targets. The URLs list is immutable. + After you get a valid `ImagePrefetcher` object, you could call `start()` on it to begin the prefetching process. + The images already cached will be skipped without downloading again. + + - parameter urls: The URLs which should be prefetched. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called every time an resource is downloaded, skipped or cancelled. + - parameter completionHandler: Called when the whole prefetching process finished. + + - returns: An `ImagePrefetcher` object. + + - Note: By default, the `ImageDownloader.defaultDownloader` and `ImageCache.defaultCache` will be used as + the downloader and cache target respectively. You can specify another downloader or cache by using a customized `KingfisherOptionsInfo`. + Both the progress and completion block will be invoked in main thread. The `CallbackDispatchQueue` in `optionsInfo` will be ignored in this method. + */ + public convenience init(urls: [URL], + options: KingfisherOptionsInfo? = nil, + progressBlock: PrefetcherProgressBlock? = nil, + completionHandler: PrefetcherCompletionHandler? = nil) + { + let resources: [Resource] = urls.map { $0 } + self.init(resources: resources, options: options, progressBlock: progressBlock, completionHandler: completionHandler) + } + + /** + Init an image prefetcher with an array of resources. + + The prefetcher should be initiated with a list of prefetching targets. The resources list is immutable. + After you get a valid `ImagePrefetcher` object, you could call `start()` on it to begin the prefetching process. + The images already cached will be skipped without downloading again. + + - parameter resources: The resources which should be prefetched. See `Resource` type for more. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called every time an resource is downloaded, skipped or cancelled. + - parameter completionHandler: Called when the whole prefetching process finished. + + - returns: An `ImagePrefetcher` object. + + - Note: By default, the `ImageDownloader.defaultDownloader` and `ImageCache.defaultCache` will be used as + the downloader and cache target respectively. You can specify another downloader or cache by using a customized `KingfisherOptionsInfo`. + Both the progress and completion block will be invoked in main thread. The `CallbackDispatchQueue` in `optionsInfo` will be ignored in this method. + */ + public init(resources: [Resource], + options: KingfisherOptionsInfo? = nil, + progressBlock: PrefetcherProgressBlock? = nil, + completionHandler: PrefetcherCompletionHandler? = nil) + { + prefetchResources = resources + pendingResources = ArraySlice(resources) + + // We want all callbacks from main queue, so we ignore the call back queue in options + let optionsInfoWithoutQueue = options?.removeAllMatchesIgnoringAssociatedValue(.callbackDispatchQueue(nil)) + self.optionsInfo = optionsInfoWithoutQueue ?? KingfisherEmptyOptionsInfo + + let cache = self.optionsInfo.targetCache + let downloader = self.optionsInfo.downloader + manager = KingfisherManager(downloader: downloader, cache: cache) + + self.progressBlock = progressBlock + self.completionHandler = completionHandler + } + + /** + Start to download the resources and cache them. This can be useful for background downloading + of assets that are required for later use in an app. This code will not try and update any UI + with the results of the process. + */ + public func start() + { + // Since we want to handle the resources cancellation in main thread only. + DispatchQueue.main.safeAsync { + + guard !self.stopped else { + assertionFailure("You can not restart the same prefetcher. Try to create a new prefetcher.") + self.handleComplete() + return + } + + guard self.maxConcurrentDownloads > 0 else { + assertionFailure("There should be concurrent downloads value should be at least 1.") + self.handleComplete() + return + } + + guard self.prefetchResources.count > 0 else { + self.handleComplete() + return + } + + let initialConcurentDownloads = min(self.prefetchResources.count, self.maxConcurrentDownloads) + for _ in 0 ..< initialConcurentDownloads { + if let resource = self.pendingResources.popFirst() { + self.startPrefetching(resource) + } + } + } + } + + + /** + Stop current downloading progress, and cancel any future prefetching activity that might be occuring. + */ + public func stop() { + DispatchQueue.main.safeAsync { + + if self.finished { return } + + self.stopped = true + self.tasks.forEach { (_, task) -> () in + task.cancel() + } + } + } + + func downloadAndCache(_ resource: Resource) { + + let downloadTaskCompletionHandler: CompletionHandler = { (image, error, _, _) -> () in + self.tasks.removeValue(forKey: resource.downloadURL) + if let _ = error { + self.failedResources.append(resource) + } else { + self.completedResources.append(resource) + } + + self.reportProgress() + if self.stopped { + if self.tasks.isEmpty { + self.failedResources.append(contentsOf: self.pendingResources) + self.handleComplete() + } + } else { + self.reportCompletionOrStartNext() + } + } + + let downloadTask = manager.downloadAndCacheImage( + with: resource.downloadURL, + forKey: resource.cacheKey, + retrieveImageTask: RetrieveImageTask(), + progressBlock: nil, + completionHandler: downloadTaskCompletionHandler, + options: optionsInfo) + + if let downloadTask = downloadTask { + tasks[resource.downloadURL] = downloadTask + } + } + + func append(cached resource: Resource) { + skippedResources.append(resource) + + reportProgress() + reportCompletionOrStartNext() + } + + func startPrefetching(_ resource: Resource) + { + if optionsInfo.forceRefresh { + downloadAndCache(resource) + } else { + let alreadyInCache = manager.cache.isImageCached(forKey: resource.cacheKey).cached + if alreadyInCache { + append(cached: resource) + } else { + downloadAndCache(resource) + } + } + } + + func reportProgress() { + progressBlock?(skippedResources, failedResources, completedResources) + } + + func reportCompletionOrStartNext() { + if let resource = pendingResources.popFirst() { + startPrefetching(resource) + } else { + guard tasks.isEmpty else { return } + handleComplete() + } + } + + func handleComplete() { + completionHandler?(skippedResources, failedResources, completedResources) + completionHandler = nil + progressBlock = nil + } +} diff --git a/Pods/Kingfisher/Sources/ImageProcessor.swift b/Pods/Kingfisher/Sources/ImageProcessor.swift new file mode 100644 index 0000000..de93a1c --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageProcessor.swift @@ -0,0 +1,365 @@ +// +// ImageProcessor.swift +// Kingfisher +// +// Created by Wei Wang on 2016/08/26. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +import Foundation +import CoreGraphics + + +/// The item which could be processed by an `ImageProcessor` +/// +/// - image: Input image +/// - data: Input data +public enum ImageProcessItem { + case image(Image) + case data(Data) +} + +/// An `ImageProcessor` would be used to convert some downloaded data to an image. +public protocol ImageProcessor { + /// Identifier of the processor. It will be used to identify the processor when + /// caching and retriving an image. You might want to make sure that processors with + /// same properties/functionality have the same identifiers, so correct processed images + /// could be retrived with proper key. + /// + /// - Note: Do not supply an empty string for a customized processor, which is already taken by + /// the `DefaultImageProcessor`. It is recommended to use a reverse domain name notation + /// string of your own for the identifier. + var identifier: String { get } + + /// Process an input `ImageProcessItem` item to an image for this processor. + /// + /// - parameter item: Input item which will be processed by `self` + /// - parameter options: Options when processing the item. + /// + /// - returns: The processed image. + /// + /// - Note: The return value will be `nil` if processing failed while converting data to image. + /// If input item is already an image and there is any errors in processing, the input + /// image itself will be returned. + /// - Note: Most processor only supports CG-based images. + /// watchOS is not supported for processers containing filter, the input image will be returned directly on watchOS. + func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? +} + +typealias ProcessorImp = ((ImageProcessItem, KingfisherOptionsInfo) -> Image?) + +public extension ImageProcessor { + + /// Append an `ImageProcessor` to another. The identifier of the new `ImageProcessor` + /// will be "\(self.identifier)|>\(another.identifier)>". + /// + /// - parameter another: An `ImageProcessor` you want to append to `self`. + /// + /// - returns: The new `ImageProcessor`. It will process the image in the order + /// of the two processors concatenated. + public func append(another: ImageProcessor) -> ImageProcessor { + let newIdentifier = identifier.appending("|>\(another.identifier)") + return GeneralProcessor(identifier: newIdentifier) { + item, options in + if let image = self.process(item: item, options: options) { + return another.process(item: .image(image), options: options) + } else { + return nil + } + } + } +} + +fileprivate struct GeneralProcessor: ImageProcessor { + let identifier: String + let p: ProcessorImp + func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + return p(item, options) + } +} + +/// The default processor. It convert the input data to a valid image. +/// Images of .PNG, .JPEG and .GIF format are supported. +/// If an image is given, `DefaultImageProcessor` will do nothing on it and just return that image. +public struct DefaultImageProcessor: ImageProcessor { + + /// A default `DefaultImageProcessor` could be used across. + public static let `default` = DefaultImageProcessor() + + public let identifier = "" + + /// Initialize a `DefaultImageProcessor` + /// + /// - returns: An initialized `DefaultImageProcessor`. + public init() {} + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image + case .data(let data): + return Kingfisher.image(data: data, scale: options.scaleFactor, preloadAllGIFData: options.preloadAllGIFData) + } + } +} + +/// Processor for making round corner images. Only CG-based images are supported in macOS, +/// if a non-CG image passed in, the processor will do nothing. +public struct RoundCornerImageProcessor: ImageProcessor { + public let identifier: String + + /// Corner radius will be applied in processing. + public let cornerRadius: CGFloat + + /// Target size of output image should be. If `nil`, the image will keep its original size after processing. + public let targetSize: CGSize? + + /// Initialize a `RoundCornerImageProcessor` + /// + /// - parameter cornerRadius: Corner radius will be applied in processing. + /// - parameter targetSize: Target size of output image should be. If `nil`, + /// the image will keep its original size after processing. + /// Default is `nil`. + /// + /// - returns: An initialized `RoundCornerImageProcessor`. + public init(cornerRadius: CGFloat, targetSize: CGSize? = nil) { + self.cornerRadius = cornerRadius + self.targetSize = targetSize + if let size = targetSize { + self.identifier = "com.onevcat.Kingfisher.RoundCornerImageProcessor(\(cornerRadius)_\(size))" + } else { + self.identifier = "com.onevcat.Kingfisher.RoundCornerImageProcessor(\(cornerRadius))" + } + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + let size = targetSize ?? image.kf.size + return image.kf.image(withRoundRadius: cornerRadius, fit: size, scale: options.scaleFactor) + case .data(_): + return (DefaultImageProcessor() >> self).process(item: item, options: options) + } + } +} + +/// Processor for resizing images. Only CG-based images are supported in macOS. +public struct ResizingImageProcessor: ImageProcessor { + public let identifier: String + + /// Target size of output image should be. + public let targetSize: CGSize + + /// Initialize a `ResizingImageProcessor` + /// + /// - parameter targetSize: Target size of output image should be. + /// + /// - returns: An initialized `ResizingImageProcessor`. + public init(targetSize: CGSize) { + self.targetSize = targetSize + self.identifier = "com.onevcat.Kingfisher.ResizingImageProcessor(\(targetSize))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.resize(to: targetSize) + case .data(_): + return (DefaultImageProcessor() >> self).process(item: item, options: options) + } + } +} + +/// Processor for adding blur effect to images. `Accelerate.framework` is used underhood for +/// a better performance. A simulated Gaussian blur with specified blur radius will be applied. +public struct BlurImageProcessor: ImageProcessor { + public let identifier: String + + /// Blur radius for the simulated Gaussian blur. + public let blurRadius: CGFloat + + /// Initialize a `BlurImageProcessor` + /// + /// - parameter blurRadius: Blur radius for the simulated Gaussian blur. + /// + /// - returns: An initialized `BlurImageProcessor`. + public init(blurRadius: CGFloat) { + self.blurRadius = blurRadius + self.identifier = "com.onevcat.Kingfisher.BlurImageProcessor(\(blurRadius))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + let radius = blurRadius * options.scaleFactor + return image.kf.blurred(withRadius: radius) + case .data(_): + return (DefaultImageProcessor() >> self).process(item: item, options: options) + } + } +} + +/// Processor for adding an overlay to images. Only CG-based images are supported in macOS. +public struct OverlayImageProcessor: ImageProcessor { + + public var identifier: String + + /// Overlay color will be used to overlay the input image. + public let overlay: Color + + /// Fraction will be used when overlay the color to image. + public let fraction: CGFloat + + /// Initialize an `OverlayImageProcessor` + /// + /// - parameter overlay: Overlay color will be used to overlay the input image. + /// - parameter fraction: Fraction will be used when overlay the color to image. + /// From 0.0 to 1.0. 0.0 means solid color, 1.0 means transparent overlay. + /// + /// - returns: An initialized `OverlayImageProcessor`. + public init(overlay: Color, fraction: CGFloat = 0.5) { + self.overlay = overlay + self.fraction = fraction + self.identifier = "com.onevcat.Kingfisher.OverlayImageProcessor(\(overlay.hex)_\(fraction))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.overlaying(with: overlay, fraction: fraction) + case .data(_): + return (DefaultImageProcessor() >> self).process(item: item, options: options) + } + } +} + +/// Processor for tint images with color. Only CG-based images are supported. +public struct TintImageProcessor: ImageProcessor { + + public let identifier: String + + /// Tint color will be used to tint the input image. + public let tint: Color + + /// Initialize a `TintImageProcessor` + /// + /// - parameter tint: Tint color will be used to tint the input image. + /// + /// - returns: An initialized `TintImageProcessor`. + public init(tint: Color) { + self.tint = tint + self.identifier = "com.onevcat.Kingfisher.TintImageProcessor(\(tint.hex))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.tinted(with: tint) + case .data(_): + return (DefaultImageProcessor() >> self).process(item: item, options: options) + } + } +} + +/// Processor for applying some color control to images. Only CG-based images are supported. +/// watchOS is not supported. +public struct ColorControlsProcessor: ImageProcessor { + + public let identifier: String + + /// Brightness changing to image. + public let brightness: CGFloat + + /// Contrast changing to image. + public let contrast: CGFloat + + /// Saturation changing to image. + public let saturation: CGFloat + + /// InputEV changing to image. + public let inputEV: CGFloat + + /// Initialize a `ColorControlsProcessor` + /// + /// - parameter brightness: Brightness changing to image. + /// - parameter contrast: Contrast changing to image. + /// - parameter saturation: Saturation changing to image. + /// - parameter inputEV: InputEV changing to image. + /// + /// - returns: An initialized `ColorControlsProcessor` + public init(brightness: CGFloat, contrast: CGFloat, saturation: CGFloat, inputEV: CGFloat) { + self.brightness = brightness + self.contrast = contrast + self.saturation = saturation + self.inputEV = inputEV + self.identifier = "com.onevcat.Kingfisher.ColorControlsProcessor(\(brightness)_\(contrast)_\(saturation)_\(inputEV))" + } + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + switch item { + case .image(let image): + return image.kf.adjusted(brightness: brightness, contrast: contrast, saturation: saturation, inputEV: inputEV) + case .data(_): + return (DefaultImageProcessor() >> self).process(item: item, options: options) + } + } +} + +/// Processor for applying black and white effect to images. Only CG-based images are supported. +/// watchOS is not supported. +public struct BlackWhiteProcessor: ImageProcessor { + public let identifier = "com.onevcat.Kingfisher.BlackWhiteProcessor" + + /// Initialize a `BlackWhiteProcessor` + /// + /// - returns: An initialized `BlackWhiteProcessor` + public init() {} + + public func process(item: ImageProcessItem, options: KingfisherOptionsInfo) -> Image? { + return ColorControlsProcessor(brightness: 0.0, contrast: 1.0, saturation: 0.0, inputEV: 0.7) + .process(item: item, options: options) + } +} + +/// Concatenate two `ImageProcessor`s. `ImageProcessor.appen(another:)` is used internally. +/// +/// - parameter left: First processor. +/// - parameter right: Second processor. +/// +/// - returns: The concatenated processor. +public func >>(left: ImageProcessor, right: ImageProcessor) -> ImageProcessor { + return left.append(another: right) +} + +fileprivate extension Color { + var hex: String { + var r: CGFloat = 0 + var g: CGFloat = 0 + var b: CGFloat = 0 + var a: CGFloat = 0 + + getRed(&r, green: &g, blue: &b, alpha: &a) + + let rgba = Int(r * 255) << 24 | Int(g * 255) << 16 | Int(b * 255) << 8 | Int(a * 255) + + return String(format:"#%08x", rgba) + } +} diff --git a/Pods/Kingfisher/Sources/ImageTransition.swift b/Pods/Kingfisher/Sources/ImageTransition.swift new file mode 100755 index 0000000..9fa9077 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageTransition.swift @@ -0,0 +1,128 @@ +// +// ImageTransition.swift +// Kingfisher +// +// Created by Wei Wang on 15/9/18. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +#if os(macOS) +// Not implemented for macOS and watchOS yet. + +import AppKit + +/// Image transition is not supported on macOS. +public enum ImageTransition { + case none + var duration: TimeInterval { + return 0 + } +} + +#elseif os(watchOS) +import UIKit +/// Image transition is not supported on watchOS. +public enum ImageTransition { + case none + var duration: TimeInterval { + return 0 + } +} +#else +import UIKit + +/** +Transition effect which will be used when an image downloaded and set by `UIImageView` extension API in Kingfisher. +You can assign an enum value with transition duration as an item in `KingfisherOptionsInfo` +to enable the animation transition. + +Apple's UIViewAnimationOptions is used under the hood. +For custom transition, you should specified your own transition options, animations and +comletion handler as well. +*/ +public enum ImageTransition { + /// No animation transistion. + case none + + /// Fade in the loaded image. + case fade(TimeInterval) + + /// Flip from left transition. + case flipFromLeft(TimeInterval) + + /// Flip from right transition. + case flipFromRight(TimeInterval) + + /// Flip from top transition. + case flipFromTop(TimeInterval) + + /// Flip from bottom transition. + case flipFromBottom(TimeInterval) + + /// Custom transition. + case custom(duration: TimeInterval, + options: UIViewAnimationOptions, + animations: ((UIImageView, UIImage) -> Void)?, + completion: ((Bool) -> Void)?) + + var duration: TimeInterval { + switch self { + case .none: return 0 + case .fade(let duration): return duration + + case .flipFromLeft(let duration): return duration + case .flipFromRight(let duration): return duration + case .flipFromTop(let duration): return duration + case .flipFromBottom(let duration): return duration + + case .custom(let duration, _, _, _): return duration + } + } + + var animationOptions: UIViewAnimationOptions { + switch self { + case .none: return [] + case .fade(_): return .transitionCrossDissolve + + case .flipFromLeft(_): return .transitionFlipFromLeft + case .flipFromRight(_): return .transitionFlipFromRight + case .flipFromTop(_): return .transitionFlipFromTop + case .flipFromBottom(_): return .transitionFlipFromBottom + + case .custom(_, let options, _, _): return options + } + } + + var animations: ((UIImageView, UIImage) -> Void)? { + switch self { + case .custom(_, _, let animations, _): return animations + default: return { $0.image = $1 } + } + } + + var completion: ((Bool) -> Void)? { + switch self { + case .custom(_, _, _, let completion): return completion + default: return nil + } + } +} +#endif diff --git a/Pods/Kingfisher/Sources/ImageView+Kingfisher.swift b/Pods/Kingfisher/Sources/ImageView+Kingfisher.swift new file mode 100755 index 0000000..d5b53a6 --- /dev/null +++ b/Pods/Kingfisher/Sources/ImageView+Kingfisher.swift @@ -0,0 +1,292 @@ +// +// ImageView+Kingfisher.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +// MARK: - Extension methods. +/** + * Set image to use from web. + */ +extension Kingfisher where Base: ImageView { + /** + Set an image with a resource, a placeholder image, options, progress handler and completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + public func setImage(with resource: Resource?, + placeholder: Image? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + base.image = placeholder + + guard let resource = resource else { + completionHandler?(nil, nil, .none, nil) + return .empty + } + + let maybeIndicator = indicator + maybeIndicator?.startAnimatingView() + + setWebURL(resource.downloadURL) + + var options = options ?? KingfisherEmptyOptionsInfo + if shouldPreloadAllGIF() { + options.append(.preloadAllGIFData) + } + + let task = KingfisherManager.shared.retrieveImage( + with: resource, + options: options, + progressBlock: { receivedSize, totalSize in + if let progressBlock = progressBlock { + progressBlock(receivedSize, totalSize) + } + }, + completionHandler: {[weak base] image, error, cacheType, imageURL in + DispatchQueue.main.safeAsync { + guard let strongBase = base, imageURL == self.webURL else { + return + } + self.setImageTask(nil) + guard let image = image else { + maybeIndicator?.stopAnimatingView() + completionHandler?(nil, error, cacheType, imageURL) + return + } + + guard let transitionItem = options.firstMatchIgnoringAssociatedValue(.transition(.none)), + case .transition(let transition) = transitionItem, ( options.forceTransition || cacheType == .none) else + { + maybeIndicator?.stopAnimatingView() + strongBase.image = image + completionHandler?(image, error, cacheType, imageURL) + return + } + + #if !os(macOS) + UIView.transition(with: strongBase, duration: 0.0, options: [], + animations: { maybeIndicator?.stopAnimatingView() }, + completion: { _ in + UIView.transition(with: strongBase, duration: transition.duration, + options: [transition.animationOptions, .allowUserInteraction], + animations: { + // Set image property in the animation. + transition.animations?(strongBase, image) + }, + completion: { finished in + transition.completion?(finished) + completionHandler?(image, error, cacheType, imageURL) + }) + }) + #endif + } + }) + + setImageTask(task) + + return task + } + + /** + Cancel the image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + public func cancelDownloadTask() { + imageTask?.downloadTask?.cancel() + } + + func shouldPreloadAllGIF() -> Bool { + return true + } +} + +// MARK: - Associated Object +private var lastURLKey: Void? +private var indicatorKey: Void? +private var indicatorTypeKey: Void? +private var imageTaskKey: Void? + +extension Kingfisher where Base: ImageView { + /// Get the image URL binded to this image view. + public var webURL: URL? { + return objc_getAssociatedObject(base, &lastURLKey) as? URL + } + + fileprivate func setWebURL(_ url: URL) { + objc_setAssociatedObject(base, &lastURLKey, url, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + + /// Holds which indicator type is going to be used. + /// Default is .none, means no indicator will be shown. + public var indicatorType: IndicatorType { + get { + let indicator = (objc_getAssociatedObject(base, &indicatorTypeKey) as? Box)?.value + return indicator ?? .none + } + + set { + switch newValue { + case .none: + indicator = nil + case .activity: + indicator = ActivityIndicator() + case .image(let data): + indicator = ImageIndicator(imageData: data) + case .custom(let anIndicator): + indicator = anIndicator + } + + objc_setAssociatedObject(base, &indicatorTypeKey, Box(value: newValue), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + /// Holds any type that conforms to the protocol `Indicator`. + /// The protocol `Indicator` has a `view` property that will be shown when loading an image. + /// It will be `nil` if `indicatorType` is `.none`. + public fileprivate(set) var indicator: Indicator? { + get { + return (objc_getAssociatedObject(base, &indicatorKey) as? Box)?.value + } + + set { + // Remove previous + if let previousIndicator = indicator { + previousIndicator.view.removeFromSuperview() + } + + // Add new + if var newIndicator = newValue { + newIndicator.view.frame = base.frame + newIndicator.viewCenter = CGPoint(x: base.bounds.midX, y: base.bounds.midY) + newIndicator.view.isHidden = true + base.addSubview(newIndicator.view) + } + + // Save in associated object + objc_setAssociatedObject(base, &indicatorKey, Box(value: newValue), .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + } + + fileprivate var imageTask: RetrieveImageTask? { + return objc_getAssociatedObject(base, &imageTaskKey) as? RetrieveImageTask + } + + fileprivate func setImageTask(_ task: RetrieveImageTask?) { + objc_setAssociatedObject(base, &imageTaskKey, task, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } +} + + +// MARK: - Deprecated. Only for back compatibility. +/** +* Set image to use from web. Deprecated. Use `kf` namespacing instead. +*/ +extension ImageView { + /** + Set an image with a resource, a placeholder image, options, progress handler and completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.setImage` instead.", renamed: "kf.setImage") + @discardableResult + public func kf_setImage(with resource: Resource?, + placeholder: Image? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + return kf.setImage(with: resource, placeholder: placeholder, options: options, progressBlock: progressBlock, completionHandler: completionHandler) + } + + /** + Cancel the image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.cancelDownloadTask` instead.", renamed: "kf.cancelDownloadTask") + public func kf_cancelDownloadTask() { kf.cancelDownloadTask() } + + /// Get the image URL binded to this image view. + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.webURL` instead.", renamed: "kf.webURL") + public var kf_webURL: URL? { return kf.webURL } + + /// Holds which indicator type is going to be used. + /// Default is .none, means no indicator will be shown. + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.indicatorType` instead.", renamed: "kf.indicatorType") + public var kf_indicatorType: IndicatorType { + get { return kf.indicatorType } + set { + var holder = kf + holder.indicatorType = newValue + } + } + + @available(*, deprecated, message: "Extensions directly on image views are deprecated. Use `imageView.kf.indicator` instead.", renamed: "kf.indicator") + /// Holds any type that conforms to the protocol `Indicator`. + /// The protocol `Indicator` has a `view` property that will be shown when loading an image. + /// It will be `nil` if `kf_indicatorType` is `.none`. + public private(set) var kf_indicator: Indicator? { + get { return kf.indicator } + set { + var holder = kf + holder.indicator = newValue + } + } + + @available(*, deprecated, message: "Extensions directly on image views are deprecated.", renamed: "kf.imageTask") + fileprivate var kf_imageTask: RetrieveImageTask? { return kf.imageTask } + @available(*, deprecated, message: "Extensions directly on image views are deprecated.", renamed: "kf.setImageTask") + fileprivate func kf_setImageTask(_ task: RetrieveImageTask?) { kf.setImageTask(task) } + @available(*, deprecated, message: "Extensions directly on image views are deprecated.", renamed: "kf.setWebURL") + fileprivate func kf_setWebURL(_ url: URL) { kf.setWebURL(url) } + @available(*, deprecated, message: "Extensions directly on image views are deprecated.", renamed: "kf.shouldPreloadAllGIF") + func shouldPreloadAllGIF() -> Bool { return kf.shouldPreloadAllGIF() } +} diff --git a/Pods/Kingfisher/Sources/Indicator.swift b/Pods/Kingfisher/Sources/Indicator.swift new file mode 100644 index 0000000..89908b1 --- /dev/null +++ b/Pods/Kingfisher/Sources/Indicator.swift @@ -0,0 +1,191 @@ +// +// Indicator.swift +// Kingfisher +// +// Created by João D. Moreira on 30/08/16. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +#if os(macOS) + import AppKit +#else + import UIKit +#endif + +#if os(macOS) + public typealias IndicatorView = NSView +#else + public typealias IndicatorView = UIView +#endif + +public enum IndicatorType { + /// No indicator. + case none + /// Use system activity indicator. + case activity + /// Use an image as indicator. GIF is supported. + case image(imageData: Data) + /// Use a custom indicator, which conforms to the `Indicator` protocol. + case custom(indicator: Indicator) +} + +// MARK: - Indicator Protocol +public protocol Indicator { + func startAnimatingView() + func stopAnimatingView() + + var viewCenter: CGPoint { get set } + var view: IndicatorView { get } +} + +extension Indicator { + #if os(macOS) + public var viewCenter: CGPoint { + get { + let frame = view.frame + return CGPoint(x: frame.origin.x + frame.size.width / 2.0, y: frame.origin.y + frame.size.height / 2.0 ) + } + set { + let frame = view.frame + let newFrame = CGRect(x: newValue.x - frame.size.width / 2.0, + y: newValue.y - frame.size.height / 2.0, + width: frame.size.width, + height: frame.size.height) + view.frame = newFrame + } + } + #else + public var viewCenter: CGPoint { + get { + return view.center + } + set { + view.center = newValue + } + } + #endif +} + +// MARK: - ActivityIndicator +// Displays a NSProgressIndicator / UIActivityIndicatorView +struct ActivityIndicator: Indicator { + + #if os(macOS) + private let activityIndicatorView: NSProgressIndicator + #else + private let activityIndicatorView: UIActivityIndicatorView + #endif + + var view: IndicatorView { + return activityIndicatorView + } + + func startAnimatingView() { + #if os(macOS) + activityIndicatorView.startAnimation(nil) + #else + activityIndicatorView.startAnimating() + #endif + activityIndicatorView.isHidden = false + } + + func stopAnimatingView() { + #if os(macOS) + activityIndicatorView.stopAnimation(nil) + #else + activityIndicatorView.stopAnimating() + #endif + activityIndicatorView.isHidden = true + } + + init() { + #if os(macOS) + activityIndicatorView = NSProgressIndicator(frame: CGRect(x: 0, y: 0, width: 16, height: 16)) + activityIndicatorView.controlSize = .small + activityIndicatorView.style = .spinningStyle + #else + #if os(tvOS) + let indicatorStyle = UIActivityIndicatorViewStyle.white + #else + let indicatorStyle = UIActivityIndicatorViewStyle.gray + #endif + activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle:indicatorStyle) + activityIndicatorView.autoresizingMask = [.flexibleLeftMargin, .flexibleRightMargin, .flexibleBottomMargin, .flexibleTopMargin] + #endif + } +} + +// MARK: - ImageIndicator +// Displays an ImageView. Supports gif +struct ImageIndicator: Indicator { + private let animatedImageIndicatorView: ImageView + + var view: IndicatorView { + return animatedImageIndicatorView + } + + init?(imageData data: Data, processor: ImageProcessor = DefaultImageProcessor.default, options: KingfisherOptionsInfo = KingfisherEmptyOptionsInfo) { + + var options = options + // Use normal image view to show gif, so we need to preload all gif data. + if !options.preloadAllGIFData { + options.append(.preloadAllGIFData) + } + + guard let image = processor.process(item: .data(data), options: options) else { + return nil + } + + animatedImageIndicatorView = ImageView() + animatedImageIndicatorView.image = image + + #if os(macOS) + // Need for gif to animate on macOS + self.animatedImageIndicatorView.imageScaling = .scaleNone + self.animatedImageIndicatorView.canDrawSubviewsIntoLayer = true + #else + animatedImageIndicatorView.contentMode = .center + + animatedImageIndicatorView.autoresizingMask = [.flexibleLeftMargin, + .flexibleRightMargin, + .flexibleBottomMargin, + .flexibleTopMargin] + #endif + } + + func startAnimatingView() { + #if os(macOS) + animatedImageIndicatorView.animates = true + #else + animatedImageIndicatorView.startAnimating() + #endif + animatedImageIndicatorView.isHidden = false + } + + func stopAnimatingView() { + #if os(macOS) + animatedImageIndicatorView.animates = false + #else + animatedImageIndicatorView.stopAnimating() + #endif + animatedImageIndicatorView.isHidden = true + } +} diff --git a/Pods/Kingfisher/Sources/Kingfisher.h b/Pods/Kingfisher/Sources/Kingfisher.h new file mode 100644 index 0000000..05350ce --- /dev/null +++ b/Pods/Kingfisher/Sources/Kingfisher.h @@ -0,0 +1,37 @@ +// +// Kingfisher.h +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +#import + +//! Project version number for Kingfisher. +FOUNDATION_EXPORT double KingfisherVersionNumber; + +//! Project version string for Kingfisher. +FOUNDATION_EXPORT const unsigned char KingfisherVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/Pods/Kingfisher/Sources/Kingfisher.swift b/Pods/Kingfisher/Sources/Kingfisher.swift new file mode 100644 index 0000000..5327147 --- /dev/null +++ b/Pods/Kingfisher/Sources/Kingfisher.swift @@ -0,0 +1,72 @@ +// +// Kingfisher.swift +// Kingfisher +// +// Created by Wei Wang on 16/9/14. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +import Foundation +import ImageIO + +#if os(macOS) + import AppKit + public typealias Image = NSImage + public typealias Color = NSColor + public typealias ImageView = NSImageView + typealias Button = NSButton +#else + import UIKit + public typealias Image = UIImage + public typealias Color = UIColor + #if !os(watchOS) + public typealias ImageView = UIImageView + typealias Button = UIButton + #endif +#endif + +public struct Kingfisher { + public let base: Base + public init(_ base: Base) { + self.base = base + } +} + +/** + A type that has Kingfisher extensions. + */ +public protocol KingfisherCompatible { + associatedtype CompatibleType + var kf: CompatibleType { get } +} + +public extension KingfisherCompatible { + public var kf: Kingfisher { + get { return Kingfisher(self) } + set { } + } +} + +extension Image: KingfisherCompatible { } +#if !os(watchOS) +extension ImageView: KingfisherCompatible { } +extension Button: KingfisherCompatible { } +#endif diff --git a/Pods/Kingfisher/Sources/KingfisherManager.swift b/Pods/Kingfisher/Sources/KingfisherManager.swift new file mode 100755 index 0000000..1045f40 --- /dev/null +++ b/Pods/Kingfisher/Sources/KingfisherManager.swift @@ -0,0 +1,213 @@ +// +// KingfisherManager.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + +public typealias DownloadProgressBlock = ((_ receivedSize: Int64, _ totalSize: Int64) -> ()) +public typealias CompletionHandler = ((_ image: Image?, _ error: NSError?, _ cacheType: CacheType, _ imageURL: URL?) -> ()) + +/// RetrieveImageTask represents a task of image retrieving process. +/// It contains an async task of getting image from disk and from network. +public class RetrieveImageTask { + + static let empty = RetrieveImageTask() + + // If task is canceled before the download task started (which means the `downloadTask` is nil), + // the download task should not begin. + var cancelledBeforeDownloadStarting: Bool = false + + /// The disk retrieve task in this image task. Kingfisher will try to look up in cache first. This task represent the cache search task. + public var diskRetrieveTask: RetrieveImageDiskTask? + + /// The network retrieve task in this image task. + public var downloadTask: RetrieveImageDownloadTask? + + /** + Cancel current task. If this task does not begin or already done, do nothing. + */ + public func cancel() { + // From Xcode 7 beta 6, the `dispatch_block_cancel` will crash at runtime. + // It fixed in Xcode 7.1. + // See https://github.com/onevcat/Kingfisher/issues/99 for more. + if let diskRetrieveTask = diskRetrieveTask { + diskRetrieveTask.cancel() + } + + if let downloadTask = downloadTask { + downloadTask.cancel() + } else { + cancelledBeforeDownloadStarting = true + } + } +} + +/// Error domain of Kingfisher +public let KingfisherErrorDomain = "com.onevcat.Kingfisher.Error" + +/// Main manager class of Kingfisher. It connects Kingfisher downloader and cache. +/// You can use this class to retrieve an image via a specified URL from web or cache. +public class KingfisherManager { + + /// Shared manager used by the extensions across Kingfisher. + public static let shared = KingfisherManager() + + /// Cache used by this manager + public var cache: ImageCache + + /// Downloader used by this manager + public var downloader: ImageDownloader + + convenience init() { + self.init(downloader: .default, cache: .default) + } + + init(downloader: ImageDownloader, cache: ImageCache) { + self.downloader = downloader + self.cache = cache + } + + /** + Get an image with resource. + If KingfisherOptions.None is used as `options`, Kingfisher will seek the image in memory and disk first. + If not found, it will download the image at `resource.downloadURL` and cache it with `resource.cacheKey`. + These default behaviors could be adjusted by passing different options. See `KingfisherOptions` for more. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called every time downloaded data changed. This could be used as a progress UI. + - parameter completionHandler: Called when the whole retrieving process finished. + + - returns: A `RetrieveImageTask` task object. You can use this object to cancel the task. + */ + @discardableResult + public func retrieveImage(with resource: Resource, + options: KingfisherOptionsInfo?, + progressBlock: DownloadProgressBlock?, + completionHandler: CompletionHandler?) -> RetrieveImageTask + { + let task = RetrieveImageTask() + + if let options = options, options.forceRefresh { + _ = downloadAndCacheImage( + with: resource.downloadURL, + forKey: resource.cacheKey, + retrieveImageTask: task, + progressBlock: progressBlock, + completionHandler: completionHandler, + options: options) + } else { + tryToRetrieveImageFromCache( + forKey: resource.cacheKey, + with: resource.downloadURL, + retrieveImageTask: task, + progressBlock: progressBlock, + completionHandler: completionHandler, + options: options) + } + + return task + } + + @discardableResult + func downloadAndCacheImage(with url: URL, + forKey key: String, + retrieveImageTask: RetrieveImageTask, + progressBlock: DownloadProgressBlock?, + completionHandler: CompletionHandler?, + options: KingfisherOptionsInfo?) -> RetrieveImageDownloadTask? + { + let options = options ?? KingfisherEmptyOptionsInfo + let downloader = options.downloader + return downloader.downloadImage(with: url, retrieveImageTask: retrieveImageTask, options: options, + progressBlock: { receivedSize, totalSize in + progressBlock?(receivedSize, totalSize) + }, + completionHandler: { image, error, imageURL, originalData in + + let targetCache = options.targetCache + if let error = error, error.code == KingfisherError.notModified.rawValue { + // Not modified. Try to find the image from cache. + // (The image should be in cache. It should be guaranteed by the framework users.) + targetCache.retrieveImage(forKey: key, options: options, completionHandler: { (cacheImage, cacheType) -> () in + completionHandler?(cacheImage, nil, cacheType, url) + }) + return + } + + if let image = image, let originalData = originalData { + targetCache.store(image, + original: originalData, + forKey: key, + processorIdentifier:options.processor.identifier, + cacheSerializer: options.cacheSerializer, + toDisk: !options.cacheMemoryOnly, + completionHandler: nil) + } + + completionHandler?(image, error, .none, url) + + }) + } + + func tryToRetrieveImageFromCache(forKey key: String, + with url: URL, + retrieveImageTask: RetrieveImageTask, + progressBlock: DownloadProgressBlock?, + completionHandler: CompletionHandler?, + options: KingfisherOptionsInfo?) + { + let diskTaskCompletionHandler: CompletionHandler = { (image, error, cacheType, imageURL) -> () in + // Break retain cycle created inside diskTask closure below + retrieveImageTask.diskRetrieveTask = nil + completionHandler?(image, error, cacheType, imageURL) + } + + let targetCache = options?.targetCache ?? cache + let diskTask = targetCache.retrieveImage(forKey: key, options: options, + completionHandler: { image, cacheType in + if image != nil { + diskTaskCompletionHandler(image, nil, cacheType, url) + } else if let options = options, options.onlyFromCache { + let error = NSError(domain: KingfisherErrorDomain, code: KingfisherError.notCached.rawValue, userInfo: nil) + diskTaskCompletionHandler(nil, error, .none, url) + } else { + self.downloadAndCacheImage( + with: url, + forKey: key, + retrieveImageTask: retrieveImageTask, + progressBlock: progressBlock, + completionHandler: diskTaskCompletionHandler, + options: options) + } + } + ) + retrieveImageTask.diskRetrieveTask = diskTask + } +} diff --git a/Pods/Kingfisher/Sources/KingfisherOptionsInfo.swift b/Pods/Kingfisher/Sources/KingfisherOptionsInfo.swift new file mode 100755 index 0000000..cb57f5e --- /dev/null +++ b/Pods/Kingfisher/Sources/KingfisherOptionsInfo.swift @@ -0,0 +1,255 @@ +// +// KingfisherOptionsInfo.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/23. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +#if os(macOS) +import AppKit +#else +import UIKit +#endif + + +/** +* KingfisherOptionsInfo is a typealias for [KingfisherOptionsInfoItem]. You can use the enum of option item with value to control some behaviors of Kingfisher. +*/ +public typealias KingfisherOptionsInfo = [KingfisherOptionsInfoItem] +let KingfisherEmptyOptionsInfo = [KingfisherOptionsInfoItem]() + +/** +Items could be added into KingfisherOptionsInfo. +*/ +public enum KingfisherOptionsInfoItem { + /// The associated value of this member should be an ImageCache object. Kingfisher will use the specified + /// cache object when handling related operations, including trying to retrieve the cached images and store + /// the downloaded image to it. + case targetCache(ImageCache) + + /// The associated value of this member should be an ImageDownloader object. Kingfisher will use this + /// downloader to download the images. + case downloader(ImageDownloader) + + /// Member for animation transition when using UIImageView. Kingfisher will use the `ImageTransition` of + /// this enum to animate the image in if it is downloaded from web. The transition will not happen when the + /// image is retrieved from either memory or disk cache by default. If you need to do the transition even when + /// the image being retrieved from cache, set `ForceTransition` as well. + case transition(ImageTransition) + + /// Associated `Float` value will be set as the priority of image download task. The value for it should be + /// between 0.0~1.0. If this option not set, the default value (`NSURLSessionTaskPriorityDefault`) will be used. + case downloadPriority(Float) + + /// If set, `Kingfisher` will ignore the cache and try to fire a download task for the resource. + case forceRefresh + + /// If set, setting the image to an image view will happen with transition even when retrieved from cache. + /// See `Transition` option for more. + case forceTransition + + /// If set, `Kingfisher` will only cache the value in memory but not in disk. + case cacheMemoryOnly + + /// If set, `Kingfisher` will only try to retrieve the image from cache not from network. + case onlyFromCache + + /// Decode the image in background thread before using. + case backgroundDecode + + /// The associated value of this member will be used as the target queue of dispatch callbacks when + /// retrieving images from cache. If not set, `Kingfisher` will use main quese for callbacks. + case callbackDispatchQueue(DispatchQueue?) + + /// The associated value of this member will be used as the scale factor when converting retrieved data to an image. + case scaleFactor(CGFloat) + + /// Whether all the GIF data should be preloaded. Default it false, which means following frames will be + /// loaded on need. If true, all the GIF data will be loaded and decoded into memory. This option is mainly + /// used for back compatibility internally. You should not set it directly. `AnimatedImageView` will not preload + /// all data, while a normal image view (`UIImageView` or `NSImageView`) will load all data. Choose to use + /// corresponding image view type instead of setting this option. + case preloadAllGIFData + + /// The `ImageDownloadRequestModifier` contained will be used to change the request before it being sent. + /// This is the last chance you can modify the request. You can modify the request for some customizing purpose, + /// such as adding auth token to the header, do basic HTTP auth or something like url mapping. The original request + /// will be sent without any modification by default. + case requestModifier(ImageDownloadRequestModifier) + + /// Processor for processing when the downloading finishes, a processor will convert the downloaded data to an image + /// and/or apply some filter on it. If a cache is connected to the downloader (it happenes when you are using + /// KingfisherManager or the image extension methods), the converted image will also be sent to cache as well as the + /// image view. `DefaultImageProcessor.default` will be used by default. + case processor(ImageProcessor) + + /// Supply an `CacheSerializer` to convert some data to an image object for + /// retrieving from disk cache or vice versa for storing to disk cache. + /// `DefaultCacheSerializer.default` will be used by default. + case cacheSerializer(CacheSerializer) +} + +precedencegroup ItemComparisonPrecedence { + associativity: none + higherThan: LogicalConjunctionPrecedence +} + +infix operator <== : ItemComparisonPrecedence + +// This operator returns true if two `KingfisherOptionsInfoItem` enum is the same, without considering the associated values. +func <== (lhs: KingfisherOptionsInfoItem, rhs: KingfisherOptionsInfoItem) -> Bool { + switch (lhs, rhs) { + case (.targetCache(_), .targetCache(_)): return true + case (.downloader(_), .downloader(_)): return true + case (.transition(_), .transition(_)): return true + case (.downloadPriority(_), .downloadPriority(_)): return true + case (.forceRefresh, .forceRefresh): return true + case (.forceTransition, .forceTransition): return true + case (.cacheMemoryOnly, .cacheMemoryOnly): return true + case (.onlyFromCache, .onlyFromCache): return true + case (.backgroundDecode, .backgroundDecode): return true + case (.callbackDispatchQueue(_), .callbackDispatchQueue(_)): return true + case (.scaleFactor(_), .scaleFactor(_)): return true + case (.preloadAllGIFData, .preloadAllGIFData): return true + case (.requestModifier(_), .requestModifier(_)): return true + case (.processor(_), .processor(_)): return true + case (.cacheSerializer(_), .cacheSerializer(_)): return true + default: return false + } +} + +extension Collection where Iterator.Element == KingfisherOptionsInfoItem { + func firstMatchIgnoringAssociatedValue(_ target: Iterator.Element) -> Iterator.Element? { + return index { $0 <== target }.flatMap { self[$0] } + } + + func removeAllMatchesIgnoringAssociatedValue(_ target: Iterator.Element) -> [Iterator.Element] { + return self.filter { !($0 <== target) } + } +} + +extension Collection where Iterator.Element == KingfisherOptionsInfoItem { + var targetCache: ImageCache { + if let item = firstMatchIgnoringAssociatedValue(.targetCache(.default)), + case .targetCache(let cache) = item + { + return cache + } + return ImageCache.default + } + + var downloader: ImageDownloader { + if let item = firstMatchIgnoringAssociatedValue(.downloader(.default)), + case .downloader(let downloader) = item + { + return downloader + } + return ImageDownloader.default + } + + var transition: ImageTransition { + if let item = firstMatchIgnoringAssociatedValue(.transition(.none)), + case .transition(let transition) = item + { + return transition + } + return ImageTransition.none + } + + var downloadPriority: Float { + if let item = firstMatchIgnoringAssociatedValue(.downloadPriority(0)), + case .downloadPriority(let priority) = item + { + return priority + } + return URLSessionTask.defaultPriority + } + + var forceRefresh: Bool { + return contains{ $0 <== .forceRefresh } + } + + var forceTransition: Bool { + return contains{ $0 <== .forceTransition } + } + + var cacheMemoryOnly: Bool { + return contains{ $0 <== .cacheMemoryOnly } + } + + var onlyFromCache: Bool { + return contains{ $0 <== .onlyFromCache } + } + + var backgroundDecode: Bool { + return contains{ $0 <== .backgroundDecode } + } + + var preloadAllGIFData: Bool { + return contains { $0 <== .preloadAllGIFData } + } + + var callbackDispatchQueue: DispatchQueue { + if let item = firstMatchIgnoringAssociatedValue(.callbackDispatchQueue(nil)), + case .callbackDispatchQueue(let queue) = item + { + return queue ?? DispatchQueue.main + } + return DispatchQueue.main + } + + var scaleFactor: CGFloat { + if let item = firstMatchIgnoringAssociatedValue(.scaleFactor(0)), + case .scaleFactor(let scale) = item + { + return scale + } + return 1.0 + } + + var modifier: ImageDownloadRequestModifier { + if let item = firstMatchIgnoringAssociatedValue(.requestModifier(NoModifier.default)), + case .requestModifier(let modifier) = item + { + return modifier + } + return NoModifier.default + } + + var processor: ImageProcessor { + if let item = firstMatchIgnoringAssociatedValue(.processor(DefaultImageProcessor.default)), + case .processor(let processor) = item + { + return processor + } + return DefaultImageProcessor.default + } + + var cacheSerializer: CacheSerializer { + if let item = firstMatchIgnoringAssociatedValue(.cacheSerializer(DefaultCacheSerializer.default)), + case .cacheSerializer(let cacheSerializer) = item + { + return cacheSerializer + } + return DefaultCacheSerializer.default + } +} diff --git a/Pods/Kingfisher/Sources/RequrstModifier.swift b/Pods/Kingfisher/Sources/RequrstModifier.swift new file mode 100644 index 0000000..c1e7ca6 --- /dev/null +++ b/Pods/Kingfisher/Sources/RequrstModifier.swift @@ -0,0 +1,53 @@ +// +// RequrstModifier.swift +// Kingfisher +// +// Created by Wei Wang on 2016/09/05. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +import Foundation + +/// Request modifier of image downloader. +public protocol ImageDownloadRequestModifier { + func modified(for request: URLRequest) -> URLRequest? +} + +struct NoModifier: ImageDownloadRequestModifier { + static let `default` = NoModifier() + private init() {} + func modified(for request: URLRequest) -> URLRequest? { + return request + } +} + +public struct AnyModifier: ImageDownloadRequestModifier { + + let block: (URLRequest) -> URLRequest? + + public func modified(for request: URLRequest) -> URLRequest? { + return block(request) + } + + public init(modify: @escaping (URLRequest) -> URLRequest? ) { + block = modify + } +} diff --git a/Pods/Kingfisher/Sources/Resource.swift b/Pods/Kingfisher/Sources/Resource.swift new file mode 100755 index 0000000..875927f --- /dev/null +++ b/Pods/Kingfisher/Sources/Resource.swift @@ -0,0 +1,74 @@ +// +// Resource.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/6. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +import Foundation + + +/// `Resource` protocol defines how to download and cache a resource from network. +public protocol Resource { + /// The key used in cache. + var cacheKey: String { get } + + /// The target image URL. + var downloadURL: URL { get } +} + +/** + ImageResource is a simple combination of `downloadURL` and `cacheKey`. + + When passed to image view set methods, Kingfisher will try to download the target + image from the `downloadURL`, and then store it with the `cacheKey` as the key in cache. + */ +public struct ImageResource: Resource { + /// The key used in cache. + public let cacheKey: String + + /// The target image URL. + public let downloadURL: URL + + /** + Create a resource. + + - parameter downloadURL: The target image URL. + - parameter cacheKey: The cache key. If `nil`, Kingfisher will use the `absoluteString` of `downloadURL` as the key. + + - returns: A resource. + */ + public init(downloadURL: URL, cacheKey: String? = nil) { + self.downloadURL = downloadURL + self.cacheKey = cacheKey ?? downloadURL.absoluteString + } +} + +/** + URL conforms to `Resource` in Kingfisher. + The `absoluteString` of this URL is used as `cacheKey`. And the URL itself will be used as `downloadURL`. + If you need customize the url and/or cache key, use `ImageResource` instead. + */ +extension URL: Resource { + public var cacheKey: String { return absoluteString } + public var downloadURL: URL { return self } +} diff --git a/Pods/Kingfisher/Sources/String+MD5.swift b/Pods/Kingfisher/Sources/String+MD5.swift new file mode 100755 index 0000000..d14dec0 --- /dev/null +++ b/Pods/Kingfisher/Sources/String+MD5.swift @@ -0,0 +1,288 @@ +// +// String+MD5.swift +// Kingfisher +// +// To date, adding CommonCrypto to a Swift framework is problematic. See: +// http://stackoverflow.com/questions/25248598/importing-commoncrypto-in-a-swift-framework +// We're using a subset and modified version of CryptoSwift as an alternative. +// The following is an altered source version that only includes MD5. The original software can be found at: +// https://github.com/krzyzanowskim/CryptoSwift +// This is the original copyright notice: + +/* +Copyright (C) 2014 Marcin Krzyżanowski +This software is provided 'as-is', without any express or implied warranty. +In no event will the authors be held liable for any damages arising from the use of this software. +Permission is granted to anyone to use this software for any purpose,including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: +- The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation is required. +- Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. +- This notice may not be removed or altered from any source or binary distribution. +*/ + +import Foundation + +public struct StringProxy { + fileprivate let base: String + init(proxy: String) { + base = proxy + } +} + +extension String: KingfisherCompatible { + public typealias CompatibleType = StringProxy + public var kf: CompatibleType { + return StringProxy(proxy: self) + } +} + +extension StringProxy { + var md5: String { + if let data = base.data(using: .utf8, allowLossyConversion: true) { + + let message = data.withUnsafeBytes { bytes -> [UInt8] in + return Array(UnsafeBufferPointer(start: bytes, count: data.count)) + } + + let MD5Calculator = MD5(message) + let MD5Data = MD5Calculator.calculate() + + let MD5String = NSMutableString() + for c in MD5Data { + MD5String.appendFormat("%02x", c) + } + return MD5String as String + + } else { + return base + } + } +} + + +/** array of bytes, little-endian representation */ +func arrayOfBytes(_ value: T, length: Int? = nil) -> [UInt8] { + let totalBytes = length ?? (MemoryLayout.size * 8) + + let valuePointer = UnsafeMutablePointer.allocate(capacity: 1) + valuePointer.pointee = value + + let bytes = valuePointer.withMemoryRebound(to: UInt8.self, capacity: totalBytes) { (bytesPointer) -> [UInt8] in + var bytes = [UInt8](repeating: 0, count: totalBytes) + for j in 0...size, totalBytes) { + bytes[totalBytes - 1 - j] = (bytesPointer + j).pointee + } + return bytes + } + + valuePointer.deinitialize() + valuePointer.deallocate(capacity: 1) + + return bytes +} + +extension Int { + /** Array of bytes with optional padding (little-endian) */ + func bytes(_ totalBytes: Int = MemoryLayout.size) -> [UInt8] { + return arrayOfBytes(self, length: totalBytes) + } + +} + +extension NSMutableData { + + /** Convenient way to append bytes */ + func appendBytes(_ arrayOfBytes: [UInt8]) { + append(arrayOfBytes, length: arrayOfBytes.count) + } + +} + +protocol HashProtocol { + var message: Array { get } + + /** Common part for hash calculation. Prepare header data. */ + func prepare(_ len: Int) -> Array +} + +extension HashProtocol { + + func prepare(_ len: Int) -> Array { + var tmpMessage = message + + // Step 1. Append Padding Bits + tmpMessage.append(0x80) // append one bit (UInt8 with one bit) to message + + // append "0" bit until message length in bits ≡ 448 (mod 512) + var msgLength = tmpMessage.count + var counter = 0 + + while msgLength % len != (len - 8) { + counter += 1 + msgLength += 1 + } + + tmpMessage += Array(repeating: 0, count: counter) + return tmpMessage + } +} + +func toUInt32Array(_ slice: ArraySlice) -> Array { + var result = Array() + result.reserveCapacity(16) + + for idx in stride(from: slice.startIndex, to: slice.endIndex, by: MemoryLayout.size) { + let d0 = UInt32(slice[idx.advanced(by: 3)]) << 24 + let d1 = UInt32(slice[idx.advanced(by: 2)]) << 16 + let d2 = UInt32(slice[idx.advanced(by: 1)]) << 8 + let d3 = UInt32(slice[idx]) + let val: UInt32 = d0 | d1 | d2 | d3 + + result.append(val) + } + return result +} + +struct BytesIterator: IteratorProtocol { + + let chunkSize: Int + let data: [UInt8] + + init(chunkSize: Int, data: [UInt8]) { + self.chunkSize = chunkSize + self.data = data + } + + var offset = 0 + + mutating func next() -> ArraySlice? { + let end = min(chunkSize, data.count - offset) + let result = data[offset.. 0 ? result : nil + } +} + +struct BytesSequence: Sequence { + let chunkSize: Int + let data: [UInt8] + + func makeIterator() -> BytesIterator { + return BytesIterator(chunkSize: chunkSize, data: data) + } +} + +func rotateLeft(_ value: UInt32, bits: UInt32) -> UInt32 { + return ((value << bits) & 0xFFFFFFFF) | (value >> (32 - bits)) +} + +class MD5: HashProtocol { + + static let size = 16 // 128 / 8 + let message: [UInt8] + + init (_ message: [UInt8]) { + self.message = message + } + + /** specifies the per-round shift amounts */ + private let shifts: [UInt32] = [7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, + 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, + 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, + 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21, 6, 10, 15, 21] + + /** binary integer part of the sines of integers (Radians) */ + private let sines: [UInt32] = [0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, + 0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, + 0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, + 0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821, + 0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa, + 0xd62f105d, 0x02441453, 0xd8a1e681, 0xe7d3fbc8, + 0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed, + 0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a, + 0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c, + 0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70, + 0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05, + 0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665, + 0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039, + 0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1, + 0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1, + 0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391] + + private let hashes: [UInt32] = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476] + + func calculate() -> [UInt8] { + var tmpMessage = prepare(64) + tmpMessage.reserveCapacity(tmpMessage.count + 4) + + // hash values + var hh = hashes + + // Step 2. Append Length a 64-bit representation of lengthInBits + let lengthInBits = (message.count * 8) + let lengthBytes = lengthInBits.bytes(64 / 8) + tmpMessage += lengthBytes.reversed() + + // Process the message in successive 512-bit chunks: + let chunkSizeBytes = 512 / 8 // 64 + + for chunk in BytesSequence(chunkSize: chunkSizeBytes, data: tmpMessage) { + // break chunk into sixteen 32-bit words M[j], 0 ≤ j ≤ 15 + var M = toUInt32Array(chunk) + assert(M.count == 16, "Invalid array") + + // Initialize hash value for this chunk: + var A: UInt32 = hh[0] + var B: UInt32 = hh[1] + var C: UInt32 = hh[2] + var D: UInt32 = hh[3] + + var dTemp: UInt32 = 0 + + // Main loop + for j in 0 ..< sines.count { + var g = 0 + var F: UInt32 = 0 + + switch j { + case 0...15: + F = (B & C) | ((~B) & D) + g = j + break + case 16...31: + F = (D & B) | (~D & C) + g = (5 * j + 1) % 16 + break + case 32...47: + F = B ^ C ^ D + g = (3 * j + 5) % 16 + break + case 48...63: + F = C ^ (B | (~D)) + g = (7 * j) % 16 + break + default: + break + } + dTemp = D + D = C + C = B + B = B &+ rotateLeft((A &+ F &+ sines[j] &+ M[g]), bits: shifts[j]) + A = dTemp + } + + hh[0] = hh[0] &+ A + hh[1] = hh[1] &+ B + hh[2] = hh[2] &+ C + hh[3] = hh[3] &+ D + } + + var result = [UInt8]() + result.reserveCapacity(hh.count / 4) + + hh.forEach { + let itemLE = $0.littleEndian + result += [UInt8(itemLE & 0xff), UInt8((itemLE >> 8) & 0xff), UInt8((itemLE >> 16) & 0xff), UInt8((itemLE >> 24) & 0xff)] + } + return result + } +} diff --git a/Pods/Kingfisher/Sources/ThreadHelper.swift b/Pods/Kingfisher/Sources/ThreadHelper.swift new file mode 100755 index 0000000..afb3c93 --- /dev/null +++ b/Pods/Kingfisher/Sources/ThreadHelper.swift @@ -0,0 +1,40 @@ +// +// ThreadHelper.swift +// Kingfisher +// +// Created by Wei Wang on 15/10/9. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +import Foundation + +extension DispatchQueue { + // This method will dispatch the `block` to self. + // If `self` is the main queue, and current thread is main thread, the block + // will be invoked immediately instead of being dispatched. + func safeAsync(_ block: @escaping ()->()) { + if self === DispatchQueue.main && Thread.isMainThread { + block() + } else { + async { block() } + } + } +} diff --git a/Pods/Kingfisher/Sources/UIButton+Kingfisher.swift b/Pods/Kingfisher/Sources/UIButton+Kingfisher.swift new file mode 100755 index 0000000..0f01f81 --- /dev/null +++ b/Pods/Kingfisher/Sources/UIButton+Kingfisher.swift @@ -0,0 +1,399 @@ +// +// UIButton+Kingfisher.swift +// Kingfisher +// +// Created by Wei Wang on 15/4/13. +// +// Copyright (c) 2016 Wei Wang +// +// 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: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// 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. + +import UIKit + +// MARK: - Set Images +/** + * Set image to use in button from web for a specified state. + */ +extension Kingfisher where Base: UIButton { + /** + Set an image to use for a specified state with a resource, a placeholder image, options, progress handler and + completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter state: The state that uses the specified image. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + public func setImage(with resource: Resource?, + for state: UIControlState, + placeholder: UIImage? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + base.setImage(placeholder, for: state) + + guard let resource = resource else { + completionHandler?(nil, nil, .none, nil) + return .empty + } + + setWebURL(resource.downloadURL, for: state) + let task = KingfisherManager.shared.retrieveImage( + with: resource, + options: options, + progressBlock: { receivedSize, totalSize in + if let progressBlock = progressBlock { + progressBlock(receivedSize, totalSize) + } + }, + completionHandler: {[weak base] image, error, cacheType, imageURL in + DispatchQueue.main.safeAsync { + guard let strongBase = base, imageURL == self.webURL(for: state) else { + return + } + self.setImageTask(nil) + + if image != nil { + strongBase.setImage(image, for: state) + } + + completionHandler?(image, error, cacheType, imageURL) + } + }) + + setImageTask(task) + return task + } + + /** + Cancel the image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + public func cancelImageDownloadTask() { + imageTask?.downloadTask?.cancel() + } + + /** + Set the background image to use for a specified state with a resource, + a placeholder image, options progress handler and completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter state: The state that uses the specified image. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + public func setBackgroundImage(with resource: Resource?, + for state: UIControlState, + placeholder: UIImage? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + base.setBackgroundImage(placeholder, for: state) + + guard let resource = resource else { + completionHandler?(nil, nil, .none, nil) + return .empty + } + + setBackgroundWebURL(resource.downloadURL, for: state) + let task = KingfisherManager.shared.retrieveImage( + with: resource, + options: options, + progressBlock: { receivedSize, totalSize in + if let progressBlock = progressBlock { + progressBlock(receivedSize, totalSize) + } + }, + completionHandler: { [weak base] image, error, cacheType, imageURL in + DispatchQueue.main.safeAsync { + guard let strongBase = base, imageURL == self.backgroundWebURL(for: state) else { + return + } + self.setBackgroundImageTask(nil) + if image != nil { + strongBase.setBackgroundImage(image, for: state) + } + completionHandler?(image, error, cacheType, imageURL) + } + }) + + setBackgroundImageTask(task) + return task + } + + /** + Cancel the background image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + public func cancelBackgroundImageDownloadTask() { + backgroundImageTask?.downloadTask?.cancel() + } + +} + +// MARK: - Associated Object +private var lastURLKey: Void? +private var imageTaskKey: Void? + +extension Kingfisher where Base: UIButton { + /** + Get the image URL binded to this button for a specified state. + + - parameter state: The state that uses the specified image. + + - returns: Current URL for image. + */ + public func webURL(for state: UIControlState) -> URL? { + return webURLs[NSNumber(value:state.rawValue)] as? URL + } + + fileprivate func setWebURL(_ url: URL, for state: UIControlState) { + webURLs[NSNumber(value:state.rawValue)] = url + } + + fileprivate var webURLs: NSMutableDictionary { + var dictionary = objc_getAssociatedObject(base, &lastURLKey) as? NSMutableDictionary + if dictionary == nil { + dictionary = NSMutableDictionary() + setWebURLs(dictionary!) + } + return dictionary! + } + + fileprivate func setWebURLs(_ URLs: NSMutableDictionary) { + objc_setAssociatedObject(base, &lastURLKey, URLs, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + + fileprivate var imageTask: RetrieveImageTask? { + return objc_getAssociatedObject(base, &imageTaskKey) as? RetrieveImageTask + } + + fileprivate func setImageTask(_ task: RetrieveImageTask?) { + objc_setAssociatedObject(base, &imageTaskKey, task, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } +} + + +private var lastBackgroundURLKey: Void? +private var backgroundImageTaskKey: Void? + + +extension Kingfisher where Base: UIButton { + /** + Get the background image URL binded to this button for a specified state. + + - parameter state: The state that uses the specified background image. + + - returns: Current URL for background image. + */ + public func backgroundWebURL(for state: UIControlState) -> URL? { + return backgroundWebURLs[NSNumber(value:state.rawValue)] as? URL + } + + fileprivate func setBackgroundWebURL(_ url: URL, for state: UIControlState) { + backgroundWebURLs[NSNumber(value:state.rawValue)] = url + } + + fileprivate var backgroundWebURLs: NSMutableDictionary { + var dictionary = objc_getAssociatedObject(base, &lastBackgroundURLKey) as? NSMutableDictionary + if dictionary == nil { + dictionary = NSMutableDictionary() + setBackgroundWebURLs(dictionary!) + } + return dictionary! + } + + fileprivate func setBackgroundWebURLs(_ URLs: NSMutableDictionary) { + objc_setAssociatedObject(base, &lastBackgroundURLKey, URLs, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } + + fileprivate var backgroundImageTask: RetrieveImageTask? { + return objc_getAssociatedObject(base, &backgroundImageTaskKey) as? RetrieveImageTask + } + + fileprivate func setBackgroundImageTask(_ task: RetrieveImageTask?) { + objc_setAssociatedObject(base, &backgroundImageTaskKey, task, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + } +} + +// MARK: - Deprecated. Only for back compatibility. +/** +* Set image to use from web for a specified state. Deprecated. Use `kf` namespacing instead. +*/ +extension UIButton { + /** + Set an image to use for a specified state with a resource, a placeholder image, options, progress handler and + completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter state: The state that uses the specified image. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.setImage` instead.", + renamed: "kf.setImage") + public func kf_setImage(with resource: Resource?, + for state: UIControlState, + placeholder: UIImage? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + return kf.setImage(with: resource, for: state, placeholder: placeholder, options: options, + progressBlock: progressBlock, completionHandler: completionHandler) + } + + /** + Cancel the image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.cancelImageDownloadTask` instead.", + renamed: "kf.cancelImageDownloadTask") + public func kf_cancelImageDownloadTask() { kf.cancelImageDownloadTask() } + + /** + Set the background image to use for a specified state with a resource, + a placeholder image, options progress handler and completion handler. + + - parameter resource: Resource object contains information such as `cacheKey` and `downloadURL`. + - parameter state: The state that uses the specified image. + - parameter placeholder: A placeholder image when retrieving the image at URL. + - parameter options: A dictionary could control some behaviors. See `KingfisherOptionsInfo` for more. + - parameter progressBlock: Called when the image downloading progress gets updated. + - parameter completionHandler: Called when the image retrieved and set. + + - returns: A task represents the retrieving process. + + - note: Both the `progressBlock` and `completionHandler` will be invoked in main thread. + The `CallbackDispatchQueue` specified in `optionsInfo` will not be used in callbacks of this method. + */ + @discardableResult + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.setBackgroundImage` instead.", + renamed: "kf.setBackgroundImage") + public func kf_setBackgroundImage(with resource: Resource?, + for state: UIControlState, + placeholder: UIImage? = nil, + options: KingfisherOptionsInfo? = nil, + progressBlock: DownloadProgressBlock? = nil, + completionHandler: CompletionHandler? = nil) -> RetrieveImageTask + { + return kf.setBackgroundImage(with: resource, for: state, placeholder: placeholder, options: options, + progressBlock: progressBlock, completionHandler: completionHandler) + } + + /** + Cancel the background image download task bounded to the image view if it is running. + Nothing will happen if the downloading has already finished. + */ + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.cancelBackgroundImageDownloadTask` instead.", + renamed: "kf.cancelBackgroundImageDownloadTask") + public func kf_cancelBackgroundImageDownloadTask() { kf.cancelBackgroundImageDownloadTask() } + + /** + Get the image URL binded to this button for a specified state. + + - parameter state: The state that uses the specified image. + + - returns: Current URL for image. + */ + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.webURL` instead.", + renamed: "kf.webURL") + public func kf_webURL(for state: UIControlState) -> URL? { return kf.webURL(for: state) } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setWebURL") + fileprivate func kf_setWebURL(_ url: URL, for state: UIControlState) { kf.setWebURL(url, for: state) } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.webURLs") + fileprivate var kf_webURLs: NSMutableDictionary { return kf.webURLs } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setWebURLs") + fileprivate func kf_setWebURLs(_ URLs: NSMutableDictionary) { kf.setWebURLs(URLs) } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.imageTask") + fileprivate var kf_imageTask: RetrieveImageTask? { return kf.imageTask } + + @available(*, deprecated, message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setImageTask") + fileprivate func kf_setImageTask(_ task: RetrieveImageTask?) { kf.setImageTask(task) } + + /** + Get the background image URL binded to this button for a specified state. + + - parameter state: The state that uses the specified background image. + + - returns: Current URL for background image. + */ + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated. Use `button.kf.backgroundWebURL` instead.", + renamed: "kf.backgroundWebURL") + public func kf_backgroundWebURL(for state: UIControlState) -> URL? { return kf.backgroundWebURL(for: state) } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setBackgroundWebURL") + fileprivate func kf_setBackgroundWebURL(_ url: URL, for state: UIControlState) { + kf.setBackgroundWebURL(url, for: state) + } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.backgroundWebURLs") + fileprivate var kf_backgroundWebURLs: NSMutableDictionary { return kf.backgroundWebURLs } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setBackgroundWebURLs") + fileprivate func kf_setBackgroundWebURLs(_ URLs: NSMutableDictionary) { kf.setBackgroundWebURLs(URLs) } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.backgroundImageTask") + fileprivate var kf_backgroundImageTask: RetrieveImageTask? { return kf.backgroundImageTask } + + @available(*, deprecated, + message: "Extensions directly on UIButton are deprecated.",renamed: "kf.setBackgroundImageTask") + fileprivate func kf_setBackgroundImageTask(_ task: RetrieveImageTask?) { return kf.setBackgroundImageTask(task) } + +} diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock new file mode 100644 index 0000000..3a3752d --- /dev/null +++ b/Pods/Manifest.lock @@ -0,0 +1,30 @@ +PODS: + - JASON (3.0) + - Kingfisher (3.1.1) + - RxBlocking (3.0.0-beta.2): + - RxSwift (~> 3.0.0-beta.2) + - RxCocoa (3.0.0-beta.2): + - RxSwift (~> 3.0.0-beta.2) + - RxSwift (3.0.0-beta.2) + - RxTests (3.0.0-beta.2): + - RxSwift (~> 3.0.0-beta.2) + +DEPENDENCIES: + - JASON + - Kingfisher (= 3.1.1) + - RxBlocking (= 3.0.0-beta.2) + - RxCocoa (= 3.0.0-beta.2) + - RxSwift (= 3.0.0-beta.2) + - RxTests (= 3.0.0-beta.2) + +SPEC CHECKSUMS: + JASON: cf4d762e61428a20db8eaef2acb6a569a10c1801 + Kingfisher: 12b755ae697cc9f0fd3e550db8417fa1233e09ab + RxBlocking: 75dad8ed874b732da94780fdf7cf48eabf0d5d2b + RxCocoa: 1dd105d8a4e18034ccd7bd6d136445363ce67c8e + RxSwift: 0ea939d7d97cb70657190ffde8dc2a9b455778fc + RxTests: 9b696439878a1c7653bb55853af027fc261d0635 + +PODFILE CHECKSUM: 6f0018b65760ac7a8f462654e4fd7e3f3c05aae8 + +COCOAPODS: 1.0.1 diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj new file mode 100644 index 0000000..98da46c --- /dev/null +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -0,0 +1,10766 @@ + + + + + archiveVersion + 1 + classes + + objectVersion + 46 + objects + + 0151734607E8E9B5591E48D71D84F4FF + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 1DE93A359FA21F91DFBE81309E851A4A + remoteInfo + Kingfisher + + 017C4189518B612AFDC189D04629E8F5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxCollectionViewReactiveArrayDataSource.swift + path + RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift + sourceTree + <group> + + 019364E89DC52A43EA98529277D0BBF7 + + fileRef + 52F8053362D3BB5A8546AE30F4626498 + isa + PBXBuildFile + + 01C6AD05FE0BF7937FB1A8262E3B3BA3 + + fileRef + 7CA58B7B2F9AC8EEA845703250F3A9ED + isa + PBXBuildFile + + 01F5BD83B350366A28D15014200E1233 + + fileRef + F56C0F7D58610E5886976C12B083D342 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 02453D3D02A1A7567016BCE51080E01D + + fileRef + 78248535A169B4D18B95353CA60E3BC8 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 027DEADAB08AAD4C8E6F5D066E9BD043 + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + Pods_Protium.framework + path + Pods-Protium.framework + sourceTree + BUILT_PRODUCTS_DIR + + 0311349A682A62DB14645DA5AB0212B1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + KVORepresentable+Swift.swift + path + RxCocoa/Common/KVORepresentable+Swift.swift + sourceTree + <group> + + 032FABBED9149E232004836E12D82050 + + fileRef + A36D07A8CADB7102BC6A9C4ACA586AF0 + isa + PBXBuildFile + + 034014829C1E4434983CF3A690C12017 + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_ANALYZER_NONNULL + YES + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + NO + ENABLE_TESTABILITY + YES + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_DYNAMIC_NO_PIC + NO + GCC_OPTIMIZATION_LEVEL + 0 + GCC_PREPROCESSOR_DEFINITIONS + + POD_CONFIGURATION_DEBUG=1 + DEBUG=1 + $(inherited) + + GCC_SYMBOLS_PRIVATE_EXTERN + NO + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + ONLY_ACTIVE_ARCH + YES + STRIP_INSTALLED_PRODUCT + NO + SYMROOT + ${SRCROOT}/../build + + isa + XCBuildConfiguration + name + Debug + + 038B05059A9DA0E2D6D59EBAA6ABE6A4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Errors.swift + path + RxSwift/Errors.swift + sourceTree + <group> + + 03FBFD4C293E0AF1DB9139304F62FAC4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSObject+Rx+RawRepresentable.swift + path + RxCocoa/Common/Observables/NSObject+Rx+RawRepresentable.swift + sourceTree + <group> + + 03FCBFEC6B1B8210B5B90539DDCD9190 + + fileRef + 48EEFBE9569982118F6FFAFED5F2D053 + isa + PBXBuildFile + + 0417F208AAC8939D748250A3DE8C79CB + + fileRef + 43301C739484D386ACEF17E0247A2C78 + isa + PBXBuildFile + + 0474ED8873521CF7CE0FB03E357013A6 + + buildActionMask + 2147483647 + files + + AC060E57578DB3FBFB933E762A70AE99 + 400F2490B1DD46E9972337547EC334B3 + 854862FABC5DD23FCFE3161432F462D1 + 0D9FD2F6037C9780ED2681F7D5BED251 + 9641E599D681F7746C659912FD23074D + 41F1E93DA768EA68454E3BD38791C110 + 3488F32AB23FBAC003F09051A744A44F + 1CDBFB85DAE64F915C0E0CACC0CAEFCE + 98BDF4C5C9F8C1CB1C3A5A91D7A9F59D + 1271B5A60D53090F66E4B53B889A9CCB + 6191340DC2C04A43B951EFCAB861FBA7 + 0A014FF598DF57F9014B053893769353 + 96C5AFDC31FCB75E3AF354A4278BE6E6 + 31F9208F8C23959492121CD8A24A9798 + CEA8E330EBD24DDCA08B7D83AE9EF62F + 0517F4A0519344449EC19A22A17A32AF + 0489E6AEFC455DA47CF563D082060E8B + 6417EA246014E4CC7E1328930333F37A + 060571DBEE067C3A510591FD86987748 + 51564F316CE13F29F1341F621F7BE879 + 61EEBB4AD22EFFFC75F14D85FDC99051 + 481FC8A17E77B63DFFFD5EE81FB2E24D + 0DB377366DE6B80004FD7C0E57DDAC7E + 72099A70040D78A3D3429ADB63A07E6D + 2FD77D8F0036F3E3114183527F5F40F0 + CDBE4F004D462026704CCA29A51A4468 + 13D9F2B19BD3E6717D68B77A6427D895 + 4C84976D428360EDB2B3900310813EAE + 0DF991EB5C3B2F0DAF2BCB79627B03A0 + 1E227BBA46592EABEB2F206319292265 + 3CC466F4BF4B1B4B3CC99B8D8AA9DBE6 + 06BBE691CC6E6C3ED1F2D535BD4100E2 + A009846289E4E2F1076667E6D55B96D1 + 74971D2F3A502BE90C540F15274DB49A + 8E7D9DA035C6A7B92B98AE8316FEF543 + E8385A0F8DD09031BE6F619C7187EA50 + EFBBDE724A051A00E85A682A849E029F + FE11BF6FEF0B346A2421457315C2FD16 + 5D4D1BAFB4F233F7E622F414C02BB4E0 + FC124CF9CC629A63996FA5438A99CBC0 + 5297E977FB482EF9AF410BE5022EF8F8 + 13F39929A14BF4930547C626058FC216 + 2AFDEEE2A65289AD5777A37A1F8F60DA + 3708972183AE35145596156CA04388D3 + 8325065B4F4F149D519A606FF687206B + 73D3C97BA9C32375BE6F45BD9A93724F + 5EE7BE8648226B231B132B196079C10E + 935E63A7D746AFBF87316E4D9FA208AA + A90D68C4F183DA11683901517274A5FF + 24BA0AD9C3970BD4B991186163E3F657 + 7C6A74C70259816EC011421BDC787CD2 + 492FE476101AC2B2726AA5470AA07271 + CC233C1C39735A9B61B795C5380C482A + EBBCDDEBBAFA7C83ABA9840C6E4D336C + 57E1C5EEA2508034D5C59B64741AEBBD + 41F36697B93525C7DC5BC17FDC8CF431 + AC211BE23FC07668A6A1383BBBCDD1D1 + 76AD1724C8BF1D68A48D380C65459AEB + 0417F208AAC8939D748250A3DE8C79CB + 992EA74CCEFEA7DCDF92BC496105AA95 + 8ADEAF3718543CF0AAE1ED0158E94522 + 6E1427FEF1C21E9670206309DFAFE4D1 + B4FB092861BD2AD108A335B027BD3B61 + B4C599FAFF4BE26DAD1BE71037D5034E + A864A3BB83A2062E2DB2C87932A1AB99 + E3EBBA8A95A971F78E0531194A4B6CFB + 8222756B9CE80F0BF2A9A32B529851D7 + D409E2DF8A5DD29ADE368DC000C6E9D5 + 77A10B3612E6DF0728DB3B6CF31D71B1 + 42104545E4113EA12FB71E1CE03CA6B8 + DDC09AF4651F7EB2C2E77FAE1C3E3964 + 4436C39F01CB818AF3ED0FD44333CA24 + CFA84C1832F9E331C7EA43DA7DE725D4 + BC2947CFB7D0D969060848D6C189D9B6 + 7D366BF97A88596C0133E1BACE9035FB + 267C1C8B7D66066295230CCE57BFD7A6 + 195891D377CB378ECCC9E5E6D8D546BD + D7C8B6A2BD6EA4788F3B6D7540DFF000 + D22302B067FD4068C8508CE247148756 + 45A5EB0F3019D096632F24822D9D49C5 + 3B89BA5FE1DDCFEE90C19C596830CBB4 + B6A0C876DBC5A1D050188313E505B800 + 90F14D3CA725CF12B1E9CC3856478BC3 + 57D2A897196EF66AD85A13547730392F + 851DD6AA7CD03099C709CEA763A4437F + F9CFE1992664AE0C4F34FB7C23F13769 + 2BDB1A245EB1D3AB435BFA0D162378F2 + B155708CA4773A61C1AF2F88ED3AD402 + 7D6CE060AFA03580B3A84A36B4833224 + F693EA75CBD313D75E7BF9C499C269E9 + C285C5D828A00493BA41C47B5561ABAF + D1677FA94A11260649A9F35C57B515A9 + E1881263D98EF75B0004726191CC8AA1 + E6BC3ADC7A555B71F715D3E9C81D2947 + A0953F18AB838742234AA5996B066297 + 836E6F5ADF61FC72AF6F5D7795FD26DE + 93AB551642123C99EC55166FB9B04F44 + CE0893BD26C65063A93EE845FF68950D + 3D244648B52A8C1FC769F8D0F9CB1DDD + 309E7B7DA4B8EFD7D1D3E8871E2626A0 + 40639565319DFE862A48CD3608C1D2E7 + C88A702CA5DB93370E0D592555941665 + 4D5E370385E9B2BE3A0E02A8017C0EAD + 4652679DE75CB7B24049EC911B5CC77F + F2579ABC251B120658EE7E04FA5D243A + 73DB0A7B2BE2292F75FC35FB22947ACA + A474998B1599CFAD7A32E47D6B5DC0A1 + B2BF716AC3FA9C09A8016CFDABF83757 + 069AD013E197D9DA2A4CB7EEF4F2AF16 + 8BC49927E2B510441F3643D2A57DAF1C + 858FC9A30473FBC24F973F334B776217 + 455A5C4E53B0F6F87B73DB89A1CDC38C + 2C83FD0BD1F961822F0DD881AB14913A + 1F609EFECBE6900B896ED2B1A840E90B + D6A4C6F5B4808280747D3E14B7CD6659 + F35B4E721DF6AEB801593A06B9867CC0 + 238FC4DA2D1C1AF46B935EA598A597C7 + 9F40B9E3CA7B52A71C396EE968A049DA + CBABB29D090B20282926B01B82F2C05B + 13B0F8C11F410B282BF50554AC5DACB4 + D990773B61E135AD5C2092127CA19E11 + C055D103171DD80FE39B31E6F3E20BD4 + 032FABBED9149E232004836E12D82050 + 06492DEE7040E26A7B07763C08F32B32 + 73720134EC9F4A240DC81B2940FABD3B + A2F8B6C1C8F44A7B78E1A46A525F2C09 + 93A60AE74B0E41C91A1F7F86DC6135F6 + DC53B0FA1BEB7DD97A312EA29554103C + E194E3FD1197CE81144FD02A6FE47443 + 2E75061E64E43D615F95120FD6265F54 + 19276FF0BEC684C0556EDE1F1B49426C + 83134275EAD08FA0B078FB01368416A8 + F2DCB4B0FF20B99F9A6CE4E70430693F + 3BDCF4D5D4188C743257A7FD42CD54DB + DFF5DB293565A9E4C9F2243A88F7388D + 14CC962C853C41A4FF9E2550D7B76DCD + 0F0D4E2B33F039685533B72C66B563F0 + A838CFF5F4E3BD5E96617361831C5E0B + 44E33A2EC1CE2E96403EAF9A5B06598B + 81938531C065FC638D1F7942229EAC73 + C8871540DB8C08FD461E40CB755B0267 + 6A3F2A2CCC7C8F6210AD5D24265A3BA8 + A35275C5E5B2CE8110A5F77F434A361D + DAAF9D50BAC3D0D45F9A2C2D0D90CDD6 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 047F93295F4CC9EA3752C4E819848C94 + + children + + 2C34B34FBD07A433F9C2930E4787BEB1 + A34113E956A812A7DDAC95D9F50EFE2A + 8F75DF109CE3FF2D658F221A968A1612 + 09D6EB9C609BD9AEB1BF560D6C7192DF + 7CA58B7B2F9AC8EEA845703250F3A9ED + 5E4EA8DE8950109984D1C20DB34FB914 + 238791B373CDA93CC0839A4B4B2B1438 + C3B74895AB1F3A7B3048114012F38022 + 472811508BA90FF334BBAEFD4C008015 + DA9504C21EBEDF08864744E77FDAEACE + E1E0D8EFEAD0FA82CB766D828883D8D8 + EC2BE04EEBC2C95D80EDBEBF2A7AEFE2 + 8CF21CA2ED42F707A04778117CA393C8 + F8EB3C3C8B35BA6AA265CB26821D465D + B6CE376B339A9E142F219975D6B956FD + 3940091C7715CD549AE69A9D5F935021 + E7D2CE9E029F6D3C24F508100F5E7986 + 62049ECE20573E8FD72E15EA82805B40 + 48354A1FD85D920D529598821C52B2FA + 04EAC4EA9E3D3354A6A5CFEA8083BDB1 + E73B4237DA3B2466DAFBB414583FD475 + FA583C51C7B56D757466D6F32452BF76 + + isa + PBXGroup + name + Kingfisher + path + Kingfisher + sourceTree + <group> + + 04895717546E08E3950147F2A218F68C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Timer.swift + path + RxSwift/Observables/Implementations/Timer.swift + sourceTree + <group> + + 0489E6AEFC455DA47CF563D082060E8B + + fileRef + CC37612205374CE26F934A186936AD0D + isa + PBXBuildFile + + 04EAC4EA9E3D3354A6A5CFEA8083BDB1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ThreadHelper.swift + path + Sources/ThreadHelper.swift + sourceTree + <group> + + 0517F4A0519344449EC19A22A17A32AF + + fileRef + ACFB2F9D6862626D2D439265851BBD1A + isa + PBXBuildFile + + 05B0726AA7B2AB6F4C61E0B548D3254B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + CompositeDisposable.swift + path + RxSwift/Disposables/CompositeDisposable.swift + sourceTree + <group> + + 060571DBEE067C3A510591FD86987748 + + fileRef + 05B0726AA7B2AB6F4C61E0B548D3254B + isa + PBXBuildFile + + 060A43622508FB606F927D0EB886F433 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIControl+Rx.swift + path + RxCocoa/iOS/UIControl+Rx.swift + sourceTree + <group> + + 0644611748785D4A4259F32FB1CCFAB3 + + fileRef + 534EDD697643C2D6E0DFD75F5FA7E6A6 + isa + PBXBuildFile + + 06492DEE7040E26A7B07763C08F32B32 + + fileRef + 2B5F45E1C48CD5DEDE3752625DFD0B4D + isa + PBXBuildFile + + 06609935DEF174AEDF2661BA47817341 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + RxBlocking-dummy.m + sourceTree + <group> + + 0675C9C59482BBF63F4A5194702BD44D + + buildActionMask + 2147483647 + files + + CF0379F792D2BDDD7C87A9A8C12ADC0B + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 068C8E050D15BAC6E86BC247E7C1CA36 + + baseConfigurationReference + 9EE71AE913A21CAEFC39F0F7B20C8FD0 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/RxCocoa/RxCocoa-prefix.pch + INFOPLIST_FILE + Target Support Files/RxCocoa/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/RxCocoa/RxCocoa.modulemap + MTL_ENABLE_DEBUG_INFO + YES + PRODUCT_NAME + RxCocoa + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 069AD013E197D9DA2A4CB7EEF4F2AF16 + + fileRef + 6A6D5D6E9CAC72A9A938476C26ADE14E + isa + PBXBuildFile + + 06BBE691CC6E6C3ED1F2D535BD4100E2 + + fileRef + 5444BAC6249F353DA5BB7F9FDF5F585B + isa + PBXBuildFile + + 07554FF0DFB8E44BEB63CF5E84B70800 + + children + + 9D41A805B3F4121E217A22F2BD23B8F1 + 6704A508ACC928FCCE717DE9A51070B3 + C877ED8A782B3D02D32F6D8FEB6CBFFF + 1383B5661E7F94B4DF82AC5641BE42B8 + 52F8053362D3BB5A8546AE30F4626498 + BBCE9C83DA6AA3C3EF94EB5C4641183E + 9A79400B0690CEC0BF376B959B4C7B74 + 10F4DF9912C458061DBE6EAC60C44D1D + 21DF3D11967DCCBB83AC244555AEE6FF + 9F15D7981B0AADF517E3831BE57F21F9 + F99913BD0EBF168FFF11E182EEF49F95 + 28E1A58A162320B9BB2B67C61B721126 + FCBB9157BBD502DC09033D604AC8BEE8 + + isa + PBXGroup + name + RxTests + path + RxTests + sourceTree + <group> + + 07B1DB23157EA9BAD90B274E02D82220 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + 0892143A4449587AABEAF5099149E128 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + 08DD077B1B0DAC414E32C5A227E8B66A + + buildActionMask + 2147483647 + files + + E86C09D56F715CABE887E581C534BC35 + 15C269CAF3A7612BC1A3A869C93C098A + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 090DDB1C624CFFBE1C09BB7C31CFD955 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ControlTarget.swift + path + RxCocoa/Common/Observables/Implementations/ControlTarget.swift + sourceTree + <group> + + 0912BE80640FD3244ED04DFDDF226908 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SerialDispatchQueueScheduler.swift + path + RxSwift/Schedulers/SerialDispatchQueueScheduler.swift + sourceTree + <group> + + 091461F9A2123AC4274FE71E2CDA3F69 + + includeInIndex + 1 + isa + PBXFileReference + path + Pods-ProtiumUITests.modulemap + sourceTree + <group> + + 09395FC0E5B36FC60CCC2DAEB6869A1D + + includeInIndex + 1 + isa + PBXFileReference + path + RxBlocking.modulemap + sourceTree + <group> + + 09AF58BAA040C16FDCD91B85AFFB216A + + fileRef + 99B56EDA75E62E6F2DF735CF2E8A84D0 + isa + PBXBuildFile + + 09D6EB9C609BD9AEB1BF560D6C7192DF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Filter.swift + path + Sources/Filter.swift + sourceTree + <group> + + 0A014FF598DF57F9014B053893769353 + + fileRef + 2AF999DF6BF4FC4F1682B33D6DD84875 + isa + PBXBuildFile + + 0A51A05F8839754EC8D210A66B76DB4A + + fileRef + FFBD546CB3D4110D355788C3A43E8A51 + isa + PBXBuildFile + + 0A5A53E7313E000D2F232C5ABB279E70 + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + Pods_ProtiumTests.framework + path + Pods-ProtiumTests.framework + sourceTree + BUILT_PRODUCTS_DIR + + 0A8016EB358499C16B9EC95E2B285391 + + fileRef + D285C0611719C40B5DB70677582F237C + isa + PBXBuildFile + + 0AC4FF53197EEEB5500B9762B4D381DD + + fileRef + D0AEE6B32E344932FB99095671FEFF17 + isa + PBXBuildFile + + 0B6FF9B5D42EC08B8253C14320C8D35C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIAlertAction+Rx.swift + path + RxCocoa/iOS/UIAlertAction+Rx.swift + sourceTree + <group> + + 0BCE650BA734D8134846A034078C3277 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 61DE7C52A85DB9EA328A7BF08F9B28A1 + remoteInfo + RxSwift + + 0C0AF2B6553D84BC43675EA85DF20CF7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + VirtualTimeScheduler.swift + path + RxSwift/Schedulers/VirtualTimeScheduler.swift + sourceTree + <group> + + 0C4BA5EB55C9F21D294076D2AA18B01A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + _RXDelegateProxy.h + path + RxCocoa/Common/_RXDelegateProxy.h + sourceTree + <group> + + 0C4FE3EA81EDF1AA8CC8B317B3AE11D4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTableViewDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift + sourceTree + <group> + + 0C5D2CF505402F2F3692F22EBB5AC10D + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + 0C6241EC2852D3C55D8C9983528FB2E0 + + fileRef + 4B3895EF17D78A7A87818C7EEB4CF2D9 + isa + PBXBuildFile + + 0D6422275C9AACC2B422084F4A5C3089 + + fileRef + E03446357CE15647936B4979A933C069 + isa + PBXBuildFile + + 0D72171ABB370853B371A14013E4AC7A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RefCount.swift + path + RxSwift/Observables/Implementations/RefCount.swift + sourceTree + <group> + + 0D9FD2F6037C9780ED2681F7D5BED251 + + fileRef + 27043210461F447C16A04FE9F94A163A + isa + PBXBuildFile + + 0DB377366DE6B80004FD7C0E57DDAC7E + + fileRef + 629C7CFDBD4ED17D35524C8E6CC27780 + isa + PBXBuildFile + + 0DF991EB5C3B2F0DAF2BCB79627B03A0 + + fileRef + 895E56E4245B4A7099A02340419C9941 + isa + PBXBuildFile + + 0EA5F4B9AC952EE0877A6B59786649B8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Scan.swift + path + RxSwift/Observables/Implementations/Scan.swift + sourceTree + <group> + + 0F0D4E2B33F039685533B72C66B563F0 + + fileRef + F400AE7E8D81785EE7B3307C4D4F5C2A + isa + PBXBuildFile + + 0FE7E2183CFA9372B26D6AAB3552F84A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + RxTests.xcconfig + sourceTree + <group> + + 10900F282BCFAEA50F569FD199B316E9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Using.swift + path + RxSwift/Observables/Implementations/Using.swift + sourceTree + <group> + + 10B180164516CFE0CC2BB09DB432D249 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSObject+Rx+KVORepresentable.swift + path + RxCocoa/Common/Observables/NSObject+Rx+KVORepresentable.swift + sourceTree + <group> + + 10D9E87EB460B8E2BF8AD3B372F41508 + + fileRef + CA76F98AC131EE1F1AE355BB2B62AFAF + isa + PBXBuildFile + + 10F013E7DE672B58780BCADB7AE6BC66 + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + RxSwift.framework + path + RxSwift.framework + sourceTree + BUILT_PRODUCTS_DIR + + 10F4DF9912C458061DBE6EAC60C44D1D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TestableObservable.swift + path + RxTests/TestableObservable.swift + sourceTree + <group> + + 1102F622EA7208C35E65515E20D05F26 + + baseConfigurationReference + 56771D310FF8AB82A55D3B869FABAC83 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/RxBlocking/RxBlocking-prefix.pch + INFOPLIST_FILE + Target Support Files/RxBlocking/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/RxBlocking/RxBlocking.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + RxBlocking + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + 1237FA520495ED6EB62C1AC57B854FBD + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Pods-Protium-acknowledgements.plist + sourceTree + <group> + + 1271B5A60D53090F66E4B53B889A9CCB + + fileRef + D70E90D2BB0AE9D7A8471CF499A76E26 + isa + PBXBuildFile + + 12E572E66F00FB656C253E61EA4F0BF5 + + fileRef + 9F15D7981B0AADF517E3831BE57F21F9 + isa + PBXBuildFile + + 1383B5661E7F94B4DF82AC5641BE42B8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + HotObservable.swift + path + RxTests/HotObservable.swift + sourceTree + <group> + + 13B0F8C11F410B282BF50554AC5DACB4 + + fileRef + 8F2626E6E89E1FB8D4BBBE72B59DE13F + isa + PBXBuildFile + + 13D9F2B19BD3E6717D68B77A6427D895 + + fileRef + ED5FE2D000151E521DCF9AC00539C579 + isa + PBXBuildFile + + 13F39929A14BF4930547C626058FC216 + + fileRef + 038B05059A9DA0E2D6D59EBAA6ABE6A4 + isa + PBXBuildFile + + 14763DA373DE3A96D3D1B84FED33C8C7 + + baseConfigurationReference + 79E908B32EF1F8C343DBBAF5626631F4 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + INFOPLIST_FILE + Target Support Files/Pods-Protium/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/Pods-Protium/Pods-Protium.modulemap + MTL_ENABLE_DEBUG_INFO + YES + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_BUNDLE_IDENTIFIER + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + PRODUCT_NAME + Pods_Protium + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 1477F4027E396D01C0C03B7C90E40905 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + DistinctUntilChanged.swift + path + RxSwift/Observables/Implementations/DistinctUntilChanged.swift + sourceTree + <group> + + 14CC962C853C41A4FF9E2550D7B76DCD + + fileRef + 10900F282BCFAEA50F569FD199B316E9 + isa + PBXBuildFile + + 15C269CAF3A7612BC1A3A869C93C098A + + fileRef + 2D6090EE8DEF9C120BED3D29FE78A5CC + isa + PBXBuildFile + + 171EE8AECB226C2598A7237173C8811A + + baseConfigurationReference + 56D3F740E3469FE408703A45B57E1B4E + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/Kingfisher/Kingfisher-prefix.pch + INFOPLIST_FILE + Target Support Files/Kingfisher/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/Kingfisher/Kingfisher.modulemap + MTL_ENABLE_DEBUG_INFO + YES + PRODUCT_NAME + Kingfisher + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 181700063DF3DF2EEAF59844A8F5C425 + + fileRef + C5FAA08B6A2A52648DEDACA8859EFDC3 + isa + PBXBuildFile + + 182F5545BD7E16461C051038B2C4C3CC + + fileRef + A34113E956A812A7DDAC95D9F50EFE2A + isa + PBXBuildFile + + 18665CEEBC37F18B40157E571B943866 + + buildActionMask + 2147483647 + files + + 28C415591D3F5AAC7A5D635A9F48C8B2 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 190F5E93C0C31880B0AE65105FEAA96D + + includeInIndex + 1 + isa + PBXFileReference + path + Pods-Protium.modulemap + sourceTree + <group> + + 19276FF0BEC684C0556EDE1F1B49426C + + fileRef + 361BE5E078278DDBED70EBEEF02C592C + isa + PBXBuildFile + + 194C5FBF7C6DDC8CED54FF28B85465AC + + fileRef + 650F55EC419A89D0A43C458F4FE710CF + isa + PBXBuildFile + + 195891D377CB378ECCC9E5E6D8D546BD + + fileRef + A921505BA3663527E1F8995261D6A9C2 + isa + PBXBuildFile + + 197E41CA9E9F02081E0321D327AC5BC9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SingleAsync.swift + path + RxSwift/Observables/Implementations/SingleAsync.swift + sourceTree + <group> + + 19B88CEEBF6856885A98E9378AD1B651 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Cancelable.swift + path + RxSwift/Cancelable.swift + sourceTree + <group> + + 1A2DF02B542A17161162CA48FE208D3C + + buildActionMask + 2147483647 + files + + 473A9085410554074ED17F48C4BB8308 + 8DBA83DA7327FE5D6C8D4AEA11B88256 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 1A6F678A5904F782CF07C613FE146E28 + + children + + E90658D75782B6988AA960861393B6F0 + B239B0E7E196D400399060B6FAE28C01 + 9EE71AE913A21CAEFC39F0F7B20C8FD0 + 486D36E7644B12189C47F299E6D3ED15 + 3ADF8B91234802F59604724C0B6484AE + D0EB34A0C99F4F66F73602585083C0F1 + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/RxCocoa + sourceTree + <group> + + 1A835E48F19DF8B300F1869B68105661 + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + RxTests.framework + path + RxTests.framework + sourceTree + BUILT_PRODUCTS_DIR + + 1AA3C373731A06DA968ABD6626F084F4 + + isa + PBXTargetDependency + name + RxTests + target + 39B24F6A272FFEB2BCF79FC06934033B + targetProxy + 41286A5015567E6AB659C9164B019C65 + + 1B732A588AF08063716183A539B8D5FC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UISwitch+Rx.swift + path + RxCocoa/iOS/UISwitch+Rx.swift + sourceTree + <group> + + 1B8C2060305BDBAC73F070F4E0DF22AC + + buildConfigurationList + 7265651D413AF8BDE4A873047593520B + buildPhases + + 8AA5BB6A5869BD851E897B7176B797B8 + 898D7BD54C472EE6CAE0996B532E68AD + 388F6C387C69C26FB74F38EDAB19B5E2 + + buildRules + + dependencies + + 5DD7A2148FD43725F283C9C64D9B9A32 + EBF46630EADC2FAD1ACEC88BCD3C3EB5 + 1AA3C373731A06DA968ABD6626F084F4 + + isa + PBXNativeTarget + name + Pods-ProtiumTests + productName + Pods-ProtiumTests + productReference + 0A5A53E7313E000D2F232C5ABB279E70 + productType + com.apple.product-type.framework + + 1C15EB660EABC8BC39A7368A8C505A51 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Single.swift + path + RxSwift/Observables/Observable+Single.swift + sourceTree + <group> + + 1C568444D9D22A3B4CB56D814BB741E9 + + fileRef + 66717BF3866489EDA0223699A5AD8002 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 1C74B0A9F196309C61B7C9887C6C4346 + + baseConfigurationReference + 0FE7E2183CFA9372B26D6AAB3552F84A + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/RxTests/RxTests-prefix.pch + INFOPLIST_FILE + Target Support Files/RxTests/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/RxTests/RxTests.modulemap + MTL_ENABLE_DEBUG_INFO + YES + PRODUCT_NAME + RxTests + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 1CDBFB85DAE64F915C0E0CACC0CAEFCE + + fileRef + 8827CF45B41D2C8ED46F04506DD7C360 + isa + PBXBuildFile + + 1CF77BA0DF6F148591F0939A3A05A88C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TakeUntil.swift + path + RxSwift/Observables/Implementations/TakeUntil.swift + sourceTree + <group> + + 1D3FC1CE3FE577EE0EE0A12EABBF8881 + + fileRef + E379F36B5207745C8A1B99CC359DBD31 + isa + PBXBuildFile + + 1DE93A359FA21F91DFBE81309E851A4A + + buildConfigurationList + 363F048EAA6933FA24F8FFB2537AE0B0 + buildPhases + + 8BF3B04A51B134FAD7615A5226D92E6F + 1A2DF02B542A17161162CA48FE208D3C + C07D2A8B30A1C35A24C6B9D689290840 + + buildRules + + dependencies + + isa + PBXNativeTarget + name + Kingfisher + productName + Kingfisher + productReference + 3C8D0D32B8DDE15F7D9020B5BD8FEA1E + productType + com.apple.product-type.framework + + 1E227BBA46592EABEB2F206319292265 + + fileRef + E8BAE9743CC9B50BE9E07F8A4ACE1598 + isa + PBXBuildFile + + 1E4EB7DC68C633870CCEA7B3696CFE5E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Queue.swift + path + RxSwift/DataStructures/Queue.swift + sourceTree + <group> + + 1EB02E8721A3013E7FEF1F5AC1EAA7C6 + + fileRef + 845114B594E213F222279AE506D0A9CF + isa + PBXBuildFile + + 1EEA7E8084A096D2D2630495B31FC055 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + Kingfisher-prefix.pch + sourceTree + <group> + + 1F609EFECBE6900B896ED2B1A840E90B + + fileRef + 2D8A0ABE3394CA2F318CAFD6DD2A6C4D + isa + PBXBuildFile + + 1F76644C74DADEF3E8006C6BE6315D63 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-ProtiumTests-frameworks.sh + sourceTree + <group> + + 1FBC5B6799FDC43C75C525EC261151BC + + isa + PBXTargetDependency + name + RxSwift + target + 61DE7C52A85DB9EA328A7BF08F9B28A1 + targetProxy + F442790CE991A7754C5A6FFFCEAAA9C3 + + 2042E42E81B4A39137D2295C447D72DD + + buildActionMask + 2147483647 + files + + 7FFC8A78E4F13D62B71A476EB0DAB7FB + 757703C478EFC5FB375DB50C508AD817 + AADCB317A4849755366BDEF090F61931 + A209F6103AB4B65FF8E25ED8902B7F23 + 019364E89DC52A43EA98529277D0BBF7 + DD57063D51EB120D785510A8471EC423 + 6F38BAAA8577529C70E75B7F87D6C33F + F8F9C29EFDD33E36265635D3A54225C5 + 7052060434DBE47F01391B10B55028F7 + AA44EA2EFE5D88346BDAE163AB46FE1F + 12E572E66F00FB656C253E61EA4F0BF5 + DAAFE269E211D287FB9D82A6EBA712EC + B68A4A6298BB7B1343CEDDE1E17C3C69 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 214F385B284CBAE6CA1926C5C1F4EC6C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTabBarDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift + sourceTree + <group> + + 215CDB2D36A5E04D1D63BEE4B4788C98 + + fileRef + E262278CEF901FD6DDF1AF07A1CC8ABE + isa + PBXBuildFile + + 21DF3D11967DCCBB83AC244555AEE6FF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TestableObserver.swift + path + RxTests/TestableObserver.swift + sourceTree + <group> + + 224415781205C53C4F26E4452110C74B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SharedSequence+Operators+arity.swift + path + RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators+arity.swift + sourceTree + <group> + + 2244D0D520DC6392DAAE901A2BEC8B79 + + fileRef + B6CE376B339A9E142F219975D6B956FD + isa + PBXBuildFile + + 22D2DAD49819F437A4CF59CAF49133C9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AddRef.swift + path + RxSwift/Observables/Implementations/AddRef.swift + sourceTree + <group> + + 22E9344A07F1A42B5AE30A2645B4AD1C + + fileRef + 42E62F61978E37E76029C07CB7842DB4 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 233D1F9362FCB6AECAA53D511884738A + + fileRef + C148730C48D1F8C7CC630677E90651F7 + isa + PBXBuildFile + + 238791B373CDA93CC0839A4B4B2B1438 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ImageDownloader.swift + path + Sources/ImageDownloader.swift + sourceTree + <group> + + 238FC4DA2D1C1AF46B935EA598A597C7 + + fileRef + 28E4F90636ABD0A49758F9924EF1F716 + isa + PBXBuildFile + + 246047BF8F2DC2D57A862CB082F4E4F6 + + fileRef + C884C04605138975C27F2F3E0C7C3F65 + isa + PBXBuildFile + + 246381E3BBFEFF002BEC679D98303558 + + fileRef + 0C4BA5EB55C9F21D294076D2AA18B01A + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 24B0711D45694743CFACB12DA5CDD32D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + _RX.m + path + RxCocoa/Common/_RX.m + sourceTree + <group> + + 24BA0AD9C3970BD4B991186163E3F657 + + fileRef + 44F8DEF97211D8DF786FAA3638623DBB + isa + PBXBuildFile + + 24E681EF4F12074CD140F35FB08F84E3 + + fileRef + 224415781205C53C4F26E4452110C74B + isa + PBXBuildFile + + 2530E34DBE5541807576CC5A2DD2CF15 + + fileRef + E3C5F98E92B9F961686689CBAC0014B0 + isa + PBXBuildFile + + 2636AE31BE4C89FA6FD121DB3CC0A90A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObservableType+Extensions.swift + path + RxSwift/ObservableType+Extensions.swift + sourceTree + <group> + + 266BAF6A5F661616F221F2B37657E737 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + 267507D7FD9113EBB56B260245106410 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Just.swift + path + RxSwift/Observables/Implementations/Just.swift + sourceTree + <group> + + 267C1C8B7D66066295230CCE57BFD7A6 + + fileRef + 6B19234D48C03E82E40AA3A861D87BE8 + isa + PBXBuildFile + + 26B0D041E461A41D1743E36BB6B3AA62 + + fileRef + 5896F0393F317866346747243D170436 + isa + PBXBuildFile + + 27043210461F447C16A04FE9F94A163A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AnonymousInvocable.swift + path + RxSwift/Schedulers/Internal/AnonymousInvocable.swift + sourceTree + <group> + + 2790EB118B15B71CDB9574420065104D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Sink.swift + path + RxSwift/Observables/Implementations/Sink.swift + sourceTree + <group> + + 2794F2859B1F2A6B377B8812D5CCC2A0 + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + 27A7DF7FD67115F916ED7EC6863F2CF2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIRefreshControl+Rx.swift + path + RxCocoa/iOS/UIRefreshControl+Rx.swift + sourceTree + <group> + + 27CED8986A1FE6C98DA1A73660AC5EE0 + + fileRef + 017C4189518B612AFDC189D04629E8F5 + isa + PBXBuildFile + + 28262F04A577573ED9B28FD26CAB1A5B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-ProtiumTests-resources.sh + sourceTree + <group> + + 2835BE61F1F6C00428ECE172ACD1272A + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + Pods_ProtiumUITests.framework + path + Pods-ProtiumUITests.framework + sourceTree + BUILT_PRODUCTS_DIR + + 2863A9B3700F150130A3F2186CB985E4 + + fileRef + 4AC768BD9B5A00FEBF7113EBB5C13977 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 28665FE80851BA4018C3B6CEB8D11565 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SubjectType.swift + path + RxSwift/Subjects/SubjectType.swift + sourceTree + <group> + + 28C415591D3F5AAC7A5D635A9F48C8B2 + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + 28E1A58A162320B9BB2B67C61B721126 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + XCTest+Rx.swift + path + RxTests/XCTest+Rx.swift + sourceTree + <group> + + 28E4F90636ABD0A49758F9924EF1F716 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + StartWith.swift + path + RxSwift/Observables/Implementations/StartWith.swift + sourceTree + <group> + + 291A9E9C31B440703E32250E44BC807E + + baseConfigurationReference + A3633765E42B66E74FFC904D347B8F7D + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/RxSwift/RxSwift-prefix.pch + INFOPLIST_FILE + Target Support Files/RxSwift/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/RxSwift/RxSwift.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + RxSwift + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + 2AF999DF6BF4FC4F1682B33D6DD84875 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + BooleanDisposable.swift + path + RxSwift/Disposables/BooleanDisposable.swift + sourceTree + <group> + + 2AFDEEE2A65289AD5777A37A1F8F60DA + + fileRef + FE4BBBEEE8D120C6BFF816038A039476 + isa + PBXBuildFile + + 2B5F45E1C48CD5DEDE3752625DFD0B4D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SynchronizedOnType.swift + path + RxSwift/Concurrency/SynchronizedOnType.swift + sourceTree + <group> + + 2B8EA0D0B158902C318C82F9C231B360 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UITableView+Rx.swift + path + RxCocoa/iOS/UITableView+Rx.swift + sourceTree + <group> + + 2BC45C1D85A9069663C54CC030BE9FD5 + + fileRef + 44475F4AF55481DA82EE8F4959F4F6B7 + isa + PBXBuildFile + + 2BDB1A245EB1D3AB435BFA0D162378F2 + + fileRef + 8FA96819840E9DB6C2A7A5129A63A27D + isa + PBXBuildFile + + 2C34B34FBD07A433F9C2930E4787BEB1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AnimatedImageView.swift + path + Sources/AnimatedImageView.swift + sourceTree + <group> + + 2C534BA43D1B0A9C1DFC4499CDFFFE46 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SkipWhile.swift + path + RxSwift/Observables/Implementations/SkipWhile.swift + sourceTree + <group> + + 2C83FD0BD1F961822F0DD881AB14913A + + fileRef + E67E71475E217C4D0E8169FB56D4E77D + isa + PBXBuildFile + + 2CCFCE6F6BC1B2744A6CAE46739803D2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TextInput.swift + path + RxCocoa/Common/TextInput.swift + sourceTree + <group> + + 2D6090EE8DEF9C120BED3D29FE78A5CC + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + path + RxSwift.framework + sourceTree + BUILT_PRODUCTS_DIR + + 2D89B097483A348B1246FED237C80E11 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ShareReplay1.swift + path + RxSwift/Observables/Implementations/ShareReplay1.swift + sourceTree + <group> + + 2D8A0ABE3394CA2F318CAFD6DD2A6C4D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SkipUntil.swift + path + RxSwift/Observables/Implementations/SkipUntil.swift + sourceTree + <group> + + 2D8BAB3C320BF917B39606398D8471CF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Repeat.swift + path + RxSwift/Observables/Implementations/Repeat.swift + sourceTree + <group> + + 2D8E8EC45A3A1A1D94AE762CB5028504 + + buildConfigurations + + 034014829C1E4434983CF3A690C12017 + C7E474A03CAE21F1CB6046E7344C59BD + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 2DD7044B334E0B0EF8F5ED322484233B + + includeInIndex + 1 + isa + PBXFileReference + path + RxTests.modulemap + sourceTree + <group> + + 2E75061E64E43D615F95120FD6265F54 + + fileRef + 1CF77BA0DF6F148591F0939A3A05A88C + isa + PBXBuildFile + + 2EFAB4427F44FF51FC350BC9635B0056 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UINavigationItem+Rx.swift + path + RxCocoa/iOS/UINavigationItem+Rx.swift + sourceTree + <group> + + 2F0965C1D21DAB69E029693B70F76CC8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ImmediateScheduler.swift + path + RxSwift/Schedulers/ImmediateScheduler.swift + sourceTree + <group> + + 2FD77D8F0036F3E3114183527F5F40F0 + + fileRef + E788EFB588DDA195197D9ED3563AA52C + isa + PBXBuildFile + + 2FEA0A60B2BAF5AA499E5F8903C53227 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Debug.swift + path + RxSwift/Observables/Implementations/Debug.swift + sourceTree + <group> + + 3015B9575200FA98F8C7F92704D4FC1D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-Protium.release.xcconfig + sourceTree + <group> + + 3028D2AF9AE52FAB06642186A23E39ED + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + WithLatestFrom.swift + path + RxSwift/Observables/Implementations/WithLatestFrom.swift + sourceTree + <group> + + 309E7B7DA4B8EFD7D1D3E8871E2626A0 + + fileRef + 58F81CAA492FE07017BB7C4C5DCC61EE + isa + PBXBuildFile + + 30A32126A828680D3317DA6D6C2B1BC6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SchedulerType.swift + path + RxSwift/SchedulerType.swift + sourceTree + <group> + + 3160C670FE54847CA02BE1FFBA62AABF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSTextStorage+Rx.swift + path + RxCocoa/iOS/NSTextStorage+Rx.swift + sourceTree + <group> + + 31BE518A3E79AE3137EC2531B1DCD676 + + buildActionMask + 2147483647 + files + + BB88725F8AC17B17D032440A71A5F430 + 919F5662A2CDA8F088F4352D9F280F99 + A6A06B3107D0D2AF036624F22508445E + 181700063DF3DF2EEAF59844A8F5C425 + E19E35C59A47E156CEFC8E905629133B + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 31F9208F8C23959492121CD8A24A9798 + + fileRef + 19B88CEEBF6856885A98E9378AD1B651 + isa + PBXBuildFile + + 3364BD43E9F12A6322DF2CDCF2FD5513 + + buildConfigurations + + 88EFDBB9E8543D84BF2BDD2DEA41DD45 + 291A9E9C31B440703E32250E44BC807E + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 33A585A7E2894DD5391E0E0AF09A9005 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Platform.Darwin.swift + path + RxSwift/Platform/Platform.Darwin.swift + sourceTree + <group> + + 33DF4B134C34804BCF18850132DA29A9 + + fileRef + C3B74895AB1F3A7B3048114012F38022 + isa + PBXBuildFile + + 34019C7FD752FADE91CF6CE446D4E5F3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text + path + Pods-ProtiumTests-acknowledgements.markdown + sourceTree + <group> + + 340903F7309E583AB3002A2761220076 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AnyObserver.swift + path + RxSwift/AnyObserver.swift + sourceTree + <group> + + 3488F32AB23FBAC003F09051A744A44F + + fileRef + 340903F7309E583AB3002A2761220076 + isa + PBXBuildFile + + 34E3F284A9A678C1DB6C982018099167 + + isa + PBXTargetDependency + name + RxCocoa + target + ADDC61C64160A002293A6F9DBE4C9073 + targetProxy + 942E7C087C06931F99F7B74636F37F07 + + 355578620F452D5AE2DBCF11E3DE5DB9 + + fileRef + 6EAA7D7CF09BA6AD517FA9FA4CCA9BD2 + isa + PBXBuildFile + + 35F13ACCB05044E146B13BCFD98D442F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-ProtiumUITests.debug.xcconfig + sourceTree + <group> + + 361BE5E078278DDBED70EBEEF02C592C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TakeWhile.swift + path + RxSwift/Observables/Implementations/TakeWhile.swift + sourceTree + <group> + + 363F048EAA6933FA24F8FFB2537AE0B0 + + buildConfigurations + + 171EE8AECB226C2598A7237173C8811A + 6A06DCF8D5A2B04AD95F8A4A98535B0D + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 36730F6F2D4279BA1D7AF40EA756D893 + + buildConfigurationList + C111769B1B854C4BEB63516871DBE9F4 + buildPhases + + 82C1BC6BD6B41CADE460952602C8786B + 18665CEEBC37F18B40157E571B943866 + 8FADF69C866E58C9960100EA05ED48E6 + + buildRules + + dependencies + + isa + PBXNativeTarget + name + JASON + productName + JASON + productReference + FE2101ADAC03130EE66F908F4800E89B + productType + com.apple.product-type.framework + + 3708972183AE35145596156CA04388D3 + + fileRef + 7F3B0684BDA50424678D0F04F5F4B6A9 + isa + PBXBuildFile + + 371F2E7759D965A93E641FAE90B0500B + + fileRef + FEA5932D5FEBCA7EDA528501AE376A4D + isa + PBXBuildFile + + 37362BADF5A441DC563FA0AC893BB66A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + RxTests-prefix.pch + sourceTree + <group> + + 37E5DAEE75E2E2974B4AB3C96876F915 + + fileRef + ABC08336AA7ACC39F45BF45EACDE1A99 + isa + PBXBuildFile + + 388F6C387C69C26FB74F38EDAB19B5E2 + + buildActionMask + 2147483647 + files + + 22E9344A07F1A42B5AE30A2645B4AD1C + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 39003651A2D53C84180E05295CA048D8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-Protium-resources.sh + sourceTree + <group> + + 3940091C7715CD549AE69A9D5F935021 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + KingfisherOptionsInfo.swift + path + Sources/KingfisherOptionsInfo.swift + sourceTree + <group> + + 39590BB12A92F11CFDB6FBEA487FFAA9 + + fileRef + FFFB24C22ED88AC2A8D2FE07CF4D132A + isa + PBXBuildFile + + 39B24F6A272FFEB2BCF79FC06934033B + + buildConfigurationList + E35C8326CA9BEE6593219AA42FBC5EC0 + buildPhases + + 2042E42E81B4A39137D2295C447D72DD + BA14536EA6AD43498D71C9B39E3D176D + F2910922D371DEA0920A3CE562114822 + + buildRules + + dependencies + + AC111E27AB9BFEF15F7622E52079125A + + isa + PBXNativeTarget + name + RxTests + productName + RxTests + productReference + 1A835E48F19DF8B300F1869B68105661 + productType + com.apple.product-type.framework + + 3A86D7D6963BC3877BAEAF918A175BB6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-Protium-frameworks.sh + sourceTree + <group> + + 3AC352A7372DE1312F4CF84A13D922A2 + + fileRef + 27A7DF7FD67115F916ED7EC6863F2CF2 + isa + PBXBuildFile + + 3ADF8B91234802F59604724C0B6484AE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + RxCocoa-prefix.pch + sourceTree + <group> + + 3B89BA5FE1DDCFEE90C19C596830CBB4 + + fileRef + 7BEAA159F6410024740B67A7033917F8 + isa + PBXBuildFile + + 3BA85BD01AF66501D1A292CD7C6B8606 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSNotificationCenter+Rx.swift + path + RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift + sourceTree + <group> + + 3BDCF4D5D4188C743257A7FD42CD54DB + + fileRef + 04895717546E08E3950147F2A218F68C + isa + PBXBuildFile + + 3C8D0D32B8DDE15F7D9020B5BD8FEA1E + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + Kingfisher.framework + path + Kingfisher.framework + sourceTree + BUILT_PRODUCTS_DIR + + 3CC466F4BF4B1B4B3CC99B8D8AA9DBE6 + + fileRef + EA28930B5625C64AFECCBFB82B67BF7D + isa + PBXBuildFile + + 3D244648B52A8C1FC769F8D0F9CB1DDD + + fileRef + 0EA5F4B9AC952EE0877A6B59786649B8 + isa + PBXBuildFile + + 3DB9D579E5A49A54172909880221ACD2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ControlProperty.swift + path + RxCocoa/Common/CocoaUnits/ControlProperty.swift + sourceTree + <group> + + 3F5CFDB8A74BC8B4536EAAEA77E3257F + + fileRef + 3DB9D579E5A49A54172909880221ACD2 + isa + PBXBuildFile + + 3F7CEC0791C382ADFDD9868678B0BAF4 + + fileRef + 85E87837B5BEA6532026C6A4D00FEEB5 + isa + PBXBuildFile + + 3F92AD702FE8DB10D2C455DC7DD07E7C + + fileRef + 214F385B284CBAE6CA1926C5C1F4EC6C + isa + PBXBuildFile + + 3FB72F9120A7F5D338C8EBD9FC42C1E6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + MainScheduler.swift + path + RxSwift/Schedulers/MainScheduler.swift + sourceTree + <group> + + 3FD268C5E6003DF678ADC483EFF33DA2 + + fileRef + 8F75DF109CE3FF2D658F221A968A1612 + isa + PBXBuildFile + + 3FDB77B3E0EFC73632371DB535291C02 + + fileRef + 78EED0DEED471E856C5ED80DB13D2B43 + isa + PBXBuildFile + + 4003EF315D8605C2D2CED4F4013AB827 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TailRecursiveSink.swift + path + RxSwift/Observers/TailRecursiveSink.swift + sourceTree + <group> + + 400F2490B1DD46E9972337547EC334B3 + + fileRef + 7DD91369A74D78F8BD5CF6229BCDCA7F + isa + PBXBuildFile + + 40639565319DFE862A48CD3608C1D2E7 + + fileRef + F8256B56314777FFBA9DB2DED3FECA70 + isa + PBXBuildFile + + 4077E724CCEF57FAE1073BDF82482831 + + buildActionMask + 2147483647 + files + + 7AA3223FC5A46B63C5229DB2E50C2443 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 41286A5015567E6AB659C9164B019C65 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 39B24F6A272FFEB2BCF79FC06934033B + remoteInfo + RxTests + + 413F2DF12689619DF897061C8313B6C1 + + fileRef + ACE36EEF7E07ECCEC2C82341CDD9AFA7 + isa + PBXBuildFile + + 416680E5D51ACB06A832967877B08B97 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + VirtualTimeConverterType.swift + path + RxSwift/Schedulers/VirtualTimeConverterType.swift + sourceTree + <group> + + 4187C92AE10ACBBAC05BB7C37D2199CC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SequenceType.swift + path + Source/SequenceType.swift + sourceTree + <group> + + 41F1E93DA768EA68454E3BD38791C110 + + fileRef + A76534D7DFD6D1BA2BA0DC506787DF58 + isa + PBXBuildFile + + 41F36697B93525C7DC5BC17FDC8CF431 + + fileRef + 3FB72F9120A7F5D338C8EBD9FC42C1E6 + isa + PBXBuildFile + + 42104545E4113EA12FB71E1CE03CA6B8 + + fileRef + C166C5948C14F8018BEEB953ACC5C61B + isa + PBXBuildFile + + 42E62F61978E37E76029C07CB7842DB4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + Pods-ProtiumTests-umbrella.h + sourceTree + <group> + + 43301C739484D386ACEF17E0247A2C78 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Multicast.swift + path + RxSwift/Observables/Implementations/Multicast.swift + sourceTree + <group> + + 4436C39F01CB818AF3ED0FD44333CA24 + + fileRef + 561BD0A4BA8178289D9D390FF39EDB54 + isa + PBXBuildFile + + 443C35A369CCEAEA5FCE8316FA075DBB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Debug.swift + path + RxSwift/Observables/Observable+Debug.swift + sourceTree + <group> + + 44475F4AF55481DA82EE8F4959F4F6B7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Pods-Protium-dummy.m + sourceTree + <group> + + 44E33A2EC1CE2E96403EAF9A5B06598B + + fileRef + 0C0AF2B6553D84BC43675EA85DF20CF7 + isa + PBXBuildFile + + 44F8DEF97211D8DF786FAA3638623DBB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + InfiniteSequence.swift + path + RxSwift/DataStructures/InfiniteSequence.swift + sourceTree + <group> + + 4520CB2833BB5C1EA31EC7487B5308C5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-ProtiumTests.release.xcconfig + sourceTree + <group> + + 455A5C4E53B0F6F87B73DB89A1CDC38C + + fileRef + 2790EB118B15B71CDB9574420065104D + isa + PBXBuildFile + + 45A5EB0F3019D096632F24822D9D49C5 + + fileRef + 33A585A7E2894DD5391E0E0AF09A9005 + isa + PBXBuildFile + + 4652679DE75CB7B24049EC911B5CC77F + + fileRef + 30A32126A828680D3317DA6D6C2B1BC6 + isa + PBXBuildFile + + 4655203602365755D2133A8C58668CEA + + includeInIndex + 1 + isa + PBXFileReference + path + JASON.modulemap + sourceTree + <group> + + 46854386CD29841A6994B7E6B27383FB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ItemEvents.swift + path + RxCocoa/iOS/Events/ItemEvents.swift + sourceTree + <group> + + 472811508BA90FF334BBAEFD4C008015 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ImageProcessor.swift + path + Sources/ImageProcessor.swift + sourceTree + <group> + + 473A9085410554074ED17F48C4BB8308 + + fileRef + BE7EC58F85D775B37FAA1845910E3777 + isa + PBXBuildFile + + 481FC8A17E77B63DFFFD5EE81FB2E24D + + fileRef + C1E011B6F3D8C6B99656B7499EB2CC3F + isa + PBXBuildFile + + 48354A1FD85D920D529598821C52B2FA + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + String+MD5.swift + path + Sources/String+MD5.swift + sourceTree + <group> + + 486D36E7644B12189C47F299E6D3ED15 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + RxCocoa-dummy.m + sourceTree + <group> + + 48C983C5746352F6425F616946521659 + + buildActionMask + 2147483647 + files + + 4FB218EE01346D97B5753D43DB5F6023 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 48EEFBE9569982118F6FFAFED5F2D053 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UITabBarItem+Rx.swift + path + RxCocoa/iOS/UITabBarItem+Rx.swift + sourceTree + <group> + + 492FE476101AC2B2726AA5470AA07271 + + fileRef + C773ACE4C55EC81C119CD31D4B427C80 + isa + PBXBuildFile + + 4A4FCE35F848FA9F21257C75E99D2076 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Switch.swift + path + RxSwift/Observables/Implementations/Switch.swift + sourceTree + <group> + + 4AC768BD9B5A00FEBF7113EBB5C13977 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + _RX.h + path + RxCocoa/Common/_RX.h + sourceTree + <group> + + 4B3895EF17D78A7A87818C7EEB4CF2D9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIBindingObserver.swift + path + RxCocoa/Common/CocoaUnits/UIBindingObserver.swift + sourceTree + <group> + + 4B8A5E523A2B7F9B1D1D18E02FFDE2C0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Take.swift + path + RxSwift/Observables/Implementations/Take.swift + sourceTree + <group> + + 4C105B3430FC0E3EBBE18A2667E4AC45 + + isa + PBXTargetDependency + name + Kingfisher + target + 1DE93A359FA21F91DFBE81309E851A4A + targetProxy + 0151734607E8E9B5591E48D71D84F4FF + + 4C25D285DD12D48EB129F3CC8F1645A1 + + children + + 9A00CAB4D5DD868421999C3C472E9636 + 09395FC0E5B36FC60CCC2DAEB6869A1D + 56771D310FF8AB82A55D3B869FABAC83 + 06609935DEF174AEDF2661BA47817341 + 7FAA951502AA2A0639B6BFC4EF4AC841 + C6185FDCFFCA7B2F3DA8323DD11BA014 + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/RxBlocking + sourceTree + <group> + + 4C84976D428360EDB2B3900310813EAE + + fileRef + 6BC99B192C2093713050F92809DC19D6 + isa + PBXBuildFile + + 4D5B458AA8BC814A9DBE57D8019CADBF + + fileRef + 81E1ED904656C7C8A50E7D5F19F8A7C6 + isa + PBXBuildFile + + 4D5E370385E9B2BE3A0E02A8017C0EAD + + fileRef + 5E0A2B28C76300A5BD5B267FA2F4589B + isa + PBXBuildFile + + 4D6DCB1BDFDA7538AACC88F0CADA0803 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Catch.swift + path + RxSwift/Observables/Implementations/Catch.swift + sourceTree + <group> + + 4E2500A89363FFDA9B8E22F8A14AAA3D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Zip+arity.swift + path + RxSwift/Observables/Implementations/Zip+arity.swift + sourceTree + <group> + + 4FB218EE01346D97B5753D43DB5F6023 + + fileRef + 7CDDD28BDE05D85FD8E97D3B4A627C07 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 51117F389497A16ABFBE38649514537E + + children + + 2D6090EE8DEF9C120BED3D29FE78A5CC + F729648D54812A67574CDE74527EBCC5 + + isa + PBXGroup + name + Frameworks + sourceTree + <group> + + 51564F316CE13F29F1341F621F7BE879 + + fileRef + B5B2AD82D2A502933C256CEAEEBB8AC6 + isa + PBXBuildFile + + 51809082BA9EF96E6035FC285AE47656 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + InvocableScheduledItem.swift + path + RxSwift/Schedulers/Internal/InvocableScheduledItem.swift + sourceTree + <group> + + 52197A011E1775247AC4D3929C73F75C + + fileRef + F8E990602F644C7B871B336144D9C4F6 + isa + PBXBuildFile + + 5297E977FB482EF9AF410BE5022EF8F8 + + fileRef + F671D336A41DED031436FD2A9DC62476 + isa + PBXBuildFile + + 52F8053362D3BB5A8546AE30F4626498 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Recorded.swift + path + RxTests/Recorded.swift + sourceTree + <group> + + 534EDD697643C2D6E0DFD75F5FA7E6A6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Bind.swift + path + RxCocoa/Common/Observable+Bind.swift + sourceTree + <group> + + 5351DCF327DBE3E6296C9BBD9B4258F4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UITextField+Rx.swift + path + RxCocoa/iOS/UITextField+Rx.swift + sourceTree + <group> + + 5444BAC6249F353DA5BB7F9FDF5F585B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + DispatchQueueSchedulerQOS.swift + path + RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift + sourceTree + <group> + + 5484C15A929EFDBA62937EF2754A7524 + + fileRef + 03FBFD4C293E0AF1DB9139304F62FAC4 + isa + PBXBuildFile + + 54D2395F6AECD6A4C486439ABB4F4987 + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + RxCocoa.framework + path + RxCocoa.framework + sourceTree + BUILT_PRODUCTS_DIR + + 551B78E3CB320EF8D37A39EBB8DCD407 + + fileRef + F0880F69B4C4AFC0D3243BFBF87D1683 + isa + PBXBuildFile + + 557FAB2B5A8081C5D5C2D8DC99663A08 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + DisposeBase.swift + path + RxSwift/Disposables/DisposeBase.swift + sourceTree + <group> + + 558260C27183AB6F0B2379319BDFC273 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTableViewReactiveArrayDataSource.swift + path + RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift + sourceTree + <group> + + 558B4ECCEC37E6A0CB5F9ED54678AE9F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTableViewDataSourceProxy.swift + path + RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift + sourceTree + <group> + + 561510A63117712838EDD194B8C8160F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Multiple.swift + path + RxSwift/Observables/Observable+Multiple.swift + sourceTree + <group> + + 561BD0A4BA8178289D9D390FF39EDB54 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObservableConvertibleType.swift + path + RxSwift/ObservableConvertibleType.swift + sourceTree + <group> + + 566675550863A10DD73456F1DEF932C8 + + children + + FE2101ADAC03130EE66F908F4800E89B + 3C8D0D32B8DDE15F7D9020B5BD8FEA1E + 027DEADAB08AAD4C8E6F5D066E9BD043 + 0A5A53E7313E000D2F232C5ABB279E70 + 2835BE61F1F6C00428ECE172ACD1272A + F906D576A00915E90F52B0030FEAA12C + 54D2395F6AECD6A4C486439ABB4F4987 + 10F013E7DE672B58780BCADB7AE6BC66 + 1A835E48F19DF8B300F1869B68105661 + + isa + PBXGroup + name + Products + sourceTree + <group> + + 56771D310FF8AB82A55D3B869FABAC83 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + RxBlocking.xcconfig + sourceTree + <group> + + 56D3F740E3469FE408703A45B57E1B4E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Kingfisher.xcconfig + sourceTree + <group> + + 57D2A897196EF66AD85A13547730392F + + fileRef + B32E8D16E0DA6995B852C9A2E4E64326 + isa + PBXBuildFile + + 57E1C5EEA2508034D5C59B64741AEBBD + + fileRef + 63E2FAC9A505C7341406BB896A55A80B + isa + PBXBuildFile + + 57FEC9C1852E7F179A3F4276ACFEB9E9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+StandardSequenceOperators.swift + path + RxSwift/Observables/Observable+StandardSequenceOperators.swift + sourceTree + <group> + + 5896F0393F317866346747243D170436 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + JASON-dummy.m + sourceTree + <group> + + 58BF5A22D02E154ECE59EB1E9A870955 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObservableConvertibleType+Blocking.swift + path + RxBlocking/ObservableConvertibleType+Blocking.swift + sourceTree + <group> + + 58F81CAA492FE07017BB7C4C5DCC61EE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ScheduledDisposable.swift + path + RxSwift/Disposables/ScheduledDisposable.swift + sourceTree + <group> + + 595E5793277C7195FA9D9C395ABB520A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Window.swift + path + RxSwift/Observables/Implementations/Window.swift + sourceTree + <group> + + 59DCDE13FD9DE2EB8671EA88218F625F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxMutableBox.swift + path + RxSwift/RxMutableBox.swift + sourceTree + <group> + + 5AE67D264C4344E3FF61663626FEE190 + + fileRef + 62049ECE20573E8FD72E15EA82805B40 + isa + PBXBuildFile + + 5C7E848F3D292D10B68A7FD6F4CA0F77 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObservableType.swift + path + RxSwift/ObservableType.swift + sourceTree + <group> + + 5CF9988E46AD5CF69981BB77B2B1FE32 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Lock.swift + path + RxSwift/Concurrency/Lock.swift + sourceTree + <group> + + 5D4D1BAFB4F233F7E622F414C02BB4E0 + + fileRef + ADDB5D0F6296B9CDE47AC161BD8D28B2 + isa + PBXBuildFile + + 5DD7A2148FD43725F283C9C64D9B9A32 + + isa + PBXTargetDependency + name + RxBlocking + target + E533BBCDF7DEEF815B15C51BCE1EEFCB + targetProxy + 93FD5D219A31CF6F84E7A3835426469F + + 5E0A2B28C76300A5BD5B267FA2F4589B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SchedulerServices+Emulation.swift + path + RxSwift/Schedulers/SchedulerServices+Emulation.swift + sourceTree + <group> + + 5E4EA8DE8950109984D1C20DB34FB914 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ImageCache.swift + path + Sources/ImageCache.swift + sourceTree + <group> + + 5EC0C1B21B3F993A1EE96EE1EE7F7FFB + + fileRef + 46854386CD29841A6994B7E6B27383FB + isa + PBXBuildFile + + 5EE7BE8648226B231B132B196079C10E + + fileRef + A8C1C6BC08CDAE216386CB3AC7816837 + isa + PBXBuildFile + + 5EE912B1CFB4829EF6AD834FB43031D0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Aggregate.swift + path + RxSwift/Observables/Observable+Aggregate.swift + sourceTree + <group> + + 5F0AE120847972BEBCE95F26C78269DA + + fileRef + 4187C92AE10ACBBAC05BB7C37D2199CC + isa + PBXBuildFile + + 609606CC0304C34A235AF8AF67088392 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + LiteralConvertible.swift + path + Source/LiteralConvertible.swift + sourceTree + <group> + + 617FDDF1E411175A19774FF88A21865F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UISegmentedControl+Rx.swift + path + RxCocoa/iOS/UISegmentedControl+Rx.swift + sourceTree + <group> + + 6191340DC2C04A43B951EFCAB861FBA7 + + fileRef + 749A4C80D079D05EDA33C41391FEF357 + isa + PBXBuildFile + + 61DE7C52A85DB9EA328A7BF08F9B28A1 + + buildConfigurationList + 3364BD43E9F12A6322DF2CDCF2FD5513 + buildPhases + + 0474ED8873521CF7CE0FB03E357013A6 + 9421878D45E1D05AE9B3276AD9C8E90A + 999F7925FBF2A0805C7B8988CE03FC6B + + buildRules + + dependencies + + isa + PBXNativeTarget + name + RxSwift + productName + RxSwift + productReference + 10F013E7DE672B58780BCADB7AE6BC66 + productType + com.apple.product-type.framework + + 61EEBB4AD22EFFFC75F14D85FDC99051 + + fileRef + FCE8B77130B2399CB446E7E186A1462C + isa + PBXBuildFile + + 62049ECE20573E8FD72E15EA82805B40 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Resource.swift + path + Sources/Resource.swift + sourceTree + <group> + + 6249DBF74638E9C6908AAA18230E5DAD + + children + + 266BAF6A5F661616F221F2B37657E737 + 9205A5A5C4C6B484484EB2C17351484F + 34019C7FD752FADE91CF6CE446D4E5F3 + FA8B099AE958FB72F9DAB39B0D74D813 + C8113E56BC2E02C84353DFF80D05290C + 1F76644C74DADEF3E8006C6BE6315D63 + 28262F04A577573ED9B28FD26CAB1A5B + 42E62F61978E37E76029C07CB7842DB4 + 6D42D4C6C8A31ACF6D99262C3B001D7F + 4520CB2833BB5C1EA31EC7487B5308C5 + + isa + PBXGroup + name + Pods-ProtiumTests + path + Target Support Files/Pods-ProtiumTests + sourceTree + <group> + + 6262EC1C88B5D53A75F036E9415BEA01 + + fileRef + 68BC470FFA4AE682DA29F7D72656B5AB + isa + PBXBuildFile + + 629C7CFDBD4ED17D35524C8E6CC27780 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ConnectableObservable.swift + path + RxSwift/Observables/Implementations/ConnectableObservable.swift + sourceTree + <group> + + 62AC43BF1CA1119A5A38645DA7AA6F80 + + buildActionMask + 2147483647 + files + + F9439650775231D2F78C555E917BDD62 + 1D3FC1CE3FE577EE0EE0A12EABBF8881 + AABF75140AA98DB550C589742ED5EE81 + ABD3D6B950AC7656FEF2092ED148862D + 0D6422275C9AACC2B422084F4A5C3089 + 944811954A09A658F2996FCAC0623420 + E9429CDFC4D0F9230F1DBCEA4D486ADC + 3F5CFDB8A74BC8B4536EAAEA77E3257F + 70E898164012CC1A945FB78878DA0439 + 233D1F9362FCB6AECAA53D511884738A + 3F7CEC0791C382ADFDD9868678B0BAF4 + D30DE305E45CE4E33EF52C1E190A2043 + 7C2FBDEFB97B08E801BD48258607E483 + 5EC0C1B21B3F993A1EE96EE1EE7F7FFB + 37E5DAEE75E2E2974B4AB3C96876F915 + 84763FB4C8A0A09590F74A78B3C6BC69 + 95AE2333E4AABDFBE8D476AE31EA1EDA + 3FDB77B3E0EFC73632371DB535291C02 + 2530E34DBE5541807576CC5A2DD2CF15 + BC7E7F96868870BF0AC7A047C96FBEB4 + 70981EDAB92B3E0F2F06DFF85B59C2A9 + 5484C15A929EFDBA62937EF2754A7524 + D28A7AAD1D04D7C42A4710E73AEC2A9A + E3E14EF30FA33B187FD43544C7E44AD3 + 246047BF8F2DC2D57A862CB082F4E4F6 + 0644611748785D4A4259F32FB1CCFAB3 + FA4AACBBE32FD7404C5464658411D84D + C2619162D80DCA8FC798A060AE7482A3 + A81DBE49A130750F39EE741B536EED0E + 4D5B458AA8BC814A9DBE57D8019CADBF + 0A51A05F8839754EC8D210A66B76DB4A + 80CBF033FAB7A9AD428153794FCE90DF + 52197A011E1775247AC4D3929C73F75C + 27CED8986A1FE6C98DA1A73660AC5EE0 + 7AAD24F194C00273DC09C341FF5C921B + 9A8C9941811BF1FF0B2D254349918AE3 + A14BEDCE79B69FDC10E8FCF0BD5E1795 + AEB7AEA386D1EBE8CE6A15B4EDC9CF97 + 3F92AD702FE8DB10D2C455DC7DD07E7C + A0ED42A90D3706F11DF717491F6043CC + 551B78E3CB320EF8D37A39EBB8DCD407 + A2BFCE27E4FA2F0E1D399D575C38C633 + A32F9AC5CD41132A660BD1F4E74E3251 + 75DC0F5C72C47D159478152D990567DC + CD4918BA077C9ADFB99E406398432A16 + E0AEFDA57C95C5E8FAFF5DA96F0215DD + BD29294D1779CCB05F4FB67D4D85B11E + 24E681EF4F12074CD140F35FB08F84E3 + 09AF58BAA040C16FDCD91B85AFFB216A + 0AC4FF53197EEEB5500B9762B4D381DD + DF56D2636D4CABA9302A3F35A515F93E + 8E41B682C847FB37DEB42F9641861ABD + A030DA78F4E106BAB9FC9E3C818F6D39 + 413F2DF12689619DF897061C8313B6C1 + C9A9D44000D63D17649F2888F21FD5FB + 0C6241EC2852D3C55D8C9983528FB2E0 + 10D9E87EB460B8E2BF8AD3B372F41508 + FE91AD7770C23F995689EB9A5E890907 + AADF8F8E57837A5B70F5B1B14FF11E3A + C69EDE2902EC8910C725EF789E8F9FF9 + 215CDB2D36A5E04D1D63BEE4B4788C98 + D63295D11C4CE5AA0747133C2221AA2A + 0A8016EB358499C16B9EC95E2B285391 + C77ECE7C5A9FA2DEDFD78B0E78568372 + E5262145BED306892AF6D3580D41C077 + DA0A7D3B8B6431DDA98241A42F12FD1B + FF9DF655086BF165CFBA86B0409810A6 + 3AC352A7372DE1312F4CF84A13D922A2 + 355578620F452D5AE2DBCF11E3DE5DB9 + 194C5FBF7C6DDC8CED54FF28B85465AC + A434D54064BEA117E92D62FADBF4EB93 + 910DB48FEC72FB5D00CB3DA18F935649 + 8DAF57F0BB183A5926D40BC0237DECBD + 6262EC1C88B5D53A75F036E9415BEA01 + F83991435AAFDACDF363C324511B7567 + CF1E35BA779713EECD47A8EC48570341 + 03FCBFEC6B1B8210B5B90539DDCD9190 + 7C6AE601983BA040D08023AEECE882F1 + E827B13D2D509D49FD2051E1FB483635 + 6304307FFAF238596E8D7FBE4F355CB1 + FF49B8637F84907A6476AB6830BDDA2D + 984C675DAB60884B3EFE831C2100B89A + C890C366ECC9941118DC9424BE86A498 + AAA495EA99C7F1BD23588B690717BB8C + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 6304307FFAF238596E8D7FBE4F355CB1 + + fileRef + D4C3AE2ED883065D6C2C5AB0052672D7 + isa + PBXBuildFile + + 634D923C054F3A5EC7D1137FA01DFB23 + + fileRef + F8EB3C3C8B35BA6AA265CB26821D465D + isa + PBXBuildFile + + 63DABA1FFE13FA1C0B89D677710F9004 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + PriorityQueue.swift + path + RxSwift/DataStructures/PriorityQueue.swift + sourceTree + <group> + + 63E2FAC9A505C7341406BB896A55A80B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + LockOwnerType.swift + path + RxSwift/Concurrency/LockOwnerType.swift + sourceTree + <group> + + 6417EA246014E4CC7E1328930333F37A + + fileRef + FD027FD68BD72E6CDACB8075DE52F46B + isa + PBXBuildFile + + 650F55EC419A89D0A43C458F4FE710CF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UISearchBar+Rx.swift + path + RxCocoa/iOS/UISearchBar+Rx.swift + sourceTree + <group> + + 65598478D68CE249B0E398461A9CA2F7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + _RXObjCRuntime.m + path + RxCocoa/Common/_RXObjCRuntime.m + sourceTree + <group> + + 66717BF3866489EDA0223699A5AD8002 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + RxSwift-umbrella.h + sourceTree + <group> + + 6677B0D564F599722921B4D35D1160E5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTextViewDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift + sourceTree + <group> + + 6704A508ACC928FCCE717DE9A51070B3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ColdObservable.swift + path + RxTests/ColdObservable.swift + sourceTree + <group> + + 685DB47D97F5884448AC56CBB156991B + + fileRef + 609606CC0304C34A235AF8AF67088392 + isa + PBXBuildFile + + 68BC470FFA4AE682DA29F7D72656B5AB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIStepper+Rx.swift + path + RxCocoa/iOS/UIStepper+Rx.swift + sourceTree + <group> + + 68D7F3E236BA0B173154D70D492BAE90 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + BlockingObservable+Operators.swift + path + RxBlocking/BlockingObservable+Operators.swift + sourceTree + <group> + + 6A06DCF8D5A2B04AD95F8A4A98535B0D + + baseConfigurationReference + 56D3F740E3469FE408703A45B57E1B4E + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/Kingfisher/Kingfisher-prefix.pch + INFOPLIST_FILE + Target Support Files/Kingfisher/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/Kingfisher/Kingfisher.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + Kingfisher + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + 6A3F2A2CCC7C8F6210AD5D24265A3BA8 + + fileRef + 4E2500A89363FFDA9B8E22F8A14AAA3D + isa + PBXBuildFile + + 6A5F2D0667733981380A06FF2836C8E5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Zip.swift + path + RxSwift/Observables/Implementations/Zip.swift + sourceTree + <group> + + 6A6D5D6E9CAC72A9A938476C26ADE14E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ShareReplay1WhileConnected.swift + path + RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift + sourceTree + <group> + + 6AEF70AE4E94172111D3B9A098B2A36C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIBarButtonItem+Rx.swift + path + RxCocoa/iOS/UIBarButtonItem+Rx.swift + sourceTree + <group> + + 6B0E041441B82020A2FD07264D2B4526 + + fileRef + 04EAC4EA9E3D3354A6A5CFEA8083BDB1 + isa + PBXBuildFile + + 6B19234D48C03E82E40AA3A861D87BE8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObserveOnSerialDispatchQueue.swift + path + RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift + sourceTree + <group> + + 6B5645DA7C3FAE29C8FF060014DFFE73 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObserverType.swift + path + RxSwift/ObserverType.swift + sourceTree + <group> + + 6BC99B192C2093713050F92809DC19D6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Deferred.swift + path + RxSwift/Observables/Implementations/Deferred.swift + sourceTree + <group> + + 6CFC0DD1C64E43055468D1C07AEA4917 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Do.swift + path + RxSwift/Observables/Implementations/Do.swift + sourceTree + <group> + + 6D424A2D201437E3E0BD0C9E3C0996E6 + + buildConfigurations + + 068C8E050D15BAC6E86BC247E7C1CA36 + 8F80ED884ACA8CC2B6A849FC1147DD4E + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 6D42D4C6C8A31ACF6D99262C3B001D7F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-ProtiumTests.debug.xcconfig + sourceTree + <group> + + 6E1427FEF1C21E9670206309DFAFE4D1 + + fileRef + 5EE912B1CFB4829EF6AD834FB43031D0 + isa + PBXBuildFile + + 6E2A3A806B9EFCE2809E48440A89530C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AnonymousDisposable.swift + path + RxSwift/Disposables/AnonymousDisposable.swift + sourceTree + <group> + + 6EAA7D7CF09BA6AD517FA9FA4CCA9BD2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIScrollView+Rx.swift + path + RxCocoa/iOS/UIScrollView+Rx.swift + sourceTree + <group> + + 6F38BAAA8577529C70E75B7F87D6C33F + + fileRef + BBCE9C83DA6AA3C3EF94EB5C4641183E + isa + PBXBuildFile + + 7052060434DBE47F01391B10B55028F7 + + fileRef + 10F4DF9912C458061DBE6EAC60C44D1D + isa + PBXBuildFile + + 707A627BA7149020978D80B4680B170A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Bag.swift + path + RxSwift/DataStructures/Bag.swift + sourceTree + <group> + + 70981EDAB92B3E0F2F06DFF85B59C2A9 + + fileRef + 10B180164516CFE0CC2BB09DB432D249 + isa + PBXBuildFile + + 70E898164012CC1A945FB78878DA0439 + + fileRef + 090DDB1C624CFFBE1C09BB7C31CFD955 + isa + PBXBuildFile + + 71CF2C6294538CC5BB2D5E7459671C4A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Properties.swift + path + Source/Properties.swift + sourceTree + <group> + + 72099A70040D78A3D3429ADB63A07E6D + + fileRef + A16BD051BA9486FC8A658E97FD35CD40 + isa + PBXBuildFile + + 7265651D413AF8BDE4A873047593520B + + buildConfigurations + + E60D7E3D11544411A5285DA04F091ABD + F33FFD923FC1B164980630EAB3894132 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 72FAF2A2C6D9EFD7CA5956B9C1E56C29 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Pods-ProtiumUITests-dummy.m + sourceTree + <group> + + 73720134EC9F4A240DC81B2940FABD3B + + fileRef + 960BA22488C9BE8721C46AF106FCD49F + isa + PBXBuildFile + + 73D3C97BA9C32375BE6F45BD9A93724F + + fileRef + D8476DDC29731AA0872954CF8E54F736 + isa + PBXBuildFile + + 73DB0A7B2BE2292F75FC35FB22947ACA + + fileRef + 0912BE80640FD3244ED04DFDDF226908 + isa + PBXBuildFile + + 74971D2F3A502BE90C540F15274DB49A + + fileRef + BB0D29820B21BF5038EAF9305AC023B3 + isa + PBXBuildFile + + 749A4C80D079D05EDA33C41391FEF357 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + BinaryDisposable.swift + path + RxSwift/Disposables/BinaryDisposable.swift + sourceTree + <group> + + 7518269B4F99CCAAA10ECAE1C2DC8FB6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxCollectionViewDataSourceType.swift + path + RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift + sourceTree + <group> + + 757703C478EFC5FB375DB50C508AD817 + + fileRef + 6704A508ACC928FCCE717DE9A51070B3 + isa + PBXBuildFile + + 75AAF33F80B873350E29B9660892F93F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSObject+Rx.swift + path + RxCocoa/Common/Observables/NSObject+Rx.swift + sourceTree + <group> + + 75DC0F5C72C47D159478152D990567DC + + fileRef + 9F08383989A6DA484CC6EEB415966708 + isa + PBXBuildFile + + 76AD1724C8BF1D68A48D380C65459AEB + + fileRef + CEEA81C1A2B7523B8EAD47E7BC30B9E2 + isa + PBXBuildFile + + 77A10B3612E6DF0728DB3B6CF31D71B1 + + fileRef + 57FEC9C1852E7F179A3F4276ACFEB9E9 + isa + PBXBuildFile + + 77A521AB3B93AFA957128519B082C782 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIProgressView+Rx.swift + path + RxCocoa/iOS/UIProgressView+Rx.swift + sourceTree + <group> + + 77D32C2381B007241427565E08381913 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 61DE7C52A85DB9EA328A7BF08F9B28A1 + remoteInfo + RxSwift + + 7801E06B088D36120890A7C8716066BC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxSearchControllerDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift + sourceTree + <group> + + 78248535A169B4D18B95353CA60E3BC8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + RxTests-umbrella.h + sourceTree + <group> + + 78EED0DEED471E856C5ED80DB13D2B43 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Logging.swift + path + RxCocoa/Common/Logging.swift + sourceTree + <group> + + 793326254CA24186BC31A1183C5CEEB6 + + fileRef + DA9504C21EBEDF08864744E77FDAEACE + isa + PBXBuildFile + + 79E908B32EF1F8C343DBBAF5626631F4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-Protium.debug.xcconfig + sourceTree + <group> + + 7AA3223FC5A46B63C5229DB2E50C2443 + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + 7AAD24F194C00273DC09C341FF5C921B + + fileRef + 8AF7311AF90F9E3209C66153A5AF67F7 + isa + PBXBuildFile + + 7B41CDE0B855F5277DA0AF36FE886785 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SingleAssignmentDisposable.swift + path + RxSwift/Disposables/SingleAssignmentDisposable.swift + sourceTree + <group> + + 7BEAA159F6410024740B67A7033917F8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Platform.Linux.swift + path + RxSwift/Platform/Platform.Linux.swift + sourceTree + <group> + + 7C2FBDEFB97B08E801BD48258607E483 + + fileRef + B8FA4DE7B60F9F14263C3A818C06E409 + isa + PBXBuildFile + + 7C69E3234122DEC2764CE03683E6A8E1 + + baseConfigurationReference + 7EBFCBC333E835DE615057C6DD4A0CBD + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/JASON/JASON-prefix.pch + INFOPLIST_FILE + Target Support Files/JASON/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/JASON/JASON.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + JASON + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + 7C6A74C70259816EC011421BDC787CD2 + + fileRef + 51809082BA9EF96E6035FC285AE47656 + isa + PBXBuildFile + + 7C6AE601983BA040D08023AEECE882F1 + + fileRef + 2B8EA0D0B158902C318C82F9C231B360 + isa + PBXBuildFile + + 7CA58B7B2F9AC8EEA845703250F3A9ED + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Image.swift + path + Sources/Image.swift + sourceTree + <group> + + 7CD7E3D3D2F00FEF6669992C33B6EF6C + + fileRef + DC3A007A57F7B524D373105688FBFF03 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 7CDDD28BDE05D85FD8E97D3B4A627C07 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + Pods-ProtiumUITests-umbrella.h + sourceTree + <group> + + 7D366BF97A88596C0133E1BACE9035FB + + fileRef + 8BBE57933C373D849DF6FF57704D944B + isa + PBXBuildFile + + 7D6CE060AFA03580B3A84A36B4833224 + + fileRef + CA15E3D8E6981AAF4CD9D0179BAB4D6C + isa + PBXBuildFile + + 7DB346D0F39D3F0E887471402A8071AB + + children + + 93A4A3777CF96A4AAC1D13BA6DCCEA73 + 51117F389497A16ABFBE38649514537E + CA019E94C0D527A7443ED288E884437A + 566675550863A10DD73456F1DEF932C8 + 82B978AD342F8B184732D4838F7FB0B0 + + isa + PBXGroup + sourceTree + <group> + + 7DD91369A74D78F8BD5CF6229BCDCA7F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Amb.swift + path + RxSwift/Observables/Implementations/Amb.swift + sourceTree + <group> + + 7DF076F5F2A8469A307E7B719CC73FD9 + + fileRef + 48354A1FD85D920D529598821C52B2FA + isa + PBXBuildFile + + 7DFBF091AA27077629C03995C00FF0D3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + JASON-prefix.pch + sourceTree + <group> + + 7E2FBFD9C7C0F7EE7E1C32DC31F91217 + + children + + 4AC768BD9B5A00FEBF7113EBB5C13977 + 24B0711D45694743CFACB12DA5CDD32D + 0C4BA5EB55C9F21D294076D2AA18B01A + E379F36B5207745C8A1B99CC359DBD31 + DC3A007A57F7B524D373105688FBFF03 + BE7EC2F3B77B49030F19ABB24BF0B250 + DD0435041DE5BD31668B59A3630E3991 + 65598478D68CE249B0E398461A9CA2F7 + B3279F70AF109C76435EC34B61F8CDF6 + E03446357CE15647936B4979A933C069 + 3DB9D579E5A49A54172909880221ACD2 + 8F005F713676620204DACBF03E96AA2B + 090DDB1C624CFFBE1C09BB7C31CFD955 + C148730C48D1F8C7CC630677E90651F7 + 85E87837B5BEA6532026C6A4D00FEEB5 + B8FA4DE7B60F9F14263C3A818C06E409 + 84EA2C0F10668146DCEC8BAA216ECC11 + 46854386CD29841A6994B7E6B27383FB + FC02F13F4C864B0F5041447574AB5543 + ABC08336AA7ACC39F45BF45EACDE1A99 + 0311349A682A62DB14645DA5AB0212B1 + 78EED0DEED471E856C5ED80DB13D2B43 + E3C5F98E92B9F961686689CBAC0014B0 + 3BA85BD01AF66501D1A292CD7C6B8606 + 75AAF33F80B873350E29B9660892F93F + 10B180164516CFE0CC2BB09DB432D249 + 03FBFD4C293E0AF1DB9139304F62FAC4 + 3160C670FE54847CA02BE1FFBA62AABF + C884C04605138975C27F2F3E0C7C3F65 + 534EDD697643C2D6E0DFD75F5FA7E6A6 + 8ABF8E968DFEA1A9DEF39E6DA2C56761 + E100F12B20B026E8A167F751D4E6D04A + B8CA879185FDCE045E777A3947F31C75 + 81E1ED904656C7C8A50E7D5F19F8A7C6 + FFBD546CB3D4110D355788C3A43E8A51 + 7518269B4F99CCAAA10ECAE1C2DC8FB6 + F8E990602F644C7B871B336144D9C4F6 + 017C4189518B612AFDC189D04629E8F5 + 8AF7311AF90F9E3209C66153A5AF67F7 + C4AFDB3BA38A46B3FD37BC5B714F9DC4 + E8D1BEAFADF605A62DF0AD9BC2366078 + 7801E06B088D36120890A7C8716066BC + 214F385B284CBAE6CA1926C5C1F4EC6C + 558B4ECCEC37E6A0CB5F9ED54678AE9F + F0880F69B4C4AFC0D3243BFBF87D1683 + 0C4FE3EA81EDF1AA8CC8B317B3AE11D4 + 558260C27183AB6F0B2379319BDFC273 + 9F08383989A6DA484CC6EEB415966708 + EE4437314BB8F7C003FE450692818CA9 + 6677B0D564F599722921B4D35D1160E5 + ED72C12BCDC75D149A416A68F2AEEAA3 + D0AEE6B32E344932FB99095671FEFF17 + 99B56EDA75E62E6F2DF735CF2E8A84D0 + 224415781205C53C4F26E4452110C74B + 2CCFCE6F6BC1B2744A6CAE46739803D2 + 972836B3A91050F57D753BB853348E79 + 0B6FF9B5D42EC08B8253C14320C8D35C + ACE36EEF7E07ECCEC2C82341CDD9AFA7 + 6AEF70AE4E94172111D3B9A098B2A36C + 4B3895EF17D78A7A87818C7EEB4CF2D9 + CA76F98AC131EE1F1AE355BB2B62AFAF + 87B6320968169C95692DC8723FD43DDE + 060A43622508FB606F927D0EB886F433 + E9859681AF69FE5B64F6D4A019D99429 + E262278CEF901FD6DDF1AF07A1CC8ABE + CE864B5D326FBB05E0206BA17BD11E2A + D285C0611719C40B5DB70677582F237C + 2EFAB4427F44FF51FC350BC9635B0056 + BB10ADB5638F836AB74C3F337709002F + BEF3C2476006098D0F78AFB7C25A6DD3 + 77A521AB3B93AFA957128519B082C782 + 27A7DF7FD67115F916ED7EC6863F2CF2 + 6EAA7D7CF09BA6AD517FA9FA4CCA9BD2 + 650F55EC419A89D0A43C458F4FE710CF + 9FC9D234ADD24F852575A1EE6ADAB379 + 617FDDF1E411175A19774FF88A21865F + CE5E71FA9C53D39A6BCEB487DD0DD45F + 68BC470FFA4AE682DA29F7D72656B5AB + 1B732A588AF08063716183A539B8D5FC + D730FCBFCE9801934DF37148EE65289A + 48EEFBE9569982118F6FFAFED5F2D053 + 2B8EA0D0B158902C318C82F9C231B360 + 5351DCF327DBE3E6296C9BBD9B4258F4 + D4C3AE2ED883065D6C2C5AB0052672D7 + B875AF6FD2019F1FDB7A4E7272FDAF1D + B1E9E7F8B45DFCF69DF6321C6443610E + 91E91D57C5DE554FE6FC86659413EE7C + C76712F1D91555C20B4418A2A24E1DFB + 1A6F678A5904F782CF07C613FE146E28 + + isa + PBXGroup + name + RxCocoa + path + RxCocoa + sourceTree + <group> + + 7E8334AB56A363B2B6447C71379BA73B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Producer.swift + path + RxSwift/Observables/Implementations/Producer.swift + sourceTree + <group> + + 7EBFCBC333E835DE615057C6DD4A0CBD + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + JASON.xcconfig + sourceTree + <group> + + 7EC1AFEC6E8403CBEC48818B43A598C5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + RxTests-dummy.m + sourceTree + <group> + + 7F3B0684BDA50424678D0F04F5F4B6A9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Filter.swift + path + RxSwift/Observables/Implementations/Filter.swift + sourceTree + <group> + + 7FAA951502AA2A0639B6BFC4EF4AC841 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + RxBlocking-prefix.pch + sourceTree + <group> + + 7FFC8A78E4F13D62B71A476EB0DAB7FB + + fileRef + 9D41A805B3F4121E217A22F2BD23B8F1 + isa + PBXBuildFile + + 80CBF033FAB7A9AD428153794FCE90DF + + fileRef + 7518269B4F99CCAAA10ECAE1C2DC8FB6 + isa + PBXBuildFile + + 81053DF0BD9A889390BD198A31064421 + + fileRef + D0EB34A0C99F4F66F73602585083C0F1 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + 81938531C065FC638D1F7942229EAC73 + + fileRef + 595E5793277C7195FA9D9C395ABB520A + isa + PBXBuildFile + + 81E1ED904656C7C8A50E7D5F19F8A7C6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxCocoa.swift + path + RxCocoa/Common/RxCocoa.swift + sourceTree + <group> + + 8222756B9CE80F0BF2A9A32B529851D7 + + fileRef + 561510A63117712838EDD194B8C8160F + isa + PBXBuildFile + + 8248EFACD13D1BE9AC0D2F0D10B3D3CE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Sample.swift + path + RxSwift/Observables/Implementations/Sample.swift + sourceTree + <group> + + 82B978AD342F8B184732D4838F7FB0B0 + + children + + BFCC224204AC4284ECDDA8909DE4C07D + 6249DBF74638E9C6908AAA18230E5DAD + F96A3A347B13A8C627E2241C289EBA2F + + isa + PBXGroup + name + Targets Support Files + sourceTree + <group> + + 82C1BC6BD6B41CADE460952602C8786B + + buildActionMask + 2147483647 + files + + 26B0D041E461A41D1743E36BB6B3AA62 + 1EB02E8721A3013E7FEF1F5AC1EAA7C6 + CFD48468A6CA68736D3A8E3DE978980D + 685DB47D97F5884448AC56CBB156991B + A12730C9F5653CABFCFE90151C44CCA4 + 5F0AE120847972BEBCE95F26C78269DA + 99EFCBEDE0580BB170CDA78DD9264629 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 82FBB3A74E788E50C77B8F576C77AD93 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 61DE7C52A85DB9EA328A7BF08F9B28A1 + remoteInfo + RxSwift + + 83134275EAD08FA0B078FB01368416A8 + + fileRef + B969E1626F329CB660E4D94F4564A231 + isa + PBXBuildFile + + 8325065B4F4F149D519A606FF687206B + + fileRef + 8D2C5AE451A1E77C40E2D4255EDA6B92 + isa + PBXBuildFile + + 836E6F5ADF61FC72AF6F5D7795FD26DE + + fileRef + 59DCDE13FD9DE2EB8671EA88218F625F + isa + PBXBuildFile + + 845114B594E213F222279AE506D0A9CF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + JSON.swift + path + Source/JSON.swift + sourceTree + <group> + + 84763FB4C8A0A09590F74A78B3C6BC69 + + fileRef + 0311349A682A62DB14645DA5AB0212B1 + isa + PBXBuildFile + + 84EA2C0F10668146DCEC8BAA216ECC11 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Driver+Subscription.swift + path + RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift + sourceTree + <group> + + 851DD6AA7CD03099C709CEA763A4437F + + fileRef + 1E4EB7DC68C633870CCEA7B3696CFE5E + isa + PBXBuildFile + + 854862FABC5DD23FCFE3161432F462D1 + + fileRef + 6E2A3A806B9EFCE2809E48440A89530C + isa + PBXBuildFile + + 858FC9A30473FBC24F973F334B776217 + + fileRef + 197E41CA9E9F02081E0321D327AC5BC9 + isa + PBXBuildFile + + 85A8D690FEF985B22FA0D8E904D798CF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Empty.swift + path + RxSwift/Observables/Implementations/Empty.swift + sourceTree + <group> + + 85E87837B5BEA6532026C6A4D00FEEB5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + DelegateProxyType.swift + path + RxCocoa/Common/DelegateProxyType.swift + sourceTree + <group> + + 8752A7B07D7AA4309205EB06248ED9A1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ImmediateSchedulerType.swift + path + RxSwift/ImmediateSchedulerType.swift + sourceTree + <group> + + 8763B305232564AFE056FF9EBF34CEE3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + JASON-umbrella.h + sourceTree + <group> + + 87B6320968169C95692DC8723FD43DDE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UICollectionView+Rx.swift + path + RxCocoa/iOS/UICollectionView+Rx.swift + sourceTree + <group> + + 8827CF45B41D2C8ED46F04506DD7C360 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AsyncLock.swift + path + RxSwift/Concurrency/AsyncLock.swift + sourceTree + <group> + + 8892762409E64DBABBD1226631A3324C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Zip+CollectionType.swift + path + RxSwift/Observables/Implementations/Zip+CollectionType.swift + sourceTree + <group> + + 88EFDBB9E8543D84BF2BDD2DEA41DD45 + + baseConfigurationReference + A3633765E42B66E74FFC904D347B8F7D + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/RxSwift/RxSwift-prefix.pch + INFOPLIST_FILE + Target Support Files/RxSwift/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/RxSwift/RxSwift.modulemap + MTL_ENABLE_DEBUG_INFO + YES + PRODUCT_NAME + RxSwift + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 895E56E4245B4A7099A02340419C9941 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Delay.swift + path + RxSwift/Observables/Implementations/Delay.swift + sourceTree + <group> + + 898C045369AB76F70669F8DBF7C7CFB7 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 36730F6F2D4279BA1D7AF40EA756D893 + remoteInfo + JASON + + 898D7BD54C472EE6CAE0996B532E68AD + + buildActionMask + 2147483647 + files + + 2794F2859B1F2A6B377B8812D5CCC2A0 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 8A4978326FA2016A5EC2A44D88128515 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ToArray.swift + path + RxSwift/Observables/Implementations/ToArray.swift + sourceTree + <group> + + 8A629D0146AB3964E918C6D0C2EC38FC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AnonymousObservable.swift + path + RxSwift/Observables/Implementations/AnonymousObservable.swift + sourceTree + <group> + + 8A79FC900E8432AF1D6C5601BB0E228B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NopDisposable.swift + path + RxSwift/Disposables/NopDisposable.swift + sourceTree + <group> + + 8AA5BB6A5869BD851E897B7176B797B8 + + buildActionMask + 2147483647 + files + + D2D3B4657877EB8DE3E8C4A47BC0B0DA + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 8ABF8E968DFEA1A9DEF39E6DA2C56761 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObservableConvertibleType+Driver.swift + path + RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift + sourceTree + <group> + + 8ADEAF3718543CF0AAE1ED0158E94522 + + fileRef + 8A79FC900E8432AF1D6C5601BB0E228B + isa + PBXBuildFile + + 8AE02C24885447443223FD38F0882738 + + buildActionMask + 2147483647 + files + + C3DEEE31BD151F191D46C7B8CCD2E2B1 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 8AF7311AF90F9E3209C66153A5AF67F7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxPickerViewDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift + sourceTree + <group> + + 8BBE57933C373D849DF6FF57704D944B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObserveOn.swift + path + RxSwift/Observables/Implementations/ObserveOn.swift + sourceTree + <group> + + 8BC49927E2B510441F3643D2A57DAF1C + + fileRef + 7B41CDE0B855F5277DA0AF36FE886785 + isa + PBXBuildFile + + 8BF0887831DD737987DFDABF2B0B3037 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + 8BF3B04A51B134FAD7615A5226D92E6F + + buildActionMask + 2147483647 + files + + 9976EC64B4ACEAD461A3CD0BB3344FF6 + 182F5545BD7E16461C051038B2C4C3CC + 3FD268C5E6003DF678ADC483EFF33DA2 + E36FDA97D600E8DAAB9A573C0CE6666B + 01C6AD05FE0BF7937FB1A8262E3B3BA3 + C35BED43CD153EA467343937F6AFBFF0 + CC513442B1C0CC1AEF8E7F9B76801010 + 33DF4B134C34804BCF18850132DA29A9 + BC3108B0D0BE17194D3D4C1040F6B566 + 793326254CA24186BC31A1183C5CEEB6 + 8E999D5DC5547C68D20D1692414B1D0C + 963610B72BBE039FA504968D53F09CE8 + 371F2E7759D965A93E641FAE90B0500B + 634D923C054F3A5EC7D1137FA01DFB23 + 2244D0D520DC6392DAAE901A2BEC8B79 + C1B8D8FE3B63424F8D7FEA6A54EF96B9 + A6376A642C07EB9739E20803BB9A07D7 + 5AE67D264C4344E3FF61663626FEE190 + 7DF076F5F2A8469A307E7B719CC73FD9 + 6B0E041441B82020A2FD07264D2B4526 + B513DD750CAC32A84E315E8BBDC46145 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 8CF21CA2ED42F707A04778117CA393C8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + Kingfisher.h + path + Sources/Kingfisher.h + sourceTree + <group> + + 8D2C5AE451A1E77C40E2D4255EDA6B92 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Generate.swift + path + RxSwift/Observables/Implementations/Generate.swift + sourceTree + <group> + + 8D4F1F32D4C254DCD8B7308F112396E3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SerialDisposable.swift + path + RxSwift/Disposables/SerialDisposable.swift + sourceTree + <group> + + 8DAF57F0BB183A5926D40BC0237DECBD + + fileRef + CE5E71FA9C53D39A6BCEB487DD0DD45F + isa + PBXBuildFile + + 8DBA83DA7327FE5D6C8D4AEA11B88256 + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + 8DFDF67475096B02D569C6F6A2455689 + + buildConfigurations + + 14763DA373DE3A96D3D1B84FED33C8C7 + B328998EC30BD7D15D31C6B661AF7C75 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 8E41B682C847FB37DEB42F9641861ABD + + fileRef + 972836B3A91050F57D753BB853348E79 + isa + PBXBuildFile + + 8E7D9DA035C6A7B92B98AE8316FEF543 + + fileRef + B47BCAB34EDB11E8577EB40AA2878853 + isa + PBXBuildFile + + 8E999D5DC5547C68D20D1692414B1D0C + + fileRef + E1E0D8EFEAD0FA82CB766D828883D8D8 + isa + PBXBuildFile + + 8F005F713676620204DACBF03E96AA2B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ControlProperty+Driver.swift + path + RxCocoa/Common/CocoaUnits/Driver/ControlProperty+Driver.swift + sourceTree + <group> + + 8F2626E6E89E1FB8D4BBBE72B59DE13F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SubscribeOn.swift + path + RxSwift/Observables/Implementations/SubscribeOn.swift + sourceTree + <group> + + 8F75DF109CE3FF2D658F221A968A1612 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + CacheSerializer.swift + path + Sources/CacheSerializer.swift + sourceTree + <group> + + 8F80ED884ACA8CC2B6A849FC1147DD4E + + baseConfigurationReference + 9EE71AE913A21CAEFC39F0F7B20C8FD0 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/RxCocoa/RxCocoa-prefix.pch + INFOPLIST_FILE + Target Support Files/RxCocoa/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/RxCocoa/RxCocoa.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + RxCocoa + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + 8FA96819840E9DB6C2A7A5129A63A27D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Reactive.swift + path + RxSwift/Reactive.swift + sourceTree + <group> + + 8FADF69C866E58C9960100EA05ED48E6 + + buildActionMask + 2147483647 + files + + E98CEFE252B2A6AB425D26509A7EB7F3 + 01F5BD83B350366A28D15014200E1233 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 90447847FD6EC217674F141B5A05B671 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 61DE7C52A85DB9EA328A7BF08F9B28A1 + remoteInfo + RxSwift + + 909F5C99F0C19748867610740BC28D1A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Utilities.swift + path + Source/Supporting Files/Utilities.swift + sourceTree + <group> + + 90F14D3CA725CF12B1E9CC3856478BC3 + + fileRef + 7E8334AB56A363B2B6447C71379BA73B + isa + PBXBuildFile + + 910DB48FEC72FB5D00CB3DA18F935649 + + fileRef + 617FDDF1E411175A19774FF88A21865F + isa + PBXBuildFile + + 919F5662A2CDA8F088F4352D9F280F99 + + fileRef + BFEA396191E5EE3E8306FE5FD73A18EF + isa + PBXBuildFile + + 91E91D57C5DE554FE6FC86659413EE7C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Variable+Driver.swift + path + RxCocoa/Common/CocoaUnits/Driver/Variable+Driver.swift + sourceTree + <group> + + 9205A5A5C4C6B484484EB2C17351484F + + includeInIndex + 1 + isa + PBXFileReference + path + Pods-ProtiumTests.modulemap + sourceTree + <group> + + 935E63A7D746AFBF87316E4D9FA208AA + + fileRef + 2F0965C1D21DAB69E029693B70F76CC8 + isa + PBXBuildFile + + 93A4A3777CF96A4AAC1D13BA6DCCEA73 + + explicitFileType + text.script.ruby + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text + name + Podfile + path + ../Podfile + sourceTree + SOURCE_ROOT + xcLanguageSpecificationIdentifier + xcode.lang.ruby + + 93A60AE74B0E41C91A1F7F86DC6135F6 + + fileRef + 4003EF315D8605C2D2CED4F4013AB827 + isa + PBXBuildFile + + 93AB551642123C99EC55166FB9B04F44 + + fileRef + C20E6427633E7A6CF39DE6B8147977CD + isa + PBXBuildFile + + 93FD5D219A31CF6F84E7A3835426469F + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + E533BBCDF7DEEF815B15C51BCE1EEFCB + remoteInfo + RxBlocking + + 9421878D45E1D05AE9B3276AD9C8E90A + + buildActionMask + 2147483647 + files + + 0C5D2CF505402F2F3692F22EBB5AC10D + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 942E7C087C06931F99F7B74636F37F07 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + ADDC61C64160A002293A6F9DBE4C9073 + remoteInfo + RxCocoa + + 944811954A09A658F2996FCAC0623420 + + fileRef + B3279F70AF109C76435EC34B61F8CDF6 + isa + PBXBuildFile + + 95AE2333E4AABDFBE8D476AE31EA1EDA + + fileRef + FC02F13F4C864B0F5041447574AB5543 + isa + PBXBuildFile + + 960BA22488C9BE8721C46AF106FCD49F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SynchronizedSubscribeType.swift + path + RxSwift/Concurrency/SynchronizedSubscribeType.swift + sourceTree + <group> + + 963610B72BBE039FA504968D53F09CE8 + + fileRef + EC2BE04EEBC2C95D80EDBEBF2A7AEFE2 + isa + PBXBuildFile + + 9641E599D681F7746C659912FD23074D + + fileRef + 8A629D0146AB3964E918C6D0C2EC38FC + isa + PBXBuildFile + + 9689D3C4A85456EC61731D6A3B9AF311 + + buildConfigurationList + 8DFDF67475096B02D569C6F6A2455689 + buildPhases + + A553ADCB01E2173EFCEAC135A08F081A + 4077E724CCEF57FAE1073BDF82482831 + 8AE02C24885447443223FD38F0882738 + + buildRules + + dependencies + + B3889A445D7E8A75BA206A3564286905 + 4C105B3430FC0E3EBBE18A2667E4AC45 + 34E3F284A9A678C1DB6C982018099167 + B34FFC75156F1731978A3B4A68B6823C + + isa + PBXNativeTarget + name + Pods-Protium + productName + Pods-Protium + productReference + 027DEADAB08AAD4C8E6F5D066E9BD043 + productType + com.apple.product-type.framework + + 96C5AFDC31FCB75E3AF354A4278BE6E6 + + fileRef + A4C00F4B81E770A401EB903BF71070D8 + isa + PBXBuildFile + + 972836B3A91050F57D753BB853348E79 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIActivityIndicatorView+Rx.swift + path + RxCocoa/iOS/UIActivityIndicatorView+Rx.swift + sourceTree + <group> + + 975D9E59095650AA28C2E74D1F1A0675 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-ProtiumUITests-resources.sh + sourceTree + <group> + + 978B275D7151323194A8F3C8441C0C8C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Disposable.swift + path + RxSwift/Disposable.swift + sourceTree + <group> + + 984C675DAB60884B3EFE831C2100B89A + + fileRef + B1E9E7F8B45DFCF69DF6321C6443610E + isa + PBXBuildFile + + 98AE9A07ADB081C3BDC7EC7E4FC3C75F + + baseConfigurationReference + 56771D310FF8AB82A55D3B869FABAC83 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/RxBlocking/RxBlocking-prefix.pch + INFOPLIST_FILE + Target Support Files/RxBlocking/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/RxBlocking/RxBlocking.modulemap + MTL_ENABLE_DEBUG_INFO + YES + PRODUCT_NAME + RxBlocking + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 98BDF4C5C9F8C1CB1C3A5A91D7A9F59D + + fileRef + 707A627BA7149020978D80B4680B170A + isa + PBXBuildFile + + 98F2F75A1E6B746ED5C0810BA0938F21 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + Pods-ProtiumUITests.release.xcconfig + sourceTree + <group> + + 992EA74CCEFEA7DCDF92BC496105AA95 + + fileRef + AEC736C235A1FB4000F381965CF37F47 + isa + PBXBuildFile + + 9976EC64B4ACEAD461A3CD0BB3344FF6 + + fileRef + 2C34B34FBD07A433F9C2930E4787BEB1 + isa + PBXBuildFile + + 999F7925FBF2A0805C7B8988CE03FC6B + + buildActionMask + 2147483647 + files + + 1C568444D9D22A3B4CB56D814BB741E9 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + 99B56EDA75E62E6F2DF735CF2E8A84D0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SharedSequence+Operators.swift + path + RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators.swift + sourceTree + <group> + + 99EFCBEDE0580BB170CDA78DD9264629 + + fileRef + 909F5C99F0C19748867610740BC28D1A + isa + PBXBuildFile + + 9A00CAB4D5DD868421999C3C472E9636 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + 9A585A08792F5106904E2DCCCB9BF88D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SubscriptionDisposable.swift + path + RxSwift/Disposables/SubscriptionDisposable.swift + sourceTree + <group> + + 9A79400B0690CEC0BF376B959B4C7B74 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Subscription.swift + path + RxTests/Subscription.swift + sourceTree + <group> + + 9A8C9941811BF1FF0B2D254349918AE3 + + fileRef + C4AFDB3BA38A46B3FD37BC5B714F9DC4 + isa + PBXBuildFile + + 9A93D2720DB746F6C1B323797C4985CB + + baseConfigurationReference + 7EBFCBC333E835DE615057C6DD4A0CBD + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/JASON/JASON-prefix.pch + INFOPLIST_FILE + Target Support Files/JASON/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/JASON/JASON.modulemap + MTL_ENABLE_DEBUG_INFO + YES + PRODUCT_NAME + JASON + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + 9C78E38E6070BCBF868A821B4DB82BAF + + includeInIndex + 1 + isa + PBXFileReference + path + RxSwift.modulemap + sourceTree + <group> + + 9C89F4A1946C8C85A2D49E5AA09E00B8 + + buildConfigurations + + C81A4C041EADA36B483C25F9D43CA508 + B572DD4BA7C1097A3C875955CB04D689 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + 9D41A805B3F4121E217A22F2BD23B8F1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Any+Equatable.swift + path + RxTests/Any+Equatable.swift + sourceTree + <group> + + 9DC1CC4B094524734C47B957FDF8FD88 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Pods-ProtiumUITests-acknowledgements.plist + sourceTree + <group> + + 9EE71AE913A21CAEFC39F0F7B20C8FD0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + RxCocoa.xcconfig + sourceTree + <group> + + 9F08383989A6DA484CC6EEB415966708 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTarget.swift + path + RxCocoa/Common/RxTarget.swift + sourceTree + <group> + + 9F15D7981B0AADF517E3831BE57F21F9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TestScheduler.swift + path + RxTests/Schedulers/TestScheduler.swift + sourceTree + <group> + + 9F40B9E3CA7B52A71C396EE968A049DA + + fileRef + BF273484A47EEEA306370F0BDCBB80BC + isa + PBXBuildFile + + 9FC9D234ADD24F852575A1EE6ADAB379 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UISearchController+Rx.swift + path + RxCocoa/iOS/UISearchController+Rx.swift + sourceTree + <group> + + A009846289E4E2F1076667E6D55B96D1 + + fileRef + 978B275D7151323194A8F3C8441C0C8C + isa + PBXBuildFile + + A030DA78F4E106BAB9FC9E3C818F6D39 + + fileRef + 0B6FF9B5D42EC08B8253C14320C8D35C + isa + PBXBuildFile + + A0953F18AB838742234AA5996B066297 + + fileRef + E9799FDB58963DE7FB16D0B1DB8D8835 + isa + PBXBuildFile + + A0ED42A90D3706F11DF717491F6043CC + + fileRef + 558B4ECCEC37E6A0CB5F9ED54678AE9F + isa + PBXBuildFile + + A12730C9F5653CABFCFE90151C44CCA4 + + fileRef + 71CF2C6294538CC5BB2D5E7459671C4A + isa + PBXBuildFile + + A14BEDCE79B69FDC10E8FCF0BD5E1795 + + fileRef + E8D1BEAFADF605A62DF0AD9BC2366078 + isa + PBXBuildFile + + A16BD051BA9486FC8A658E97FD35CD40 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ConnectableObservableType.swift + path + RxSwift/ConnectableObservableType.swift + sourceTree + <group> + + A19ED70E760FB83A79FAED20BB8D8AFC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + Pods-Protium-umbrella.h + sourceTree + <group> + + A1A2E256DFB728746355C94D800B8CF2 + + children + + 07B1DB23157EA9BAD90B274E02D82220 + 4655203602365755D2133A8C58668CEA + 7EBFCBC333E835DE615057C6DD4A0CBD + 5896F0393F317866346747243D170436 + 7DFBF091AA27077629C03995C00FF0D3 + 8763B305232564AFE056FF9EBF34CEE3 + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/JASON + sourceTree + <group> + + A209F6103AB4B65FF8E25ED8902B7F23 + + fileRef + 1383B5661E7F94B4DF82AC5641BE42B8 + isa + PBXBuildFile + + A2BFCE27E4FA2F0E1D399D575C38C633 + + fileRef + 0C4FE3EA81EDF1AA8CC8B317B3AE11D4 + isa + PBXBuildFile + + A2F8B6C1C8F44A7B78E1A46A525F2C09 + + fileRef + A6DEEB3BF2044FA67C9FBD7B86DD9EC1 + isa + PBXBuildFile + + A32F9AC5CD41132A660BD1F4E74E3251 + + fileRef + 558260C27183AB6F0B2379319BDFC273 + isa + PBXBuildFile + + A34113E956A812A7DDAC95D9F50EFE2A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Box.swift + path + Sources/Box.swift + sourceTree + <group> + + A35275C5E5B2CE8110A5F77F434A361D + + fileRef + 8892762409E64DBABBD1226631A3324C + isa + PBXBuildFile + + A3633765E42B66E74FFC904D347B8F7D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.xcconfig + path + RxSwift.xcconfig + sourceTree + <group> + + A36D07A8CADB7102BC6A9C4ACA586AF0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SynchronizedDisposeType.swift + path + RxSwift/Concurrency/SynchronizedDisposeType.swift + sourceTree + <group> + + A434D54064BEA117E92D62FADBF4EB93 + + fileRef + 9FC9D234ADD24F852575A1EE6ADAB379 + isa + PBXBuildFile + + A474998B1599CFAD7A32E47D6B5DC0A1 + + fileRef + 8D4F1F32D4C254DCD8B7308F112396E3 + isa + PBXBuildFile + + A4C00F4B81E770A401EB903BF71070D8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Buffer.swift + path + RxSwift/Observables/Implementations/Buffer.swift + sourceTree + <group> + + A553ADCB01E2173EFCEAC135A08F081A + + buildActionMask + 2147483647 + files + + 2BC45C1D85A9069663C54CC030BE9FD5 + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + A6376A642C07EB9739E20803BB9A07D7 + + fileRef + E7D2CE9E029F6D3C24F508100F5E7986 + isa + PBXBuildFile + + A6A06B3107D0D2AF036624F22508445E + + fileRef + 58BF5A22D02E154ECE59EB1E9A870955 + isa + PBXBuildFile + + A6DEEB3BF2044FA67C9FBD7B86DD9EC1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SynchronizedUnsubscribeType.swift + path + RxSwift/Concurrency/SynchronizedUnsubscribeType.swift + sourceTree + <group> + + A76534D7DFD6D1BA2BA0DC506787DF58 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + AnonymousObserver.swift + path + RxSwift/Observers/AnonymousObserver.swift + sourceTree + <group> + + A81DBE49A130750F39EE741B536EED0E + + fileRef + 486D36E7644B12189C47F299E6D3ED15 + isa + PBXBuildFile + + A838CFF5F4E3BD5E96617361831C5E0B + + fileRef + 416680E5D51ACB06A832967877B08B97 + isa + PBXBuildFile + + A864A3BB83A2062E2DB2C87932A1AB99 + + fileRef + D30E0EF7B99E115A8E1593EC4CDEC5F7 + isa + PBXBuildFile + + A8C1C6BC08CDAE216386CB3AC7816837 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + HistoricalSchedulerTimeConverter.swift + path + RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift + sourceTree + <group> + + A90D68C4F183DA11683901517274A5FF + + fileRef + 8752A7B07D7AA4309205EB06248ED9A1 + isa + PBXBuildFile + + A921505BA3663527E1F8995261D6A9C2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObserverBase.swift + path + RxSwift/Observers/ObserverBase.swift + sourceTree + <group> + + AA44EA2EFE5D88346BDAE163AB46FE1F + + fileRef + 21DF3D11967DCCBB83AC244555AEE6FF + isa + PBXBuildFile + + AAA495EA99C7F1BD23588B690717BB8C + + fileRef + C76712F1D91555C20B4418A2A24E1DFB + isa + PBXBuildFile + + AABF75140AA98DB550C589742ED5EE81 + + fileRef + BE7EC2F3B77B49030F19ABB24BF0B250 + isa + PBXBuildFile + + AADCB317A4849755366BDEF090F61931 + + fileRef + C877ED8A782B3D02D32F6D8FEB6CBFFF + isa + PBXBuildFile + + AADF8F8E57837A5B70F5B1B14FF11E3A + + fileRef + 060A43622508FB606F927D0EB886F433 + isa + PBXBuildFile + + ABC08336AA7ACC39F45BF45EACDE1A99 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + KVORepresentable+CoreGraphics.swift + path + RxCocoa/Common/KVORepresentable+CoreGraphics.swift + sourceTree + <group> + + ABD3D6B950AC7656FEF2092ED148862D + + fileRef + 65598478D68CE249B0E398461A9CA2F7 + isa + PBXBuildFile + + AC060E57578DB3FBFB933E762A70AE99 + + fileRef + 22D2DAD49819F437A4CF59CAF49133C9 + isa + PBXBuildFile + + AC111E27AB9BFEF15F7622E52079125A + + isa + PBXTargetDependency + name + RxSwift + target + 61DE7C52A85DB9EA328A7BF08F9B28A1 + targetProxy + 77D32C2381B007241427565E08381913 + + AC211BE23FC07668A6A1383BBBCDD1D1 + + fileRef + D1B174689B47E89AA5F4F46AB452642A + isa + PBXBuildFile + + ACE36EEF7E07ECCEC2C82341CDD9AFA7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIApplication+Rx.swift + path + RxCocoa/iOS/UIApplication+Rx.swift + sourceTree + <group> + + ACFB2F9D6862626D2D439265851BBD1A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + CombineLatest+arity.swift + path + RxSwift/Observables/Implementations/CombineLatest+arity.swift + sourceTree + <group> + + ADDB5D0F6296B9CDE47AC161BD8D28B2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ElementAt.swift + path + RxSwift/Observables/Implementations/ElementAt.swift + sourceTree + <group> + + ADDC61C64160A002293A6F9DBE4C9073 + + buildConfigurationList + 6D424A2D201437E3E0BD0C9E3C0996E6 + buildPhases + + 62AC43BF1CA1119A5A38645DA7AA6F80 + B39AED95CE54F436A4B3D2BB055E6F6E + B595ED03BDB33F76F13B5CF91354AC9D + + buildRules + + dependencies + + EFA20FEFA16A9D29C766EBBCBA72F172 + + isa + PBXNativeTarget + name + RxCocoa + productName + RxCocoa + productReference + 54D2395F6AECD6A4C486439ABB4F4987 + productType + com.apple.product-type.framework + + AEB7AEA386D1EBE8CE6A15B4EDC9CF97 + + fileRef + 7801E06B088D36120890A7C8716066BC + isa + PBXBuildFile + + AEC736C235A1FB4000F381965CF37F47 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Never.swift + path + RxSwift/Observables/Implementations/Never.swift + sourceTree + <group> + + B0311091CDAD38431C5438B08B426121 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable.swift + path + RxSwift/Observable.swift + sourceTree + <group> + + B040BC8C3C0854A94EC7C3D9416F4991 + + baseConfigurationReference + 0FE7E2183CFA9372B26D6AAB3552F84A + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + GCC_PREFIX_HEADER + Target Support Files/RxTests/RxTests-prefix.pch + INFOPLIST_FILE + Target Support Files/RxTests/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 8.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/RxTests/RxTests.modulemap + MTL_ENABLE_DEBUG_INFO + NO + PRODUCT_NAME + RxTests + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + B155708CA4773A61C1AF2F88ED3AD402 + + fileRef + D080AB530F399015439A7DF564605E61 + isa + PBXBuildFile + + B1875CEE144C785E5485DB6F3DB238E6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RefCountDisposable.swift + path + RxSwift/Disposables/RefCountDisposable.swift + sourceTree + <group> + + B1894B5A781F4A8CE2661D2E9E09EDA2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Range.swift + path + RxSwift/Observables/Implementations/Range.swift + sourceTree + <group> + + B19B3DF8A55437DE0ED76B2709E038E5 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Binding.swift + path + RxSwift/Observables/Observable+Binding.swift + sourceTree + <group> + + B1E9E7F8B45DFCF69DF6321C6443610E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIViewController+Rx.swift + path + RxCocoa/iOS/UIViewController+Rx.swift + sourceTree + <group> + + B239B0E7E196D400399060B6FAE28C01 + + includeInIndex + 1 + isa + PBXFileReference + path + RxCocoa.modulemap + sourceTree + <group> + + B25CA66FF8ABAB7F3FDDCDBD038F6B68 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Timeout.swift + path + RxSwift/Observables/Implementations/Timeout.swift + sourceTree + <group> + + B2BF716AC3FA9C09A8016CFDABF83757 + + fileRef + 2D89B097483A348B1246FED237C80E11 + isa + PBXBuildFile + + B3279F70AF109C76435EC34B61F8CDF6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ControlEvent.swift + path + RxCocoa/Common/CocoaUnits/ControlEvent.swift + sourceTree + <group> + + B328998EC30BD7D15D31C6B661AF7C75 + + baseConfigurationReference + 3015B9575200FA98F8C7F92704D4FC1D + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + INFOPLIST_FILE + Target Support Files/Pods-Protium/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/Pods-Protium/Pods-Protium.modulemap + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_BUNDLE_IDENTIFIER + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + PRODUCT_NAME + Pods_Protium + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + B32E8D16E0DA6995B852C9A2E4E64326 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + PublishSubject.swift + path + RxSwift/Subjects/PublishSubject.swift + sourceTree + <group> + + B34FFC75156F1731978A3B4A68B6823C + + isa + PBXTargetDependency + name + RxSwift + target + 61DE7C52A85DB9EA328A7BF08F9B28A1 + targetProxy + 90447847FD6EC217674F141B5A05B671 + + B3889A445D7E8A75BA206A3564286905 + + isa + PBXTargetDependency + name + JASON + target + 36730F6F2D4279BA1D7AF40EA756D893 + targetProxy + 898C045369AB76F70669F8DBF7C7CFB7 + + B39AED95CE54F436A4B3D2BB055E6F6E + + buildActionMask + 2147483647 + files + + CDCF615CA44AC57DB1712D744CB16F55 + C6B971200FDEE7C74AABCCA56FADD2C8 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + B47BCAB34EDB11E8577EB40AA2878853 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + DisposeBag.swift + path + RxSwift/Disposables/DisposeBag.swift + sourceTree + <group> + + B4B6254371287A865CF0832EB06DE6CB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + B4C599FAFF4BE26DAD1BE71037D5034E + + fileRef + EC8596C451F66165C70C1684E362F059 + isa + PBXBuildFile + + B4FB092861BD2AD108A335B027BD3B61 + + fileRef + B19B3DF8A55437DE0ED76B2709E038E5 + isa + PBXBuildFile + + B513DD750CAC32A84E315E8BBDC46145 + + fileRef + E73B4237DA3B2466DAFBB414583FD475 + isa + PBXBuildFile + + B55275CD01E8747B76BEC3BB6A064629 + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + B572DD4BA7C1097A3C875955CB04D689 + + baseConfigurationReference + 98F2F75A1E6B746ED5C0810BA0938F21 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + INFOPLIST_FILE + Target Support Files/Pods-ProtiumUITests/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests.modulemap + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_BUNDLE_IDENTIFIER + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + PRODUCT_NAME + Pods_ProtiumUITests + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + B595ED03BDB33F76F13B5CF91354AC9D + + buildActionMask + 2147483647 + files + + 2863A9B3700F150130A3F2186CB985E4 + 246381E3BBFEFF002BEC679D98303558 + 7CD7E3D3D2F00FEF6669992C33B6EF6C + DB52B2C5D64315465D6A28D549F25795 + 81053DF0BD9A889390BD198A31064421 + C484E6817B9F855C07F1F083908DF263 + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + B5B2AD82D2A502933C256CEAEEBB8AC6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Concat.swift + path + RxSwift/Observables/Implementations/Concat.swift + sourceTree + <group> + + B68A4A6298BB7B1343CEDDE1E17C3C69 + + fileRef + 28E1A58A162320B9BB2B67C61B721126 + isa + PBXBuildFile + + B6A0C876DBC5A1D050188313E505B800 + + fileRef + 63DABA1FFE13FA1C0B89D677710F9004 + isa + PBXBuildFile + + B6CE376B339A9E142F219975D6B956FD + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + KingfisherManager.swift + path + Sources/KingfisherManager.swift + sourceTree + <group> + + B7A5C9B8E68595D5B14D21D4AE58B0C6 + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + Foundation.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/Foundation.framework + sourceTree + DEVELOPER_DIR + + B875AF6FD2019F1FDB7A4E7272FDAF1D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIView+Rx.swift + path + RxCocoa/iOS/UIView+Rx.swift + sourceTree + <group> + + B8CA879185FDCE045E777A3947F31C75 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + RxCocoa.h + path + RxCocoa/RxCocoa.h + sourceTree + <group> + + B8FA4DE7B60F9F14263C3A818C06E409 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Driver.swift + path + RxCocoa/Common/CocoaUnits/Driver/Driver.swift + sourceTree + <group> + + B969E1626F329CB660E4D94F4564A231 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Throttle.swift + path + RxSwift/Observables/Implementations/Throttle.swift + sourceTree + <group> + + BA14536EA6AD43498D71C9B39E3D176D + + buildActionMask + 2147483647 + files + + E4D344B95BFA9D512A3CB87BDA202339 + C491271FC2BF7C4CAD36A506FBE70513 + 39590BB12A92F11CFDB6FBEA487FFAA9 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + BB0D29820B21BF5038EAF9305AC023B3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Disposables.swift + path + RxSwift/Disposables/Disposables.swift + sourceTree + <group> + + BB10ADB5638F836AB74C3F337709002F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIPageControl+Rx.swift + path + RxCocoa/iOS/UIPageControl+Rx.swift + sourceTree + <group> + + BB88725F8AC17B17D032440A71A5F430 + + fileRef + 68D7F3E236BA0B173154D70D492BAE90 + isa + PBXBuildFile + + BBCE9C83DA6AA3C3EF94EB5C4641183E + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTests.swift + path + RxTests/RxTests.swift + sourceTree + <group> + + BC2947CFB7D0D969060848D6C189D9B6 + + fileRef + 5C7E848F3D292D10B68A7FD6F4CA0F77 + isa + PBXBuildFile + + BC3108B0D0BE17194D3D4C1040F6B566 + + fileRef + 472811508BA90FF334BBAEFD4C008015 + isa + PBXBuildFile + + BC7E7F96868870BF0AC7A047C96FBEB4 + + fileRef + 3BA85BD01AF66501D1A292CD7C6B8606 + isa + PBXBuildFile + + BD29294D1779CCB05F4FB67D4D85B11E + + fileRef + ED72C12BCDC75D149A416A68F2AEEAA3 + isa + PBXBuildFile + + BE7EC2F3B77B49030F19ABB24BF0B250 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + _RXKVOObserver.m + path + RxCocoa/Common/_RXKVOObserver.m + sourceTree + <group> + + BE7EC58F85D775B37FAA1845910E3777 + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + CFNetwork.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/CFNetwork.framework + sourceTree + DEVELOPER_DIR + + BEF3C2476006098D0F78AFB7C25A6DD3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIPickerView+Rx.swift + path + RxCocoa/iOS/UIPickerView+Rx.swift + sourceTree + <group> + + BF273484A47EEEA306370F0BDCBB80BC + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + String+Rx.swift + path + RxSwift/Extensions/String+Rx.swift + sourceTree + <group> + + BF4062D19B8E10C88C091B60E629F227 + + children + + 22D2DAD49819F437A4CF59CAF49133C9 + 7DD91369A74D78F8BD5CF6229BCDCA7F + 6E2A3A806B9EFCE2809E48440A89530C + 27043210461F447C16A04FE9F94A163A + 8A629D0146AB3964E918C6D0C2EC38FC + A76534D7DFD6D1BA2BA0DC506787DF58 + 340903F7309E583AB3002A2761220076 + 8827CF45B41D2C8ED46F04506DD7C360 + 707A627BA7149020978D80B4680B170A + D70E90D2BB0AE9D7A8471CF499A76E26 + 749A4C80D079D05EDA33C41391FEF357 + 2AF999DF6BF4FC4F1682B33D6DD84875 + A4C00F4B81E770A401EB903BF71070D8 + 19B88CEEBF6856885A98E9378AD1B651 + 4D6DCB1BDFDA7538AACC88F0CADA0803 + FD027FD68BD72E6CDACB8075DE52F46B + ACFB2F9D6862626D2D439265851BBD1A + CC37612205374CE26F934A186936AD0D + 05B0726AA7B2AB6F4C61E0B548D3254B + B5B2AD82D2A502933C256CEAEEBB8AC6 + FCE8B77130B2399CB446E7E186A1462C + C1E011B6F3D8C6B99656B7499EB2CC3F + 629C7CFDBD4ED17D35524C8E6CC27780 + A16BD051BA9486FC8A658E97FD35CD40 + E788EFB588DDA195197D9ED3563AA52C + 2FEA0A60B2BAF5AA499E5F8903C53227 + ED5FE2D000151E521DCF9AC00539C579 + 6BC99B192C2093713050F92809DC19D6 + 895E56E4245B4A7099A02340419C9941 + E8BAE9743CC9B50BE9E07F8A4ACE1598 + EA28930B5625C64AFECCBFB82B67BF7D + 5444BAC6249F353DA5BB7F9FDF5F585B + 978B275D7151323194A8F3C8441C0C8C + BB0D29820B21BF5038EAF9305AC023B3 + B47BCAB34EDB11E8577EB40AA2878853 + 557FAB2B5A8081C5D5C2D8DC99663A08 + 1477F4027E396D01C0C03B7C90E40905 + 6CFC0DD1C64E43055468D1C07AEA4917 + ADDB5D0F6296B9CDE47AC161BD8D28B2 + 85A8D690FEF985B22FA0D8E904D798CF + F671D336A41DED031436FD2A9DC62476 + 038B05059A9DA0E2D6D59EBAA6ABE6A4 + FE4BBBEEE8D120C6BFF816038A039476 + 7F3B0684BDA50424678D0F04F5F4B6A9 + 8D2C5AE451A1E77C40E2D4255EDA6B92 + D8476DDC29731AA0872954CF8E54F736 + A8C1C6BC08CDAE216386CB3AC7816837 + 2F0965C1D21DAB69E029693B70F76CC8 + 8752A7B07D7AA4309205EB06248ED9A1 + 44F8DEF97211D8DF786FAA3638623DBB + 51809082BA9EF96E6035FC285AE47656 + C773ACE4C55EC81C119CD31D4B427C80 + 267507D7FD9113EBB56B260245106410 + 5CF9988E46AD5CF69981BB77B2B1FE32 + 63E2FAC9A505C7341406BB896A55A80B + 3FB72F9120A7F5D338C8EBD9FC42C1E6 + D1B174689B47E89AA5F4F46AB452642A + CEEA81C1A2B7523B8EAD47E7BC30B9E2 + 43301C739484D386ACEF17E0247A2C78 + AEC736C235A1FB4000F381965CF37F47 + 8A79FC900E8432AF1D6C5601BB0E228B + B0311091CDAD38431C5438B08B426121 + 5EE912B1CFB4829EF6AD834FB43031D0 + B19B3DF8A55437DE0ED76B2709E038E5 + EC8596C451F66165C70C1684E362F059 + D30E0EF7B99E115A8E1593EC4CDEC5F7 + 443C35A369CCEAEA5FCE8316FA075DBB + 561510A63117712838EDD194B8C8160F + 1C15EB660EABC8BC39A7368A8C505A51 + 57FEC9C1852E7F179A3F4276ACFEB9E9 + C166C5948C14F8018BEEB953ACC5C61B + 561BD0A4BA8178289D9D390FF39EDB54 + 5C7E848F3D292D10B68A7FD6F4CA0F77 + 2636AE31BE4C89FA6FD121DB3CC0A90A + 8BBE57933C373D849DF6FF57704D944B + 6B19234D48C03E82E40AA3A861D87BE8 + A921505BA3663527E1F8995261D6A9C2 + 6B5645DA7C3FAE29C8FF060014DFFE73 + EA55A095EC216B41AE956E567FA25C54 + 33A585A7E2894DD5391E0E0AF09A9005 + 7BEAA159F6410024740B67A7033917F8 + 63DABA1FFE13FA1C0B89D677710F9004 + 7E8334AB56A363B2B6447C71379BA73B + B32E8D16E0DA6995B852C9A2E4E64326 + 1E4EB7DC68C633870CCEA7B3696CFE5E + B1894B5A781F4A8CE2661D2E9E09EDA2 + 8FA96819840E9DB6C2A7A5129A63A27D + D080AB530F399015439A7DF564605E61 + CA15E3D8E6981AAF4CD9D0179BAB4D6C + 0D72171ABB370853B371A14013E4AC7A + B1875CEE144C785E5485DB6F3DB238E6 + 2D8BAB3C320BF917B39606398D8471CF + CA4E6A06F4F0EFF583F26E82175DE491 + FD6FC2369CB44D3D98C297BA5278F32F + E9799FDB58963DE7FB16D0B1DB8D8835 + 59DCDE13FD9DE2EB8671EA88218F625F + 8248EFACD13D1BE9AC0D2F0D10B3D3CE + 0EA5F4B9AC952EE0877A6B59786649B8 + 58F81CAA492FE07017BB7C4C5DCC61EE + F8256B56314777FFBA9DB2DED3FECA70 + CDE7BE7C791D1C7C7FD2987827629F25 + 5E0A2B28C76300A5BD5B267FA2F4589B + 30A32126A828680D3317DA6D6C2B1BC6 + E406863E65E4620458952E3DB5CBCA68 + 0912BE80640FD3244ED04DFDDF226908 + 8D4F1F32D4C254DCD8B7308F112396E3 + 2D89B097483A348B1246FED237C80E11 + 6A6D5D6E9CAC72A9A938476C26ADE14E + 7B41CDE0B855F5277DA0AF36FE886785 + 197E41CA9E9F02081E0321D327AC5BC9 + 2790EB118B15B71CDB9574420065104D + E67E71475E217C4D0E8169FB56D4E77D + 2D8A0ABE3394CA2F318CAFD6DD2A6C4D + 2C534BA43D1B0A9C1DFC4499CDFFFE46 + C4506C2A1CB80DA888EC917E38A17B36 + 28E4F90636ABD0A49758F9924EF1F716 + BF273484A47EEEA306370F0BDCBB80BC + 28665FE80851BA4018C3B6CEB8D11565 + 8F2626E6E89E1FB8D4BBBE72B59DE13F + 9A585A08792F5106904E2DCCCB9BF88D + 4A4FCE35F848FA9F21257C75E99D2076 + A36D07A8CADB7102BC6A9C4ACA586AF0 + 2B5F45E1C48CD5DEDE3752625DFD0B4D + 960BA22488C9BE8721C46AF106FCD49F + A6DEEB3BF2044FA67C9FBD7B86DD9EC1 + 4003EF315D8605C2D2CED4F4013AB827 + 4B8A5E523A2B7F9B1D1D18E02FFDE2C0 + CC4471FBFC7A9E288DC40A4CDC6DA12B + 1CF77BA0DF6F148591F0939A3A05A88C + 361BE5E078278DDBED70EBEEF02C592C + B969E1626F329CB660E4D94F4564A231 + B25CA66FF8ABAB7F3FDDCDBD038F6B68 + 04895717546E08E3950147F2A218F68C + 8A4978326FA2016A5EC2A44D88128515 + 10900F282BCFAEA50F569FD199B316E9 + F400AE7E8D81785EE7B3307C4D4F5C2A + 416680E5D51ACB06A832967877B08B97 + 0C0AF2B6553D84BC43675EA85DF20CF7 + 595E5793277C7195FA9D9C395ABB520A + 3028D2AF9AE52FAB06642186A23E39ED + 6A5F2D0667733981380A06FF2836C8E5 + 4E2500A89363FFDA9B8E22F8A14AAA3D + 8892762409E64DBABBD1226631A3324C + D648DA352E13AFB027CB11399A6A1ADC + + isa + PBXGroup + name + RxSwift + path + RxSwift + sourceTree + <group> + + BFC1A7AF44A4F114D71E543C4C05964E + + buildConfigurations + + 98AE9A07ADB081C3BDC7EC7E4FC3C75F + 1102F622EA7208C35E65515E20D05F26 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + BFCC224204AC4284ECDDA8909DE4C07D + + children + + C8A4484C5C7EECD0E3DFD55B7084C2FA + 190F5E93C0C31880B0AE65105FEAA96D + E27A1D2F7964D5804F73FFE3BE7380F3 + 1237FA520495ED6EB62C1AC57B854FBD + 44475F4AF55481DA82EE8F4959F4F6B7 + 3A86D7D6963BC3877BAEAF918A175BB6 + 39003651A2D53C84180E05295CA048D8 + A19ED70E760FB83A79FAED20BB8D8AFC + 79E908B32EF1F8C343DBBAF5626631F4 + 3015B9575200FA98F8C7F92704D4FC1D + + isa + PBXGroup + name + Pods-Protium + path + Target Support Files/Pods-Protium + sourceTree + <group> + + BFEA396191E5EE3E8306FE5FD73A18EF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + BlockingObservable.swift + path + RxBlocking/BlockingObservable.swift + sourceTree + <group> + + C055D103171DD80FE39B31E6F3E20BD4 + + fileRef + 4A4FCE35F848FA9F21257C75E99D2076 + isa + PBXBuildFile + + C07D2A8B30A1C35A24C6B9D689290840 + + buildActionMask + 2147483647 + files + + EE2F34B0BA1B34C7A826B60ED1F34F46 + D96A6C6E1676F9832AA3BE49E22AAEBA + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + C0B6F9762980F7044836DD4E992085DD + + buildConfigurationList + 9C89F4A1946C8C85A2D49E5AA09E00B8 + buildPhases + + E28D94D7B76C1BE3BE9BCDB394D0E162 + E57E193108977F23F4100EAC539B9A42 + 48C983C5746352F6425F616946521659 + + buildRules + + dependencies + + isa + PBXNativeTarget + name + Pods-ProtiumUITests + productName + Pods-ProtiumUITests + productReference + 2835BE61F1F6C00428ECE172ACD1272A + productType + com.apple.product-type.framework + + C111769B1B854C4BEB63516871DBE9F4 + + buildConfigurations + + 9A93D2720DB746F6C1B323797C4985CB + 7C69E3234122DEC2764CE03683E6A8E1 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + C148730C48D1F8C7CC630677E90651F7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + DelegateProxy.swift + path + RxCocoa/Common/DelegateProxy.swift + sourceTree + <group> + + C166C5948C14F8018BEEB953ACC5C61B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Time.swift + path + RxSwift/Observables/Observable+Time.swift + sourceTree + <group> + + C1B8D8FE3B63424F8D7FEA6A54EF96B9 + + fileRef + 3940091C7715CD549AE69A9D5F935021 + isa + PBXBuildFile + + C1E011B6F3D8C6B99656B7499EB2CC3F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ConcurrentMainScheduler.swift + path + RxSwift/Schedulers/ConcurrentMainScheduler.swift + sourceTree + <group> + + C20E6427633E7A6CF39DE6B8147977CD + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + RxSwift-dummy.m + sourceTree + <group> + + C2619162D80DCA8FC798A060AE7482A3 + + fileRef + E100F12B20B026E8A167F751D4E6D04A + isa + PBXBuildFile + + C285C5D828A00493BA41C47B5561ABAF + + fileRef + B1875CEE144C785E5485DB6F3DB238E6 + isa + PBXBuildFile + + C35BED43CD153EA467343937F6AFBFF0 + + fileRef + 5E4EA8DE8950109984D1C20DB34FB914 + isa + PBXBuildFile + + C3B74895AB1F3A7B3048114012F38022 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ImagePrefetcher.swift + path + Sources/ImagePrefetcher.swift + sourceTree + <group> + + C3DEEE31BD151F191D46C7B8CCD2E2B1 + + fileRef + A19ED70E760FB83A79FAED20BB8D8AFC + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + C4506C2A1CB80DA888EC917E38A17B36 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + StableCompositeDisposable.swift + path + RxSwift/Disposables/StableCompositeDisposable.swift + sourceTree + <group> + + C484E6817B9F855C07F1F083908DF263 + + fileRef + B8CA879185FDCE045E777A3947F31C75 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + C491271FC2BF7C4CAD36A506FBE70513 + + fileRef + 2D6090EE8DEF9C120BED3D29FE78A5CC + isa + PBXBuildFile + + C4AFDB3BA38A46B3FD37BC5B714F9DC4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxScrollViewDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift + sourceTree + <group> + + C5FAA08B6A2A52648DEDACA8859EFDC3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RunLoopLock.swift + path + RxBlocking/RunLoopLock.swift + sourceTree + <group> + + C6185FDCFFCA7B2F3DA8323DD11BA014 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + RxBlocking-umbrella.h + sourceTree + <group> + + C69EDE2902EC8910C725EF789E8F9FF9 + + fileRef + E9859681AF69FE5B64F6D4A019D99429 + isa + PBXBuildFile + + C6B971200FDEE7C74AABCCA56FADD2C8 + + fileRef + 2D6090EE8DEF9C120BED3D29FE78A5CC + isa + PBXBuildFile + + C76712F1D91555C20B4418A2A24E1DFB + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Variable+SharedSequence.swift + path + RxCocoa/Common/CocoaUnits/SharedSequence/Variable+SharedSequence.swift + sourceTree + <group> + + C773ACE4C55EC81C119CD31D4B427C80 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + InvocableType.swift + path + RxSwift/Schedulers/Internal/InvocableType.swift + sourceTree + <group> + + C77ECE7C5A9FA2DEDFD78B0E78568372 + + fileRef + 2EFAB4427F44FF51FC350BC9635B0056 + isa + PBXBuildFile + + C7E474A03CAE21F1CB6046E7344C59BD + + buildSettings + + ALWAYS_SEARCH_USER_PATHS + NO + CLANG_ANALYZER_NONNULL + YES + CLANG_CXX_LANGUAGE_STANDARD + gnu++0x + CLANG_CXX_LIBRARY + libc++ + CLANG_ENABLE_MODULES + YES + CLANG_ENABLE_OBJC_ARC + YES + CLANG_WARN_BOOL_CONVERSION + YES + CLANG_WARN_CONSTANT_CONVERSION + YES + CLANG_WARN_DIRECT_OBJC_ISA_USAGE + YES + CLANG_WARN_EMPTY_BODY + YES + CLANG_WARN_ENUM_CONVERSION + YES + CLANG_WARN_INT_CONVERSION + YES + CLANG_WARN_OBJC_ROOT_CLASS + YES + CLANG_WARN_UNREACHABLE_CODE + YES + CLANG_WARN__DUPLICATE_METHOD_MATCH + YES + COPY_PHASE_STRIP + YES + ENABLE_NS_ASSERTIONS + NO + GCC_C_LANGUAGE_STANDARD + gnu99 + GCC_PREPROCESSOR_DEFINITIONS + + POD_CONFIGURATION_RELEASE=1 + $(inherited) + + GCC_WARN_64_TO_32_BIT_CONVERSION + YES + GCC_WARN_ABOUT_RETURN_TYPE + YES + GCC_WARN_UNDECLARED_SELECTOR + YES + GCC_WARN_UNINITIALIZED_AUTOS + YES + GCC_WARN_UNUSED_FUNCTION + YES + GCC_WARN_UNUSED_VARIABLE + YES + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + STRIP_INSTALLED_PRODUCT + NO + SYMROOT + ${SRCROOT}/../build + VALIDATE_PRODUCT + YES + + isa + XCBuildConfiguration + name + Release + + C8113E56BC2E02C84353DFF80D05290C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Pods-ProtiumTests-dummy.m + sourceTree + <group> + + C81A4C041EADA36B483C25F9D43CA508 + + baseConfigurationReference + 35F13ACCB05044E146B13BCFD98D442F + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + INFOPLIST_FILE + Target Support Files/Pods-ProtiumUITests/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/Pods-ProtiumUITests/Pods-ProtiumUITests.modulemap + MTL_ENABLE_DEBUG_INFO + YES + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_BUNDLE_IDENTIFIER + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + PRODUCT_NAME + Pods_ProtiumUITests + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + C877ED8A782B3D02D32F6D8FEB6CBFFF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Event+Equatable.swift + path + RxTests/Event+Equatable.swift + sourceTree + <group> + + C884C04605138975C27F2F3E0C7C3F65 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSURLSession+Rx.swift + path + RxCocoa/Common/Observables/NSURLSession+Rx.swift + sourceTree + <group> + + C8871540DB8C08FD461E40CB755B0267 + + fileRef + 3028D2AF9AE52FAB06642186A23E39ED + isa + PBXBuildFile + + C88A702CA5DB93370E0D592555941665 + + fileRef + CDE7BE7C791D1C7C7FD2987827629F25 + isa + PBXBuildFile + + C890C366ECC9941118DC9424BE86A498 + + fileRef + 91E91D57C5DE554FE6FC86659413EE7C + isa + PBXBuildFile + + C8A4484C5C7EECD0E3DFD55B7084C2FA + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + C9A9D44000D63D17649F2888F21FD5FB + + fileRef + 6AEF70AE4E94172111D3B9A098B2A36C + isa + PBXBuildFile + + CA019E94C0D527A7443ED288E884437A + + children + + FA7F8BBBC7E7087ED73CF54CB8086FFE + 047F93295F4CC9EA3752C4E819848C94 + E5A5C7D4C55BCFBD1DF660728D6A4233 + 7E2FBFD9C7C0F7EE7E1C32DC31F91217 + BF4062D19B8E10C88C091B60E629F227 + 07554FF0DFB8E44BEB63CF5E84B70800 + + isa + PBXGroup + name + Pods + sourceTree + <group> + + CA15E3D8E6981AAF4CD9D0179BAB4D6C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Reduce.swift + path + RxSwift/Observables/Implementations/Reduce.swift + sourceTree + <group> + + CA4E6A06F4F0EFF583F26E82175DE491 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ReplaySubject.swift + path + RxSwift/Subjects/ReplaySubject.swift + sourceTree + <group> + + CA76F98AC131EE1F1AE355BB2B62AFAF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIButton+Rx.swift + path + RxCocoa/iOS/UIButton+Rx.swift + sourceTree + <group> + + CBABB29D090B20282926B01B82F2C05B + + fileRef + 28665FE80851BA4018C3B6CEB8D11565 + isa + PBXBuildFile + + CC233C1C39735A9B61B795C5380C482A + + fileRef + 267507D7FD9113EBB56B260245106410 + isa + PBXBuildFile + + CC37612205374CE26F934A186936AD0D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + CombineLatest+CollectionType.swift + path + RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift + sourceTree + <group> + + CC4471FBFC7A9E288DC40A4CDC6DA12B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TakeLast.swift + path + RxSwift/Observables/Implementations/TakeLast.swift + sourceTree + <group> + + CC513442B1C0CC1AEF8E7F9B76801010 + + fileRef + 238791B373CDA93CC0839A4B4B2B1438 + isa + PBXBuildFile + + CD4918BA077C9ADFB99E406398432A16 + + fileRef + EE4437314BB8F7C003FE450692818CA9 + isa + PBXBuildFile + + CDBE4F004D462026704CCA29A51A4468 + + fileRef + 2FEA0A60B2BAF5AA499E5F8903C53227 + isa + PBXBuildFile + + CDCF615CA44AC57DB1712D744CB16F55 + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + CDE7BE7C791D1C7C7FD2987827629F25 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ScheduledItemType.swift + path + RxSwift/Schedulers/Internal/ScheduledItemType.swift + sourceTree + <group> + + CE0893BD26C65063A93EE845FF68950D + + fileRef + 8248EFACD13D1BE9AC0D2F0D10B3D3CE + isa + PBXBuildFile + + CE5E71FA9C53D39A6BCEB487DD0DD45F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UISlider+Rx.swift + path + RxCocoa/iOS/UISlider+Rx.swift + sourceTree + <group> + + CE864B5D326FBB05E0206BA17BD11E2A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIImageView+Rx.swift + path + RxCocoa/iOS/UIImageView+Rx.swift + sourceTree + <group> + + CEA8E330EBD24DDCA08B7D83AE9EF62F + + fileRef + 4D6DCB1BDFDA7538AACC88F0CADA0803 + isa + PBXBuildFile + + CEEA81C1A2B7523B8EAD47E7BC30B9E2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Merge.swift + path + RxSwift/Observables/Implementations/Merge.swift + sourceTree + <group> + + CF0379F792D2BDDD7C87A9A8C12ADC0B + + fileRef + C6185FDCFFCA7B2F3DA8323DD11BA014 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + CF04EEAA2F2DAF98B28FC481D7172F17 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + JSONKey.swift + path + Source/JSONKey.swift + sourceTree + <group> + + CF1E35BA779713EECD47A8EC48570341 + + fileRef + D730FCBFCE9801934DF37148EE65289A + isa + PBXBuildFile + + CFA84C1832F9E331C7EA43DA7DE725D4 + + fileRef + 2636AE31BE4C89FA6FD121DB3CC0A90A + isa + PBXBuildFile + + CFD48468A6CA68736D3A8E3DE978980D + + fileRef + CF04EEAA2F2DAF98B28FC481D7172F17 + isa + PBXBuildFile + + D080AB530F399015439A7DF564605E61 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RecursiveScheduler.swift + path + RxSwift/Schedulers/RecursiveScheduler.swift + sourceTree + <group> + + D0AEE6B32E344932FB99095671FEFF17 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SharedSequence.swift + path + RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence.swift + sourceTree + <group> + + D0EB34A0C99F4F66F73602585083C0F1 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + RxCocoa-umbrella.h + sourceTree + <group> + + D1677FA94A11260649A9F35C57B515A9 + + fileRef + 2D8BAB3C320BF917B39606398D8471CF + isa + PBXBuildFile + + D1B174689B47E89AA5F4F46AB452642A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Map.swift + path + RxSwift/Observables/Implementations/Map.swift + sourceTree + <group> + + D22302B067FD4068C8508CE247148756 + + fileRef + EA55A095EC216B41AE956E567FA25C54 + isa + PBXBuildFile + + D285C0611719C40B5DB70677582F237C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UILabel+Rx.swift + path + RxCocoa/iOS/UILabel+Rx.swift + sourceTree + <group> + + D28A7AAD1D04D7C42A4710E73AEC2A9A + + fileRef + 75AAF33F80B873350E29B9660892F93F + isa + PBXBuildFile + + D2D3B4657877EB8DE3E8C4A47BC0B0DA + + fileRef + C8113E56BC2E02C84353DFF80D05290C + isa + PBXBuildFile + + D30DE305E45CE4E33EF52C1E190A2043 + + fileRef + 84EA2C0F10668146DCEC8BAA216ECC11 + isa + PBXBuildFile + + D30E0EF7B99E115A8E1593EC4CDEC5F7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Creation.swift + path + RxSwift/Observables/Observable+Creation.swift + sourceTree + <group> + + D409E2DF8A5DD29ADE368DC000C6E9D5 + + fileRef + 1C15EB660EABC8BC39A7368A8C505A51 + isa + PBXBuildFile + + D41D8CD98F00B204E9800998ECF8427E + + attributes + + LastSwiftUpdateCheck + 0730 + LastUpgradeCheck + 0700 + + buildConfigurationList + 2D8E8EC45A3A1A1D94AE762CB5028504 + compatibilityVersion + Xcode 3.2 + developmentRegion + English + hasScannedForEncodings + 0 + isa + PBXProject + knownRegions + + en + + mainGroup + 7DB346D0F39D3F0E887471402A8071AB + productRefGroup + 566675550863A10DD73456F1DEF932C8 + projectDirPath + + projectReferences + + projectRoot + + targets + + 36730F6F2D4279BA1D7AF40EA756D893 + 1DE93A359FA21F91DFBE81309E851A4A + 9689D3C4A85456EC61731D6A3B9AF311 + 1B8C2060305BDBAC73F070F4E0DF22AC + C0B6F9762980F7044836DD4E992085DD + E533BBCDF7DEEF815B15C51BCE1EEFCB + ADDC61C64160A002293A6F9DBE4C9073 + 61DE7C52A85DB9EA328A7BF08F9B28A1 + 39B24F6A272FFEB2BCF79FC06934033B + + + D4C3AE2ED883065D6C2C5AB0052672D7 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UITextView+Rx.swift + path + RxCocoa/iOS/UITextView+Rx.swift + sourceTree + <group> + + D63295D11C4CE5AA0747133C2221AA2A + + fileRef + CE864B5D326FBB05E0206BA17BD11E2A + isa + PBXBuildFile + + D648DA352E13AFB027CB11399A6A1ADC + + children + + 8BF0887831DD737987DFDABF2B0B3037 + 9C78E38E6070BCBF868A821B4DB82BAF + A3633765E42B66E74FFC904D347B8F7D + C20E6427633E7A6CF39DE6B8147977CD + D70E753DEDDFBEF4D6D72413BEF26DB4 + 66717BF3866489EDA0223699A5AD8002 + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/RxSwift + sourceTree + <group> + + D6A4C6F5B4808280747D3E14B7CD6659 + + fileRef + 2C534BA43D1B0A9C1DFC4499CDFFFE46 + isa + PBXBuildFile + + D70E753DEDDFBEF4D6D72413BEF26DB4 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + RxSwift-prefix.pch + sourceTree + <group> + + D70E90D2BB0AE9D7A8471CF499A76E26 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + BehaviorSubject.swift + path + RxSwift/Subjects/BehaviorSubject.swift + sourceTree + <group> + + D730FCBFCE9801934DF37148EE65289A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UITabBar+Rx.swift + path + RxCocoa/iOS/UITabBar+Rx.swift + sourceTree + <group> + + D7C8B6A2BD6EA4788F3B6D7540DFF000 + + fileRef + 6B5645DA7C3FAE29C8FF060014DFFE73 + isa + PBXBuildFile + + D8476DDC29731AA0872954CF8E54F736 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + HistoricalScheduler.swift + path + RxSwift/Schedulers/HistoricalScheduler.swift + sourceTree + <group> + + D96A6C6E1676F9832AA3BE49E22AAEBA + + fileRef + 8CF21CA2ED42F707A04778117CA393C8 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + D990773B61E135AD5C2092127CA19E11 + + fileRef + 9A585A08792F5106904E2DCCCB9BF88D + isa + PBXBuildFile + + DA0A7D3B8B6431DDA98241A42F12FD1B + + fileRef + BEF3C2476006098D0F78AFB7C25A6DD3 + isa + PBXBuildFile + + DA3543355A611988BA0192DCE6A83D26 + + includeInIndex + 1 + isa + PBXFileReference + path + Kingfisher.modulemap + sourceTree + <group> + + DA9504C21EBEDF08864744E77FDAEACE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ImageTransition.swift + path + Sources/ImageTransition.swift + sourceTree + <group> + + DAAF9D50BAC3D0D45F9A2C2D0D90CDD6 + + fileRef + 6A5F2D0667733981380A06FF2836C8E5 + isa + PBXBuildFile + + DAAFE269E211D287FB9D82A6EBA712EC + + fileRef + F99913BD0EBF168FFF11E182EEF49F95 + isa + PBXBuildFile + + DB52B2C5D64315465D6A28D549F25795 + + fileRef + DD0435041DE5BD31668B59A3630E3991 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + DC3A007A57F7B524D373105688FBFF03 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + _RXKVOObserver.h + path + RxCocoa/Common/_RXKVOObserver.h + sourceTree + <group> + + DC53B0FA1BEB7DD97A312EA29554103C + + fileRef + 4B8A5E523A2B7F9B1D1D18E02FFDE2C0 + isa + PBXBuildFile + + DD0435041DE5BD31668B59A3630E3991 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + _RXObjCRuntime.h + path + RxCocoa/Common/_RXObjCRuntime.h + sourceTree + <group> + + DD276C8B13DAFB6E87E640E6DD72D9BE + + fileRef + 72FAF2A2C6D9EFD7CA5956B9C1E56C29 + isa + PBXBuildFile + + DD57063D51EB120D785510A8471EC423 + + fileRef + 7EC1AFEC6E8403CBEC48818B43A598C5 + isa + PBXBuildFile + + DDC09AF4651F7EB2C2E77FAE1C3E3964 + + fileRef + B0311091CDAD38431C5438B08B426121 + isa + PBXBuildFile + + DF56D2636D4CABA9302A3F35A515F93E + + fileRef + 2CCFCE6F6BC1B2744A6CAE46739803D2 + isa + PBXBuildFile + + DFF5DB293565A9E4C9F2243A88F7388D + + fileRef + 8A4978326FA2016A5EC2A44D88128515 + isa + PBXBuildFile + + E03446357CE15647936B4979A933C069 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ControlEvent+Driver.swift + path + RxCocoa/Common/CocoaUnits/Driver/ControlEvent+Driver.swift + sourceTree + <group> + + E0AEFDA57C95C5E8FAFF5DA96F0215DD + + fileRef + 6677B0D564F599722921B4D35D1160E5 + isa + PBXBuildFile + + E100F12B20B026E8A167F751D4E6D04A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ObservableConvertibleType+SharedSequence.swift + path + RxCocoa/Common/CocoaUnits/SharedSequence/ObservableConvertibleType+SharedSequence.swift + sourceTree + <group> + + E1881263D98EF75B0004726191CC8AA1 + + fileRef + CA4E6A06F4F0EFF583F26E82175DE491 + isa + PBXBuildFile + + E194E3FD1197CE81144FD02A6FE47443 + + fileRef + CC4471FBFC7A9E288DC40A4CDC6DA12B + isa + PBXBuildFile + + E19E35C59A47E156CEFC8E905629133B + + fileRef + 06609935DEF174AEDF2661BA47817341 + isa + PBXBuildFile + + E1E0D8EFEAD0FA82CB766D828883D8D8 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ImageView+Kingfisher.swift + path + Sources/ImageView+Kingfisher.swift + sourceTree + <group> + + E262278CEF901FD6DDF1AF07A1CC8ABE + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIGestureRecognizer+Rx.swift + path + RxCocoa/iOS/UIGestureRecognizer+Rx.swift + sourceTree + <group> + + E27A1D2F7964D5804F73FFE3BE7380F3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text + path + Pods-Protium-acknowledgements.markdown + sourceTree + <group> + + E28D94D7B76C1BE3BE9BCDB394D0E162 + + buildActionMask + 2147483647 + files + + DD276C8B13DAFB6E87E640E6DD72D9BE + + isa + PBXSourcesBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + E35C8326CA9BEE6593219AA42FBC5EC0 + + buildConfigurations + + 1C74B0A9F196309C61B7C9887C6C4346 + B040BC8C3C0854A94EC7C3D9416F4991 + + defaultConfigurationIsVisible + 0 + defaultConfigurationName + Release + isa + XCConfigurationList + + E36FDA97D600E8DAAB9A573C0CE6666B + + fileRef + 09D6EB9C609BD9AEB1BF560D6C7192DF + isa + PBXBuildFile + + E379F36B5207745C8A1B99CC359DBD31 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + name + _RXDelegateProxy.m + path + RxCocoa/Common/_RXDelegateProxy.m + sourceTree + <group> + + E3B3EDE61D0A4998919CCEF24894DF13 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + E3C5F98E92B9F961686689CBAC0014B0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + NSLayoutConstraint+Rx.swift + path + RxCocoa/Common/NSLayoutConstraint+Rx.swift + sourceTree + <group> + + E3E14EF30FA33B187FD43544C7E44AD3 + + fileRef + 3160C670FE54847CA02BE1FFBA62AABF + isa + PBXBuildFile + + E3EBBA8A95A971F78E0531194A4B6CFB + + fileRef + 443C35A369CCEAEA5FCE8316FA075DBB + isa + PBXBuildFile + + E406863E65E4620458952E3DB5CBCA68 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Sequence.swift + path + RxSwift/Observables/Implementations/Sequence.swift + sourceTree + <group> + + E4D344B95BFA9D512A3CB87BDA202339 + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + E5262145BED306892AF6D3580D41C077 + + fileRef + BB10ADB5638F836AB74C3F337709002F + isa + PBXBuildFile + + E533BBCDF7DEEF815B15C51BCE1EEFCB + + buildConfigurationList + BFC1A7AF44A4F114D71E543C4C05964E + buildPhases + + 31BE518A3E79AE3137EC2531B1DCD676 + 08DD077B1B0DAC414E32C5A227E8B66A + 0675C9C59482BBF63F4A5194702BD44D + + buildRules + + dependencies + + 1FBC5B6799FDC43C75C525EC261151BC + + isa + PBXNativeTarget + name + RxBlocking + productName + RxBlocking + productReference + F906D576A00915E90F52B0030FEAA12C + productType + com.apple.product-type.framework + + E57E193108977F23F4100EAC539B9A42 + + buildActionMask + 2147483647 + files + + B55275CD01E8747B76BEC3BB6A064629 + + isa + PBXFrameworksBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + E5A5C7D4C55BCFBD1DF660728D6A4233 + + children + + BFEA396191E5EE3E8306FE5FD73A18EF + 68D7F3E236BA0B173154D70D492BAE90 + 58BF5A22D02E154ECE59EB1E9A870955 + C5FAA08B6A2A52648DEDACA8859EFDC3 + 4C25D285DD12D48EB129F3CC8F1645A1 + + isa + PBXGroup + name + RxBlocking + path + RxBlocking + sourceTree + <group> + + E5EE3682D8E144AB86F3C587ED86ABBF + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + path + Kingfisher-umbrella.h + sourceTree + <group> + + E60D7E3D11544411A5285DA04F091ABD + + baseConfigurationReference + 6D42D4C6C8A31ACF6D99262C3B001D7F + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + INFOPLIST_FILE + Target Support Files/Pods-ProtiumTests/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests.modulemap + MTL_ENABLE_DEBUG_INFO + YES + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_BUNDLE_IDENTIFIER + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + PRODUCT_NAME + Pods_ProtiumTests + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_OPTIMIZATION_LEVEL + -Onone + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Debug + + E67E71475E217C4D0E8169FB56D4E77D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Skip.swift + path + RxSwift/Observables/Implementations/Skip.swift + sourceTree + <group> + + E6BC3ADC7A555B71F715D3E9C81D2947 + + fileRef + FD6FC2369CB44D3D98C297BA5278F32F + isa + PBXBuildFile + + E73B4237DA3B2466DAFBB414583FD475 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIButton+Kingfisher.swift + path + Sources/UIButton+Kingfisher.swift + sourceTree + <group> + + E788EFB588DDA195197D9ED3563AA52C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + CurrentThreadScheduler.swift + path + RxSwift/Schedulers/CurrentThreadScheduler.swift + sourceTree + <group> + + E7D2CE9E029F6D3C24F508100F5E7986 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RequrstModifier.swift + path + Sources/RequrstModifier.swift + sourceTree + <group> + + E827B13D2D509D49FD2051E1FB483635 + + fileRef + 5351DCF327DBE3E6296C9BBD9B4258F4 + isa + PBXBuildFile + + E8385A0F8DD09031BE6F619C7187EA50 + + fileRef + 557FAB2B5A8081C5D5C2D8DC99663A08 + isa + PBXBuildFile + + E86C09D56F715CABE887E581C534BC35 + + fileRef + B7A5C9B8E68595D5B14D21D4AE58B0C6 + isa + PBXBuildFile + + E8BAE9743CC9B50BE9E07F8A4ACE1598 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + DelaySubscription.swift + path + RxSwift/Observables/Implementations/DelaySubscription.swift + sourceTree + <group> + + E8D1BEAFADF605A62DF0AD9BC2366078 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxSearchBarDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift + sourceTree + <group> + + E90658D75782B6988AA960861393B6F0 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Info.plist + sourceTree + <group> + + E9429CDFC4D0F9230F1DBCEA4D486ADC + + fileRef + 8F005F713676620204DACBF03E96AA2B + isa + PBXBuildFile + + E9799FDB58963DE7FB16D0B1DB8D8835 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Rx.swift + path + RxSwift/Rx.swift + sourceTree + <group> + + E9859681AF69FE5B64F6D4A019D99429 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + UIDatePicker+Rx.swift + path + RxCocoa/iOS/UIDatePicker+Rx.swift + sourceTree + <group> + + E98CEFE252B2A6AB425D26509A7EB7F3 + + fileRef + 8763B305232564AFE056FF9EBF34CEE3 + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + EA28930B5625C64AFECCBFB82B67BF7D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + DispatchQueueConfiguration.swift + path + RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift + sourceTree + <group> + + EA55A095EC216B41AE956E567FA25C54 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + OperationQueueScheduler.swift + path + RxSwift/Schedulers/OperationQueueScheduler.swift + sourceTree + <group> + + EBBCDDEBBAFA7C83ABA9840C6E4D336C + + fileRef + 5CF9988E46AD5CF69981BB77B2B1FE32 + isa + PBXBuildFile + + EBF46630EADC2FAD1ACEC88BCD3C3EB5 + + isa + PBXTargetDependency + name + RxSwift + target + 61DE7C52A85DB9EA328A7BF08F9B28A1 + targetProxy + 82FBB3A74E788E50C77B8F576C77AD93 + + EC2BE04EEBC2C95D80EDBEBF2A7AEFE2 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Indicator.swift + path + Sources/Indicator.swift + sourceTree + <group> + + EC8596C451F66165C70C1684E362F059 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Observable+Concurrency.swift + path + RxSwift/Observables/Observable+Concurrency.swift + sourceTree + <group> + + ECB0B695F6EA4A153C77E994FCD69686 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text + path + Pods-ProtiumUITests-acknowledgements.markdown + sourceTree + <group> + + ED5FE2D000151E521DCF9AC00539C579 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Debunce.swift + path + RxSwift/Observables/Implementations/Debunce.swift + sourceTree + <group> + + ED72C12BCDC75D149A416A68F2AEEAA3 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + SectionedViewDataSourceType.swift + path + RxCocoa/Common/SectionedViewDataSourceType.swift + sourceTree + <group> + + EE2F34B0BA1B34C7A826B60ED1F34F46 + + fileRef + E5EE3682D8E144AB86F3C587ED86ABBF + isa + PBXBuildFile + settings + + ATTRIBUTES + + Public + + + + EE4437314BB8F7C003FE450692818CA9 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTextStorageDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift + sourceTree + <group> + + EFA20FEFA16A9D29C766EBBCBA72F172 + + isa + PBXTargetDependency + name + RxSwift + target + 61DE7C52A85DB9EA328A7BF08F9B28A1 + targetProxy + 0BCE650BA734D8134846A034078C3277 + + EFBBDE724A051A00E85A682A849E029F + + fileRef + 1477F4027E396D01C0C03B7C90E40905 + isa + PBXBuildFile + + F0880F69B4C4AFC0D3243BFBF87D1683 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxTableViewDataSourceType.swift + path + RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift + sourceTree + <group> + + F2579ABC251B120658EE7E04FA5D243A + + fileRef + E406863E65E4620458952E3DB5CBCA68 + isa + PBXBuildFile + + F2910922D371DEA0920A3CE562114822 + + buildActionMask + 2147483647 + files + + 02453D3D02A1A7567016BCE51080E01D + + isa + PBXHeadersBuildPhase + runOnlyForDeploymentPostprocessing + 0 + + F2DCB4B0FF20B99F9A6CE4E70430693F + + fileRef + B25CA66FF8ABAB7F3FDDCDBD038F6B68 + isa + PBXBuildFile + + F33FFD923FC1B164980630EAB3894132 + + baseConfigurationReference + 4520CB2833BB5C1EA31EC7487B5308C5 + buildSettings + + CODE_SIGN_IDENTITY[sdk=iphoneos*] + iPhone Developer + CURRENT_PROJECT_VERSION + 1 + DEBUG_INFORMATION_FORMAT + dwarf-with-dsym + DEFINES_MODULE + YES + DYLIB_COMPATIBILITY_VERSION + 1 + DYLIB_CURRENT_VERSION + 1 + DYLIB_INSTALL_NAME_BASE + @rpath + ENABLE_STRICT_OBJC_MSGSEND + YES + GCC_NO_COMMON_BLOCKS + YES + INFOPLIST_FILE + Target Support Files/Pods-ProtiumTests/Info.plist + INSTALL_PATH + $(LOCAL_LIBRARY_DIR)/Frameworks + IPHONEOS_DEPLOYMENT_TARGET + 9.0 + LD_RUNPATH_SEARCH_PATHS + + $(inherited) + @executable_path/Frameworks + @loader_path/Frameworks + + MACH_O_TYPE + staticlib + MACOSX_DEPLOYMENT_TARGET + 10.10 + MODULEMAP_FILE + Target Support Files/Pods-ProtiumTests/Pods-ProtiumTests.modulemap + MTL_ENABLE_DEBUG_INFO + NO + OTHER_LDFLAGS + + OTHER_LIBTOOLFLAGS + + PODS_ROOT + $(SRCROOT) + PRODUCT_BUNDLE_IDENTIFIER + org.cocoapods.${PRODUCT_NAME:rfc1034identifier} + PRODUCT_NAME + Pods_ProtiumTests + SDKROOT + iphoneos + SKIP_INSTALL + YES + SWIFT_VERSION + 3.0 + TARGETED_DEVICE_FAMILY + 1,2 + VERSIONING_SYSTEM + apple-generic + VERSION_INFO_PREFIX + + + isa + XCBuildConfiguration + name + Release + + F35B4E721DF6AEB801593A06B9867CC0 + + fileRef + C4506C2A1CB80DA888EC917E38A17B36 + isa + PBXBuildFile + + F400AE7E8D81785EE7B3307C4D4F5C2A + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Variable.swift + path + RxSwift/Subjects/Variable.swift + sourceTree + <group> + + F442790CE991A7754C5A6FFFCEAAA9C3 + + containerPortal + D41D8CD98F00B204E9800998ECF8427E + isa + PBXContainerItemProxy + proxyType + 1 + remoteGlobalIDString + 61DE7C52A85DB9EA328A7BF08F9B28A1 + remoteInfo + RxSwift + + F56C0F7D58610E5886976C12B083D342 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.h + name + JASON.h + path + Source/Supporting Files/JASON.h + sourceTree + <group> + + F671D336A41DED031436FD2A9DC62476 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Error.swift + path + RxSwift/Observables/Implementations/Error.swift + sourceTree + <group> + + F693EA75CBD313D75E7BF9C499C269E9 + + fileRef + 0D72171ABB370853B371A14013E4AC7A + isa + PBXBuildFile + + F729648D54812A67574CDE74527EBCC5 + + children + + BE7EC58F85D775B37FAA1845910E3777 + B7A5C9B8E68595D5B14D21D4AE58B0C6 + FFFB24C22ED88AC2A8D2FE07CF4D132A + + isa + PBXGroup + name + iOS + sourceTree + <group> + + F8256B56314777FFBA9DB2DED3FECA70 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ScheduledItem.swift + path + RxSwift/Schedulers/Internal/ScheduledItem.swift + sourceTree + <group> + + F83991435AAFDACDF363C324511B7567 + + fileRef + 1B732A588AF08063716183A539B8D5FC + isa + PBXBuildFile + + F8E990602F644C7B871B336144D9C4F6 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxCollectionViewDelegateProxy.swift + path + RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift + sourceTree + <group> + + F8EB3C3C8B35BA6AA265CB26821D465D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Kingfisher.swift + path + Sources/Kingfisher.swift + sourceTree + <group> + + F8F9C29EFDD33E36265635D3A54225C5 + + fileRef + 9A79400B0690CEC0BF376B959B4C7B74 + isa + PBXBuildFile + + F906D576A00915E90F52B0030FEAA12C + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + RxBlocking.framework + path + RxBlocking.framework + sourceTree + BUILT_PRODUCTS_DIR + + F9439650775231D2F78C555E917BDD62 + + fileRef + 24B0711D45694743CFACB12DA5CDD32D + isa + PBXBuildFile + + F96A3A347B13A8C627E2241C289EBA2F + + children + + E3B3EDE61D0A4998919CCEF24894DF13 + 091461F9A2123AC4274FE71E2CDA3F69 + ECB0B695F6EA4A153C77E994FCD69686 + 9DC1CC4B094524734C47B957FDF8FD88 + 72FAF2A2C6D9EFD7CA5956B9C1E56C29 + FF7F1599B9710DFB9ABF1BB8E590E384 + 975D9E59095650AA28C2E74D1F1A0675 + 7CDDD28BDE05D85FD8E97D3B4A627C07 + 35F13ACCB05044E146B13BCFD98D442F + 98F2F75A1E6B746ED5C0810BA0938F21 + + isa + PBXGroup + name + Pods-ProtiumUITests + path + Target Support Files/Pods-ProtiumUITests + sourceTree + <group> + + F99913BD0EBF168FFF11E182EEF49F95 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + TestSchedulerVirtualTimeConverter.swift + path + RxTests/Schedulers/TestSchedulerVirtualTimeConverter.swift + sourceTree + <group> + + F9CFE1992664AE0C4F34FB7C23F13769 + + fileRef + B1894B5A781F4A8CE2661D2E9E09EDA2 + isa + PBXBuildFile + + FA4AACBBE32FD7404C5464658411D84D + + fileRef + 8ABF8E968DFEA1A9DEF39E6DA2C56761 + isa + PBXBuildFile + + FA583C51C7B56D757466D6F32452BF76 + + children + + B4B6254371287A865CF0832EB06DE6CB + DA3543355A611988BA0192DCE6A83D26 + 56D3F740E3469FE408703A45B57E1B4E + FEA5932D5FEBCA7EDA528501AE376A4D + 1EEA7E8084A096D2D2630495B31FC055 + E5EE3682D8E144AB86F3C587ED86ABBF + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/Kingfisher + sourceTree + <group> + + FA7F8BBBC7E7087ED73CF54CB8086FFE + + children + + F56C0F7D58610E5886976C12B083D342 + 845114B594E213F222279AE506D0A9CF + CF04EEAA2F2DAF98B28FC481D7172F17 + 609606CC0304C34A235AF8AF67088392 + 71CF2C6294538CC5BB2D5E7459671C4A + 4187C92AE10ACBBAC05BB7C37D2199CC + 909F5C99F0C19748867610740BC28D1A + A1A2E256DFB728746355C94D800B8CF2 + + isa + PBXGroup + name + JASON + path + JASON + sourceTree + <group> + + FA8B099AE958FB72F9DAB39B0D74D813 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.plist.xml + path + Pods-ProtiumTests-acknowledgements.plist + sourceTree + <group> + + FC02F13F4C864B0F5041447574AB5543 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + KVORepresentable.swift + path + RxCocoa/Common/KVORepresentable.swift + sourceTree + <group> + + FC124CF9CC629A63996FA5438A99CBC0 + + fileRef + 85A8D690FEF985B22FA0D8E904D798CF + isa + PBXBuildFile + + FCBB9157BBD502DC09033D604AC8BEE8 + + children + + 0892143A4449587AABEAF5099149E128 + 2DD7044B334E0B0EF8F5ED322484233B + 0FE7E2183CFA9372B26D6AAB3552F84A + 7EC1AFEC6E8403CBEC48818B43A598C5 + 37362BADF5A441DC563FA0AC893BB66A + 78248535A169B4D18B95353CA60E3BC8 + + isa + PBXGroup + name + Support Files + path + ../Target Support Files/RxTests + sourceTree + <group> + + FCE8B77130B2399CB446E7E186A1462C + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + ConcurrentDispatchQueueScheduler.swift + path + RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift + sourceTree + <group> + + FD027FD68BD72E6CDACB8075DE52F46B + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + CombineLatest.swift + path + RxSwift/Observables/Implementations/CombineLatest.swift + sourceTree + <group> + + FD6FC2369CB44D3D98C297BA5278F32F + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RetryWhen.swift + path + RxSwift/Observables/Implementations/RetryWhen.swift + sourceTree + <group> + + FE11BF6FEF0B346A2421457315C2FD16 + + fileRef + 6CFC0DD1C64E43055468D1C07AEA4917 + isa + PBXBuildFile + + FE2101ADAC03130EE66F908F4800E89B + + explicitFileType + wrapper.framework + includeInIndex + 0 + isa + PBXFileReference + name + JASON.framework + path + JASON.framework + sourceTree + BUILT_PRODUCTS_DIR + + FE4BBBEEE8D120C6BFF816038A039476 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + Event.swift + path + RxSwift/Event.swift + sourceTree + <group> + + FE91AD7770C23F995689EB9A5E890907 + + fileRef + 87B6320968169C95692DC8723FD43DDE + isa + PBXBuildFile + + FEA5932D5FEBCA7EDA528501AE376A4D + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.c.objc + path + Kingfisher-dummy.m + sourceTree + <group> + + FF49B8637F84907A6476AB6830BDDA2D + + fileRef + B875AF6FD2019F1FDB7A4E7272FDAF1D + isa + PBXBuildFile + + FF7F1599B9710DFB9ABF1BB8E590E384 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + text.script.sh + path + Pods-ProtiumUITests-frameworks.sh + sourceTree + <group> + + FF9DF655086BF165CFBA86B0409810A6 + + fileRef + 77A521AB3B93AFA957128519B082C782 + isa + PBXBuildFile + + FFBD546CB3D4110D355788C3A43E8A51 + + includeInIndex + 1 + isa + PBXFileReference + lastKnownFileType + sourcecode.swift + name + RxCollectionViewDataSourceProxy.swift + path + RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift + sourceTree + <group> + + FFFB24C22ED88AC2A8D2FE07CF4D132A + + isa + PBXFileReference + lastKnownFileType + wrapper.framework + name + XCTest.framework + path + Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/XCTest.framework + sourceTree + DEVELOPER_DIR + + + rootObject + D41D8CD98F00B204E9800998ECF8427E + + diff --git a/Pods/RxBlocking/LICENSE.md b/Pods/RxBlocking/LICENSE.md new file mode 100644 index 0000000..d6765d9 --- /dev/null +++ b/Pods/RxBlocking/LICENSE.md @@ -0,0 +1,9 @@ +**The MIT License** +**Copyright © 2015 Krunoslav Zaher** +**All rights reserved.** + +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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +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. \ No newline at end of file diff --git a/Pods/RxBlocking/README.md b/Pods/RxBlocking/README.md new file mode 100644 index 0000000..5e47efa --- /dev/null +++ b/Pods/RxBlocking/README.md @@ -0,0 +1,198 @@ +Miss Electric Eel 2016 RxSwift: ReactiveX for Swift +====================================== + +[![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux%28experimental%29-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) + +## About Rx + +**:warning: This readme describes RxSwift 3.0 version that requires Swift 3.0.** + +**:warning: If you are looking for Swift 2.3 compatible version, please take a look at RxSwift ~> 2.0 versions and [swift-2.3](https://github.com/ReactiveX/RxSwift/tree/rxswift-2.0) branch.** + +Rx is a [generic abstraction of computation](https://youtu.be/looJcaeboBY) expressed through `Observable` interface. + +This is a Swift version of [Rx](https://github.com/Reactive-Extensions/Rx.NET). + +It tries to port as many concepts from the original version as possible, but some concepts were adapted for more pleasant and performant integration with iOS/OSX environment. + +Cross platform documentation can be found on [ReactiveX.io](http://reactivex.io/). + +Like the original Rx, its intention is to enable easy composition of asynchronous operations and event/data streams. + +KVO observing, async operations and streams are all unified under [abstraction of sequence](Documentation/GettingStarted.md#observables-aka-sequences). This is the reason why Rx is so simple, elegant and powerful. + +## I came here because I want to ... + +###### ... understand + +* [why use rx?](Documentation/Why.md) +* [the basics, getting started with RxSwift](Documentation/GettingStarted.md) +* [units](Documentation/Units.md) - what is `Driver`, `ControlProperty`, and `Variable` ... and why do they exist? +* [testing](Documentation/UnitTests.md) +* [tips and common errors](Documentation/Tips.md) +* [debugging](Documentation/GettingStarted.md#debugging) +* [the math behind Rx](Documentation/MathBehindRx.md) +* [what are hot and cold observable sequences?](Documentation/HotAndColdObservables.md) +* [what does the the public API look like?](Documentation/API.md) + + +###### ... install + +* Integrate RxSwift/RxCocoa with my app. [Installation Guide](#installation) + +###### ... hack around + +* with the example app. [Running Example App](Documentation/ExampleApp.md) +* with operators in playgrounds. [Playgrounds](Documentation/Playgrounds.md) + +###### ... interact + +* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences.
[![Slack channel](http://rxswift-slack.herokuapp.com/badge.svg)](http://slack.rxswift.org) [Join Slack Channel](http://rxswift-slack.herokuapp.com) +* Report a problem using the library. [Open an Issue With Bug Template](ISSUE_TEMPLATE.md) +* Request a new feature. [Open an Issue With Feature Request Template](Documentation/NewFeatureRequestTemplate.md) + + +###### ... compare + +* [with other libraries](Documentation/ComparisonWithOtherLibraries.md). + + +###### ... find compatible + +* libraries from [RxSwiftCommunity](https://github.com/RxSwiftCommunity). +* [Pods using RxSwift](https://cocoapods.org/?q=uses%3Arxswift). + +###### ... see the broader vision + +* Does this exist for Android? [RxJava](https://github.com/ReactiveX/RxJava) +* Where is all of this going, what is the future, what about reactive architectures, how do you design entire apps this way? [Cycle.js](https://github.com/cyclejs/cycle-core) - this is javascript, but [RxJS](https://github.com/Reactive-Extensions/RxJS) is javascript version of Rx. + +## Usage + + + + + + + + + + + + + + + + + + + +
Here's an exampleIn Action
Define search for GitHub repositories ...
+let searchResults = searchBar.rx.text
+    .throttle(0.3, scheduler: MainScheduler.instance)
+    .distinctUntilChanged()
+    .flatMapLatest { query -> Observable<[Repository]> in
+        if query.isEmpty {
+            return .just([])
+        }
+
+        return searchGitHub(query)
+            .catchErrorJustReturn([])
+    }
+    .observeOn(MainScheduler.instance)
... then bind the results to your tableview
+searchResults
+    .bindTo(tableView.rx.items(cellIdentifier: "Cell")) {
+        (index, repository: Repository, cell) in
+        cell.textLabel?.text = repository.name
+        cell.detailTextLabel?.text = repository.url
+    }
+    .addDisposableTo(disposeBag)
+ + +## Requirements + +* Xcode 8.0 +* Swift 3.0 + +## Installation + +Rx doesn't contain any external dependencies. + +These are currently the supported options: + +### Manual + +Open Rx.xcworkspace, choose `RxExample` and hit run. This method will build everything and run the sample app + +### [CocoaPods](https://guides.cocoapods.org/using/using-cocoapods.html) + +``` +# Podfile +use_frameworks! + +target 'YOUR_TARGET_NAME' do + pod 'RxSwift', '~> 3.0.0-beta.2' + pod 'RxCocoa', '~> 3.0.0-beta.2' +end + +# RxTests and RxBlocking make the most sense in the context of unit/integration tests +target 'YOUR_TESTING_TARGET' do + pod 'RxBlocking', '~> 3.0.0-beta.2' + pod 'RxTests', '~> 3.0.0-beta.2' +end +``` + +Replace `YOUR_TARGET_NAME` and then, in the `Podfile` directory, type: + +**:warning: If you want to use CocoaPods with Xcode 8.0 beta and Swift 3.0, you might need to add the following +lines to your podfile: :warning:** + +``` +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['SWIFT_VERSION'] = '3.0' + config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10' + end + end +end +``` + +``` +$ pod install +``` + +### [Carthage](https://github.com/Carthage/Carthage) + +Add this to `Cartfile` + +``` +github "ReactiveX/RxSwift" "3.0.0-beta.2" +``` + +``` +$ carthage update +``` + +### Manually using git submodules + +* Add RxSwift as a submodule + +``` +$ git submodule add git@github.com:ReactiveX/RxSwift.git +``` + +* Drag `Rx.xcodeproj` into Project Navigator +* Go to `Project > Targets > Build Phases > Link Binary With Libraries`, click `+` and select `RxSwift-[Platform]` and `RxCocoa-[Platform]` targets + + +## References + +* [http://reactivex.io/](http://reactivex.io/) +* [Reactive Extensions GitHub (GitHub)](https://github.com/Reactive-Extensions) +* [Erik Meijer (Wikipedia)](http://en.wikipedia.org/wiki/Erik_Meijer_%28computer_scientist%29) +* [Expert to Expert: Brian Beckman and Erik Meijer - Inside the .NET Reactive Framework (Rx) (video)](https://youtu.be/looJcaeboBY) +* [Reactive Programming Overview (Jafar Husain from Netflix)](https://www.youtube.com/watch?v=dwP1TNXE6fc) +* [Subject/Observer is Dual to Iterator (paper)](http://csl.stanford.edu/~christos/pldi2010.fit/meijer.duality.pdf) +* [Rx standard sequence operators visualized (visualization tool)](http://rxmarbles.com/) +* [Haskell](https://www.haskell.org/) diff --git a/Pods/RxBlocking/RxBlocking/BlockingObservable+Operators.swift b/Pods/RxBlocking/RxBlocking/BlockingObservable+Operators.swift new file mode 100644 index 0000000..eb95e81 --- /dev/null +++ b/Pods/RxBlocking/RxBlocking/BlockingObservable+Operators.swift @@ -0,0 +1,253 @@ +// +// BlockingObservable+Operators.swift +// Rx +// +// Created by Krunoslav Zaher on 10/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +extension BlockingObservable { + /** + Blocks current thread until sequence terminates. + + If sequence terminates with error, terminating error will be thrown. + + - returns: All elements of sequence. + */ + public func toArray() throws -> [E] { + var elements: [E] = Array() + + var error: Swift.Error? + + let lock = RunLoopLock(timeout: timeout) + + let d = SingleAssignmentDisposable() + + defer { + d.dispose() + } + + lock.dispatch { + let subscription = self.source.subscribe { e in + if d.isDisposed { + return + } + switch e { + case .next(let element): + elements.append(element) + case .error(let e): + error = e + d.dispose() + lock.stop() + case .completed: + d.dispose() + lock.stop() + } + } + + d.setDisposable(subscription) + } + + try lock.run() + + if let error = error { + throw error + } + + return elements + } +} + +extension BlockingObservable { + /** + Blocks current thread until sequence produces first element. + + If sequence terminates with error before producing first element, terminating error will be thrown. + + - returns: First element of sequence. If sequence is empty `nil` is returned. + */ + public func first() throws -> E? { + var element: E? + + var error: Swift.Error? + + let d = SingleAssignmentDisposable() + + defer { + d.dispose() + } + + let lock = RunLoopLock(timeout: timeout) + + lock.dispatch { + let subscription = self.source.subscribe { e in + if d.isDisposed { + return + } + + switch e { + case .next(let e): + if element == nil { + element = e + } + break + case .error(let e): + error = e + default: + break + } + + d.dispose() + lock.stop() + } + + d.setDisposable(subscription) + } + + try lock.run() + + if let error = error { + throw error + } + + return element + } +} + +extension BlockingObservable { + /** + Blocks current thread until sequence terminates. + + If sequence terminates with error, terminating error will be thrown. + + - returns: Last element in the sequence. If sequence is empty `nil` is returned. + */ + public func last() throws -> E? { + var element: E? + + var error: Swift.Error? + + let d = SingleAssignmentDisposable() + + defer { + d.dispose() + } + + let lock = RunLoopLock(timeout: timeout) + + lock.dispatch { + let subscription = self.source.subscribe { e in + if d.isDisposed { + return + } + switch e { + case .next(let e): + element = e + return + case .error(let e): + error = e + default: + break + } + + d.dispose() + lock.stop() + } + + d.setDisposable(subscription) + } + + try lock.run() + + if let error = error { + throw error + } + + return element + } +} + +extension BlockingObservable { + /** + Blocks current thread until sequence terminates. + + If sequence terminates with error before producing first element, terminating error will be thrown. + + - returns: Returns the only element of an sequence, and reports an error if there is not exactly one element in the observable sequence. + */ + public func single() throws -> E? { + return try single { _ in true } + } + + /** + Blocks current thread until sequence terminates. + + If sequence terminates with error before producing first element, terminating error will be thrown. + + - parameter predicate: A function to test each source element for a condition. + - returns: Returns the only element of an sequence that satisfies the condition in the predicate, and reports an error if there is not exactly one element in the sequence. + */ + public func single(_ predicate: @escaping (E) throws -> Bool) throws -> E? { + var element: E? + + var error: Swift.Error? + + let d = SingleAssignmentDisposable() + + defer { + d.dispose() + } + + let lock = RunLoopLock(timeout: timeout) + + lock.dispatch { + let subscription = self.source.subscribe { e in + if d.isDisposed { + return + } + switch e { + case .next(let e): + do { + if try !predicate(e) { + return + } + if element == nil { + element = e + } else { + throw RxError.moreThanOneElement + } + } catch (let err) { + error = err + d.dispose() + lock.stop() + } + return + case .error(let e): + error = e + case .completed: + if element == nil { + error = RxError.noElements + } + } + + d.dispose() + lock.stop() + } + + d.setDisposable(subscription) + } + + try lock.run() + + if let error = error { + throw error + } + + return element + } +} diff --git a/Pods/RxBlocking/RxBlocking/BlockingObservable.swift b/Pods/RxBlocking/RxBlocking/BlockingObservable.swift new file mode 100644 index 0000000..062ac38 --- /dev/null +++ b/Pods/RxBlocking/RxBlocking/BlockingObservable.swift @@ -0,0 +1,25 @@ +// +// BlockingObservable.swift +// Rx +// +// Created by Krunoslav Zaher on 10/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +/** +`BlockingObservable` is a variety of `Observable` that provides blocking operators. + +It can be useful for testing and demo purposes, but is generally inappropriate for production applications. + +If you think you need to use a `BlockingObservable` this is usually a sign that you should rethink your +design. +*/ +public struct BlockingObservable { + let timeout: RxTimeInterval? + let source: Observable +} diff --git a/Pods/RxBlocking/RxBlocking/ObservableConvertibleType+Blocking.swift b/Pods/RxBlocking/RxBlocking/ObservableConvertibleType+Blocking.swift new file mode 100644 index 0000000..d44bc66 --- /dev/null +++ b/Pods/RxBlocking/RxBlocking/ObservableConvertibleType+Blocking.swift @@ -0,0 +1,25 @@ +// +// ObservableConvertibleType+Blocking.swift +// RxBlocking +// +// Created by Krunoslav Zaher on 7/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +extension ObservableConvertibleType { + /** + Converts an Observable into a `BlockingObservable` (an Observable with blocking operators). + + - parameter timeout: Maximal time interval BlockingObservable can block without throwing `RxError.timeout`. + - returns: `BlockingObservable` version of `self` + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func toBlocking(timeout: RxTimeInterval? = nil) -> BlockingObservable { + return BlockingObservable(timeout: timeout, source: self.asObservable()) + } +} diff --git a/Pods/RxBlocking/RxBlocking/RunLoopLock.swift b/Pods/RxBlocking/RxBlocking/RunLoopLock.swift new file mode 100644 index 0000000..7df595b --- /dev/null +++ b/Pods/RxBlocking/RxBlocking/RunLoopLock.swift @@ -0,0 +1,88 @@ +// +// RunLoopLock.swift +// Rx +// +// Created by Krunoslav Zaher on 11/5/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +typealias AtomicInt = Int32 + +#if os(Linux) + func AtomicIncrement(increment: UnsafeMutablePointer) -> AtomicInt { + increment.memory = increment.memory + 1 + return increment.memory + } + + func AtomicDecrement(increment: UnsafeMutablePointer) -> AtomicInt { + increment.memory = increment.memory - 1 + return increment.memory + } +#else + let AtomicIncrement = OSAtomicIncrement32 + let AtomicDecrement = OSAtomicDecrement32 +#endif + +class RunLoopLock { + let _currentRunLoop: CFRunLoop + + var _calledRun: AtomicInt = 0 + var _calledStop: AtomicInt = 0 + var _timeout: RxTimeInterval? + + init(timeout: RxTimeInterval?) { + _timeout = timeout + _currentRunLoop = CFRunLoopGetCurrent() + } + + func dispatch(_ action: @escaping () -> ()) { + CFRunLoopPerformBlock(_currentRunLoop, CFRunLoopMode.defaultMode.rawValue) { + if CurrentThreadScheduler.isScheduleRequired { + _ = CurrentThreadScheduler.instance.schedule(()) { _ in + action() + return Disposables.create() + } + } + else { + action() + } + } + CFRunLoopWakeUp(_currentRunLoop) + } + + func stop() { + if AtomicIncrement(&_calledStop) != 1 { + return + } + CFRunLoopPerformBlock(_currentRunLoop, CFRunLoopMode.defaultMode.rawValue) { + CFRunLoopStop(self._currentRunLoop) + } + CFRunLoopWakeUp(_currentRunLoop) + } + + func run() throws { + if AtomicIncrement(&_calledRun) != 1 { + fatalError("Run can be only called once") + } + if let timeout = _timeout { + switch CFRunLoopRunInMode(CFRunLoopMode.defaultMode, timeout, false) { + case .finished: + return + case .handledSource: + return + case .stopped: + return + case .timedOut: + throw RxError.timeout + } + } + else { + CFRunLoopRun() + } + } +} diff --git a/Pods/RxCocoa/LICENSE.md b/Pods/RxCocoa/LICENSE.md new file mode 100644 index 0000000..d6765d9 --- /dev/null +++ b/Pods/RxCocoa/LICENSE.md @@ -0,0 +1,9 @@ +**The MIT License** +**Copyright © 2015 Krunoslav Zaher** +**All rights reserved.** + +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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +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. \ No newline at end of file diff --git a/Pods/RxCocoa/README.md b/Pods/RxCocoa/README.md new file mode 100644 index 0000000..5e47efa --- /dev/null +++ b/Pods/RxCocoa/README.md @@ -0,0 +1,198 @@ +Miss Electric Eel 2016 RxSwift: ReactiveX for Swift +====================================== + +[![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux%28experimental%29-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) + +## About Rx + +**:warning: This readme describes RxSwift 3.0 version that requires Swift 3.0.** + +**:warning: If you are looking for Swift 2.3 compatible version, please take a look at RxSwift ~> 2.0 versions and [swift-2.3](https://github.com/ReactiveX/RxSwift/tree/rxswift-2.0) branch.** + +Rx is a [generic abstraction of computation](https://youtu.be/looJcaeboBY) expressed through `Observable` interface. + +This is a Swift version of [Rx](https://github.com/Reactive-Extensions/Rx.NET). + +It tries to port as many concepts from the original version as possible, but some concepts were adapted for more pleasant and performant integration with iOS/OSX environment. + +Cross platform documentation can be found on [ReactiveX.io](http://reactivex.io/). + +Like the original Rx, its intention is to enable easy composition of asynchronous operations and event/data streams. + +KVO observing, async operations and streams are all unified under [abstraction of sequence](Documentation/GettingStarted.md#observables-aka-sequences). This is the reason why Rx is so simple, elegant and powerful. + +## I came here because I want to ... + +###### ... understand + +* [why use rx?](Documentation/Why.md) +* [the basics, getting started with RxSwift](Documentation/GettingStarted.md) +* [units](Documentation/Units.md) - what is `Driver`, `ControlProperty`, and `Variable` ... and why do they exist? +* [testing](Documentation/UnitTests.md) +* [tips and common errors](Documentation/Tips.md) +* [debugging](Documentation/GettingStarted.md#debugging) +* [the math behind Rx](Documentation/MathBehindRx.md) +* [what are hot and cold observable sequences?](Documentation/HotAndColdObservables.md) +* [what does the the public API look like?](Documentation/API.md) + + +###### ... install + +* Integrate RxSwift/RxCocoa with my app. [Installation Guide](#installation) + +###### ... hack around + +* with the example app. [Running Example App](Documentation/ExampleApp.md) +* with operators in playgrounds. [Playgrounds](Documentation/Playgrounds.md) + +###### ... interact + +* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences.
[![Slack channel](http://rxswift-slack.herokuapp.com/badge.svg)](http://slack.rxswift.org) [Join Slack Channel](http://rxswift-slack.herokuapp.com) +* Report a problem using the library. [Open an Issue With Bug Template](ISSUE_TEMPLATE.md) +* Request a new feature. [Open an Issue With Feature Request Template](Documentation/NewFeatureRequestTemplate.md) + + +###### ... compare + +* [with other libraries](Documentation/ComparisonWithOtherLibraries.md). + + +###### ... find compatible + +* libraries from [RxSwiftCommunity](https://github.com/RxSwiftCommunity). +* [Pods using RxSwift](https://cocoapods.org/?q=uses%3Arxswift). + +###### ... see the broader vision + +* Does this exist for Android? [RxJava](https://github.com/ReactiveX/RxJava) +* Where is all of this going, what is the future, what about reactive architectures, how do you design entire apps this way? [Cycle.js](https://github.com/cyclejs/cycle-core) - this is javascript, but [RxJS](https://github.com/Reactive-Extensions/RxJS) is javascript version of Rx. + +## Usage + + + + + + + + + + + + + + + + + + + +
Here's an exampleIn Action
Define search for GitHub repositories ...
+let searchResults = searchBar.rx.text
+    .throttle(0.3, scheduler: MainScheduler.instance)
+    .distinctUntilChanged()
+    .flatMapLatest { query -> Observable<[Repository]> in
+        if query.isEmpty {
+            return .just([])
+        }
+
+        return searchGitHub(query)
+            .catchErrorJustReturn([])
+    }
+    .observeOn(MainScheduler.instance)
... then bind the results to your tableview
+searchResults
+    .bindTo(tableView.rx.items(cellIdentifier: "Cell")) {
+        (index, repository: Repository, cell) in
+        cell.textLabel?.text = repository.name
+        cell.detailTextLabel?.text = repository.url
+    }
+    .addDisposableTo(disposeBag)
+ + +## Requirements + +* Xcode 8.0 +* Swift 3.0 + +## Installation + +Rx doesn't contain any external dependencies. + +These are currently the supported options: + +### Manual + +Open Rx.xcworkspace, choose `RxExample` and hit run. This method will build everything and run the sample app + +### [CocoaPods](https://guides.cocoapods.org/using/using-cocoapods.html) + +``` +# Podfile +use_frameworks! + +target 'YOUR_TARGET_NAME' do + pod 'RxSwift', '~> 3.0.0-beta.2' + pod 'RxCocoa', '~> 3.0.0-beta.2' +end + +# RxTests and RxBlocking make the most sense in the context of unit/integration tests +target 'YOUR_TESTING_TARGET' do + pod 'RxBlocking', '~> 3.0.0-beta.2' + pod 'RxTests', '~> 3.0.0-beta.2' +end +``` + +Replace `YOUR_TARGET_NAME` and then, in the `Podfile` directory, type: + +**:warning: If you want to use CocoaPods with Xcode 8.0 beta and Swift 3.0, you might need to add the following +lines to your podfile: :warning:** + +``` +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['SWIFT_VERSION'] = '3.0' + config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10' + end + end +end +``` + +``` +$ pod install +``` + +### [Carthage](https://github.com/Carthage/Carthage) + +Add this to `Cartfile` + +``` +github "ReactiveX/RxSwift" "3.0.0-beta.2" +``` + +``` +$ carthage update +``` + +### Manually using git submodules + +* Add RxSwift as a submodule + +``` +$ git submodule add git@github.com:ReactiveX/RxSwift.git +``` + +* Drag `Rx.xcodeproj` into Project Navigator +* Go to `Project > Targets > Build Phases > Link Binary With Libraries`, click `+` and select `RxSwift-[Platform]` and `RxCocoa-[Platform]` targets + + +## References + +* [http://reactivex.io/](http://reactivex.io/) +* [Reactive Extensions GitHub (GitHub)](https://github.com/Reactive-Extensions) +* [Erik Meijer (Wikipedia)](http://en.wikipedia.org/wiki/Erik_Meijer_%28computer_scientist%29) +* [Expert to Expert: Brian Beckman and Erik Meijer - Inside the .NET Reactive Framework (Rx) (video)](https://youtu.be/looJcaeboBY) +* [Reactive Programming Overview (Jafar Husain from Netflix)](https://www.youtube.com/watch?v=dwP1TNXE6fc) +* [Subject/Observer is Dual to Iterator (paper)](http://csl.stanford.edu/~christos/pldi2010.fit/meijer.duality.pdf) +* [Rx standard sequence operators visualized (visualization tool)](http://rxmarbles.com/) +* [Haskell](https://www.haskell.org/) diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/ControlEvent.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/ControlEvent.swift new file mode 100644 index 0000000..3202ad1 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/ControlEvent.swift @@ -0,0 +1,86 @@ +// +// ControlEvent.swift +// Rx +// +// Created by Krunoslav Zaher on 8/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +/** +Protocol that enables extension of `ControlEvent`. +*/ +public protocol ControlEventType : ObservableType { + + /** + - returns: `ControlEvent` interface + */ + func asControlEvent() -> ControlEvent +} + +/** + Unit for `Observable`/`ObservableType` that represents event on UI element. + + It's properties are: + + - it never fails + - it won't send any initial value on subscription + - it will `Complete` sequence on control being deallocated + - it never errors out + - it delivers events on `MainScheduler.instance` + + **The implementation of `ControlEvent` will ensure that sequence of events is being subscribed on main scheduler + (`subscribeOn(ConcurrentMainScheduler.instance)` behavior).** + + **It is implementor's responsibility to make sure that that all other properties enumerated above are satisfied.** + + **If they aren't, then using this unit communicates wrong properties and could potentially break someone's code.** + + **In case `events` observable sequence that is being passed into initializer doesn't satisfy all enumerated + properties, please don't use this unit.** +*/ +public struct ControlEvent : ControlEventType { + public typealias E = PropertyType + + let _events: Observable + + /** + Initializes control event with a observable sequence that represents events. + + - parameter events: Observable sequence that represents events. + - returns: Control event created with a observable sequence of events. + */ + public init(events: Ev) where Ev.E == E { + _events = events.subscribeOn(ConcurrentMainScheduler.instance) + } + + /** + Subscribes an observer to control events. + + - parameter observer: Observer to subscribe to events. + - returns: Disposable object that can be used to unsubscribe the observer from receiving control events. + */ + public func subscribe(_ observer: O) -> Disposable where O.E == E { + return _events.subscribe(observer) + } + + /** + - returns: `Observable` interface. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asObservable() -> Observable { + return _events + } + + /** + - returns: `ControlEvent` interface. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asControlEvent() -> ControlEvent { + return self + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/ControlProperty.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/ControlProperty.swift new file mode 100644 index 0000000..bc4e751 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/ControlProperty.swift @@ -0,0 +1,110 @@ +// +// ControlProperty.swift +// Rx +// +// Created by Krunoslav Zaher on 8/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +/** +Protocol that enables extension of `ControlProperty`. +*/ +public protocol ControlPropertyType : ObservableType, ObserverType { + + /** + - returns: `ControlProperty` interface + */ + func asControlProperty() -> ControlProperty +} + +/** + Unit for `Observable`/`ObservableType` that represents property of UI element. + + It's properties are: + + - it never fails + - `shareReplay(1)` behavior + - it's stateful, upon subscription (calling subscribe) last element is immediately replayed if it was produced + - it will `Complete` sequence on control being deallocated + - it never errors out + - it delivers events on `MainScheduler.instance` + + **The implementation of `ControlProperty` will ensure that sequence of values is being subscribed on main scheduler + (`subscribeOn(ConcurrentMainScheduler.instance)` behavior).** + + **It is implementor's responsibility to make sure that that all other properties enumerated above are satisfied.** + + **If they aren't, then using this unit communicates wrong properties and could potentially break someone's code.** + + **In case `values` observable sequence that is being passed into initializer doesn't satisfy all enumerated + properties, please don't use this unit.** +*/ +public struct ControlProperty : ControlPropertyType { + public typealias E = PropertyType + + let _values: Observable + let _valueSink: AnyObserver + + /** + Initializes control property with a observable sequence that represents property values and observer that enables + binding values to property. + + - parameter values: Observable sequence that represents property values. + - parameter valueSink: Observer that enables binding values to control property. + - returns: Control property created with a observable sequence of values and an observer that enables binding values + to property. + */ + public init(values: V, valueSink: S) where E == V.E, E == S.E { + _values = values.subscribeOn(ConcurrentMainScheduler.instance) + _valueSink = valueSink.asObserver() + } + + /** + Subscribes an observer to control property values. + + - parameter observer: Observer to subscribe to property values. + - returns: Disposable object that can be used to unsubscribe the observer from receiving control property values. + */ + public func subscribe(_ observer: O) -> Disposable where O.E == E { + return _values.subscribe(observer) + } + + /** + - returns: `Observable` interface. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asObservable() -> Observable { + return _values + } + + /** + - returns: `ControlProperty` interface. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asControlProperty() -> ControlProperty { + return self + } + + /** + Binds event to user interface. + + - In case next element is received, it is being set to control value. + - In case error is received, DEBUG buids raise fatal error, RELEASE builds log event to standard output. + - In case sequence completes, nothing happens. + */ + public func on(_ event: Event) { + switch event { + case .error(let error): + bindingErrorToInterface(error) + case .next: + _valueSink.on(event) + case .completed: + _valueSink.on(event) + } + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ControlEvent+Driver.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ControlEvent+Driver.swift new file mode 100644 index 0000000..61a25c9 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ControlEvent+Driver.swift @@ -0,0 +1,30 @@ +// +// ControlEvent+Driver.swift +// Rx +// +// Created by Krunoslav Zaher on 9/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +extension ControlEvent { + /** + Converts `ControlEvent` to `Driver` unit. + + `ControlEvent` already can't fail, so no special case needs to be handled. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asDriver() -> Driver { + return self.asDriver { (error) -> Driver in + #if DEBUG + rxFatalError("Somehow driver received error from a source that shouldn't fail.") + #else + return Driver.empty() + #endif + } + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ControlProperty+Driver.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ControlProperty+Driver.swift new file mode 100644 index 0000000..c752156 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ControlProperty+Driver.swift @@ -0,0 +1,30 @@ +// +// ControlProperty+Driver.swift +// Rx +// +// Created by Krunoslav Zaher on 9/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +extension ControlProperty { + /** + Converts `ControlProperty` to `Driver` unit. + + `ControlProperty` already can't fail, so no special case needs to be handled. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asDriver() -> Driver { + return self.asDriver { (error) -> Driver in + #if DEBUG + rxFatalError("Somehow driver received error from a source that shouldn't fail.") + #else + return Driver.empty() + #endif + } + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift new file mode 100644 index 0000000..ade2c49 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift @@ -0,0 +1,116 @@ +// +// Driver+Subscription.swift +// Rx +// +// Created by Krunoslav Zaher on 9/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +private let driverErrorMessage = "`drive*` family of methods can be only called from `MainThread`.\n" + +"This is required to ensure that the last replayed `Driver` element is delivered on `MainThread`.\n" + +// This would ideally be Driver, but unfortunatelly Driver can't be extended in Swift 3.0 +extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingStrategy { + /** + Creates new subscription and sends elements to observer. + This method can be only called from `MainThread`. + + In this form it's equivalent to `subscribe` method, but it communicates intent better. + + - parameter observer: Observer that receives events. + - returns: Disposable object that can be used to unsubscribe the observer from the subject. + */ + // @warn_unused_result(message:"http://git.io/rxs.ud") + public func drive(_ observer: O) -> Disposable where O.E == E { + MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + return self.asSharedSequence().asObservable().subscribe(observer) + } + + /** + Creates new subscription and sends elements to variable. + This method can be only called from `MainThread`. + + - parameter variable: Target variable for sequence elements. + - returns: Disposable object that can be used to unsubscribe the observer from the variable. + */ + // @warn_unused_result(message:"http://git.io/rxs.ud") + public func drive(_ variable: Variable) -> Disposable { + MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + return drive(onNext: { e in + variable.value = e + }) + } + + /** + Subscribes to observable sequence using custom binder function. + This method can be only called from `MainThread`. + + - parameter with: Function used to bind elements from `self`. + - returns: Object representing subscription. + */ + // @warn_unused_result(message:"http://git.io/rxs.ud") + public func drive(_ transformation: (Observable) -> R) -> R { + MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + return transformation(self.asObservable()) + } + + /** + Subscribes to observable sequence using custom binder function and final parameter passed to binder function + after `self` is passed. + + public func drive(with: Self -> R1 -> R2, curriedArgument: R1) -> R2 { + return with(self)(curriedArgument) + } + + This method can be only called from `MainThread`. + + - parameter with: Function used to bind elements from `self`. + - parameter curriedArgument: Final argument passed to `binder` to finish binding process. + - returns: Object representing subscription. + */ + // @warn_unused_result(message:"http://git.io/rxs.ud") + public func drive(_ with: (Observable) -> (R1) -> R2, curriedArgument: R1) -> R2 { + MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + return with(self.asObservable())(curriedArgument) + } + + /** + Subscribes an element handler, a completion handler and disposed handler to an observable sequence. + This method can be only called from `MainThread`. + + Error callback is not exposed because `Driver` can't error out. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + gracefully completed, errored, or if the generation is cancelled by disposing subscription) + - parameter onDisposed: Action to invoke upon any type of termination of sequence (if the sequence has + gracefully completed, errored, or if the generation is cancelled by disposing subscription) + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.ud") + public func drive(onNext: ((E) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil) -> Disposable { + MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + return self.asObservable().subscribe(onNext: onNext, onCompleted: onCompleted, onDisposed: onDisposed) + } + + /** + Subscribes an element handler to an observable sequence. + This method can be only called from `MainThread`. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.ud") + @available(*, deprecated, renamed: "drive(onNext:)") + public func driveNext(_ onNext: @escaping (E) -> Void) -> Disposable { + MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) + return self.asObservable().subscribe(onNext: onNext) + } +} + + diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Driver.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Driver.swift new file mode 100644 index 0000000..b5ddc5c --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Driver.swift @@ -0,0 +1,83 @@ +// +// Driver.swift +// Rx +// +// Created by Krunoslav Zaher on 9/26/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + + +/** + Unit that represents observable sequence with following properties: + + - it never fails + - it delivers events on `MainScheduler.instance` + - `shareReplayLatestWhileConnected()` behavior + - all observers share sequence computation resources + - it's stateful, upon subscription (calling subscribe) last element is immediatelly replayed if it was produced + - computation of elements is reference counted with respect to the number of observers + - if there are no subscribers, it will release sequence computation resources + + `Driver` can be considered a builder pattern for observable sequences that drive the application. + + If observable sequence has produced at least one element, after new subscription is made last produced element will be + immediately replayed on the same thread on which the subscription was made. + + When using `drive*`, `subscribe*` and `bind*` family of methods, they should always be called from main thread. + + If `drive*`, `subscribe*` and `bind*` are called from background thread, it is possible that initial replay + will happen on background thread, and subsequent events will arrive on main thread. + + To find out more about units and how to use them, please visit `Documentation/Units.md`. + */ +public typealias Driver = SharedSequence + +public struct DriverSharingStrategy: SharingStrategyProtocol { + public static var scheduler: SchedulerType { return driverObserveOnScheduler } + public static func share(_ source: Observable) -> Observable { + return source.shareReplayLatestWhileConnected() + } +} + +extension SharedSequenceConvertibleType where SharingStrategy == DriverSharingStrategy { + /** + Adds `asDriver` to `SharingSequence` with `DriverSharingStrategy`. + */ + public func asDriver() -> Driver { + return self.asSharedSequence() + } +} + +/** + This method can be used in unit tests to ensure that driver is using mock schedulers instead of + main schedulers. + + **This shouldn't be used in normal release builds.** +*/ +public func driveOnScheduler(_ scheduler: SchedulerType, action: () -> ()) { + let originalObserveOnScheduler = driverObserveOnScheduler + driverObserveOnScheduler = scheduler + + action() + + // If you remove this line , compiler buggy optimizations will change behavior of this code + _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(driverObserveOnScheduler) + // Scary, I know + + driverObserveOnScheduler = originalObserveOnScheduler +} + +func _forceCompilerToStopDoingInsaneOptimizationsThatBreakCode(_ scheduler: SchedulerType) { + let a: Int32 = 1 + let b = 314 + Int32(arc4random() & 1) + if a == b { + print(scheduler) + } +} + +fileprivate var driverObserveOnScheduler: SchedulerType = MainScheduler.instance diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift new file mode 100644 index 0000000..a4edb37 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift @@ -0,0 +1,63 @@ +// +// ObservableConvertibleType+Driver.swift +// Rx +// +// Created by Krunoslav Zaher on 9/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +extension ObservableConvertibleType { + /** + Converts anything convertible to `Observable` to `Driver` unit. + + - parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence. + - returns: Driving observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asDriver(onErrorJustReturn: E) -> Driver { + let source = self + .asObservable() + .observeOn(DriverSharingStrategy.scheduler) + .catchErrorJustReturn(onErrorJustReturn) + return Driver(source) + } + + /** + Converts anything convertible to `Observable` to `Driver` unit. + + - parameter onErrorDriveWith: Driver that continues to drive the sequence in case of error. + - returns: Driving observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asDriver(onErrorDriveWith: Driver) -> Driver { + let source = self + .asObservable() + .observeOn(DriverSharingStrategy.scheduler) + .catchError { _ in + onErrorDriveWith.asObservable() + } + return Driver(source) + } + + /** + Converts anything convertible to `Observable` to `Driver` unit. + + - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error. + - returns: Driving observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asDriver(onErrorRecover: @escaping (_ error: Swift.Error) -> Driver) -> Driver { + let source = self + .asObservable() + .observeOn(DriverSharingStrategy.scheduler) + .catchError { error in + onErrorRecover(error).asObservable() + } + return Driver(source) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Variable+Driver.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Variable+Driver.swift new file mode 100644 index 0000000..e8d7ac5 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/Driver/Variable+Driver.swift @@ -0,0 +1,26 @@ +// +// Variable+Driver.swift +// Rx +// +// Created by Krunoslav Zaher on 12/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +extension Variable { + /** + Converts `Variable` to `Driver` unit. + + - returns: Driving observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asDriver() -> Driver { + let source = self.asObservable() + .observeOn(DriverSharingStrategy.scheduler) + return Driver(source) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/ObservableConvertibleType+SharedSequence.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/ObservableConvertibleType+SharedSequence.swift new file mode 100644 index 0000000..21b41e1 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/ObservableConvertibleType+SharedSequence.swift @@ -0,0 +1,63 @@ +// +// ObservableConvertibleType+SharedSequence.swift +// Rx +// +// Created by Krunoslav Zaher on 9/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +extension ObservableConvertibleType { + /** + Converts anything convertible to `Observable` to `SharedSequence` unit. + + - parameter onErrorJustReturn: Element to return in case of error and after that complete the sequence. + - returns: Driving observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asSharedSequence(sharingStrategy: S.Type = S.self, onErrorJustReturn: E) -> SharedSequence { + let source = self + .asObservable() + .observeOn(S.scheduler) + .catchErrorJustReturn(onErrorJustReturn) + return SharedSequence(source) + } + + /** + Converts anything convertible to `Observable` to `SharedSequence` unit. + + - parameter onErrorDriveWith: SharedSequence that provides elements of the sequence in case of error. + - returns: Driving observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asSharedSequence(sharingStrategy: S.Type = S.self, onErrorDriveWith: SharedSequence) -> SharedSequence { + let source = self + .asObservable() + .observeOn(S.scheduler) + .catchError { _ in + onErrorDriveWith.asObservable() + } + return SharedSequence(source) + } + + /** + Converts anything convertible to `Observable` to `SharedSequence` unit. + + - parameter onErrorRecover: Calculates driver that continues to drive the sequence in case of error. + - returns: Driving observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asSharedSequence(sharingStrategy: S.Type = S.self, onErrorRecover: @escaping (_ error: Swift.Error) -> SharedSequence) -> SharedSequence { + let source = self + .asObservable() + .observeOn(S.scheduler) + .catchError { error in + onErrorRecover(error).asObservable() + } + return SharedSequence(source) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators+arity.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators+arity.swift new file mode 100644 index 0000000..7800a9a --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators+arity.swift @@ -0,0 +1,365 @@ +// This file is autogenerated. Take a look at `Preprocessor` target in RxSwift project +// +// SharedSequence+Operators+arity.swift +// Rx +// +// Created by Krunoslav Zaher on 10/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + + + +// 2 + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, resultSelector: @escaping (O1.E, O2.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy { + let source = Observable.zip( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, resultSelector: @escaping (O1.E, O2.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy { + let source = Observable.combineLatest( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + + + +// 3 + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, resultSelector: @escaping (O1.E, O2.E, O3.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy { + let source = Observable.zip( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, resultSelector: @escaping (O1.E, O2.E, O3.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy { + let source = Observable.combineLatest( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + + + +// 4 + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy { + let source = Observable.zip( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy { + let source = Observable.combineLatest( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + + + +// 5 + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy, + O1.SharingStrategy == O5.SharingStrategy { + let source = Observable.zip( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), source5.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy, + O1.SharingStrategy == O5.SharingStrategy { + let source = Observable.combineLatest( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), source5.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + + + +// 6 + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy, + O1.SharingStrategy == O5.SharingStrategy, + O1.SharingStrategy == O6.SharingStrategy { + let source = Observable.zip( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), source5.asSharedSequence().asObservable(), source6.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy, + O1.SharingStrategy == O5.SharingStrategy, + O1.SharingStrategy == O6.SharingStrategy { + let source = Observable.combineLatest( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), source5.asSharedSequence().asObservable(), source6.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + + + +// 7 + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy, + O1.SharingStrategy == O5.SharingStrategy, + O1.SharingStrategy == O6.SharingStrategy, + O1.SharingStrategy == O7.SharingStrategy { + let source = Observable.zip( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), source5.asSharedSequence().asObservable(), source6.asSharedSequence().asObservable(), source7.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy, + O1.SharingStrategy == O5.SharingStrategy, + O1.SharingStrategy == O6.SharingStrategy, + O1.SharingStrategy == O7.SharingStrategy { + let source = Observable.combineLatest( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), source5.asSharedSequence().asObservable(), source6.asSharedSequence().asObservable(), source7.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + + + +// 8 + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy, + O1.SharingStrategy == O5.SharingStrategy, + O1.SharingStrategy == O6.SharingStrategy, + O1.SharingStrategy == O7.SharingStrategy, + O1.SharingStrategy == O8.SharingStrategy { + let source = Observable.zip( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), source5.asSharedSequence().asObservable(), source6.asSharedSequence().asObservable(), source7.asSharedSequence().asObservable(), source8.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E) + -> SharedSequence where O1.SharingStrategy == O2.SharingStrategy, + O1.SharingStrategy == O3.SharingStrategy, + O1.SharingStrategy == O4.SharingStrategy, + O1.SharingStrategy == O5.SharingStrategy, + O1.SharingStrategy == O6.SharingStrategy, + O1.SharingStrategy == O7.SharingStrategy, + O1.SharingStrategy == O8.SharingStrategy { + let source = Observable.combineLatest( + source1.asSharedSequence().asObservable(), source2.asSharedSequence().asObservable(), source3.asSharedSequence().asObservable(), source4.asSharedSequence().asObservable(), source5.asSharedSequence().asObservable(), source6.asSharedSequence().asObservable(), source7.asSharedSequence().asObservable(), source8.asSharedSequence().asObservable(), + resultSelector: resultSelector + ) + + return SharedSequence(source) + } +} + + diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators.swift new file mode 100644 index 0000000..a858e6d --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence+Operators.swift @@ -0,0 +1,579 @@ +// +// SharedSequence+Operators.swift +// Rx +// +// Created by Krunoslav Zaher on 9/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +// MARK: map +extension SharedSequenceConvertibleType { + + /** + Projects each element of an observable sequence into a new form. + + - parameter selector: A transform function to apply to each source element. + - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func map(_ selector: @escaping (E) -> R) -> SharedSequence { + let source = self + .asObservable() + .map(selector) + return SharedSequence(source) + } +} + +// MARK: filter +extension SharedSequenceConvertibleType { + /** + Filters the elements of an observable sequence based on a predicate. + + - parameter predicate: A function to test each source element for a condition. + - returns: An observable sequence that contains elements from the input sequence that satisfy the condition. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func filter(_ predicate: @escaping (E) -> Bool) -> SharedSequence { + let source = self + .asObservable() + .filter(predicate) + return SharedSequence(source) + } +} + +// MARK: switchLatest +extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType, E.SharingStrategy == SharingStrategy { + + /** + Transforms an observable sequence of observable sequences into an observable sequence + producing values only from the most recent observable sequence. + + Each time a new inner observable sequence is received, unsubscribe from the + previous inner observable sequence. + + - returns: The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func switchLatest() -> SharedSequence { + let source: Observable = self + .asObservable() + .map { $0.asSharedSequence() } + .switchLatest() + return SharedSequence(source) + } +} + +// MARK: flatMapLatest +extension SharedSequenceConvertibleType { + /** + Projects each element of an observable sequence into a new sequence of observable sequences and then + transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + + It is a combination of `map` + `switchLatest` operator + + - parameter selector: A transform function to apply to each element. + - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source producing an + Observable of Observable sequences and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func flatMapLatest(_ selector: @escaping (E) -> SharedSequence) + -> SharedSequence { + let source: Observable = self + .asObservable() + .flatMapLatest(selector) + return SharedSequence(source) + } +} + +// MARK: flatMapFirst +extension SharedSequenceConvertibleType { + + /** + Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + If element is received while there is some projected observable sequence being merged it will simply be ignored. + + - parameter selector: A transform function to apply to element that was observed while no observable is executing in parallel. + - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence that was received while no other sequence was being calculated. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func flatMapFirst(_ selector: @escaping (E) -> SharedSequence) + -> SharedSequence { + let source: Observable = self + .asObservable() + .flatMapFirst(selector) + return SharedSequence(source) + } +} + +// MARK: doOn +extension SharedSequenceConvertibleType { + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter eventHandler: Action to invoke for each event in the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") + public func doOn(_ eventHandler: @escaping (Event) -> Void) + -> SharedSequence { + let source = self.asObservable() + .doOn(eventHandler) + + return SharedSequence(source) + } + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. This callback will never be invoked since driver can't error out. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") + public func doOn(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil) + -> SharedSequence { + let source = self.asObservable() + .doOn(onNext: onNext, onError: onError, onCompleted: onCompleted) + + return SharedSequence(source) + } + + /** + Invokes an action for each Next event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onNext:)") + public func doOnNext(_ onNext: @escaping (E) -> Void) + -> SharedSequence { + return self.do(onNext: onNext) + } + + /** + Invokes an action for the Completed event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onCompleted:)") + public func doOnCompleted(_ onCompleted: @escaping () -> Void) + -> SharedSequence { + return self.do(onCompleted: onCompleted) + } + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. This callback will never be invoked since driver can't error out. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - parameter onSubscribe: Action to invoke before subscribing to source observable sequence. + - parameter onDispose: Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func `do`(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onSubscribe: (() -> ())? = nil, onDispose: (() -> ())? = nil) + -> SharedSequence { + let source = self.asObservable() + .do(onNext: onNext, onError: onError, onCompleted: onCompleted, onSubscribe: onSubscribe, onDispose: onDispose) + + return SharedSequence(source) + } +} + +// MARK: debug +extension SharedSequenceConvertibleType { + + /** + Prints received events for all observers on standard output. + + - parameter identifier: Identifier that is printed together with event description to standard output. + - returns: An observable sequence whose events are printed to standard output. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func debug(_ identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) -> SharedSequence { + let source = self.asObservable() + .debug(identifier, file: file, line: line, function: function) + return SharedSequence(source) + } +} + +// MARK: distinctUntilChanged +extension SharedSequenceConvertibleType where E: Equatable { + + /** + Returns an observable sequence that contains only distinct contiguous elements according to equality operator. + + - returns: An observable sequence only containing the distinct contiguous elements, based on equality operator, from the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func distinctUntilChanged() + -> SharedSequence { + let source = self.asObservable() + .distinctUntilChanged({ $0 }, comparer: { ($0 == $1) }) + + return SharedSequence(source) + } +} + +extension SharedSequenceConvertibleType { + + /** + Returns an observable sequence that contains only distinct contiguous elements according to the `keySelector`. + + - parameter keySelector: A function to compute the comparison key for each element. + - returns: An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func distinctUntilChanged(_ keySelector: @escaping (E) -> K) -> SharedSequence { + let source = self.asObservable() + .distinctUntilChanged(keySelector, comparer: { $0 == $1 }) + return SharedSequence(source) + } + + /** + Returns an observable sequence that contains only distinct contiguous elements according to the `comparer`. + + - parameter comparer: Equality comparer for computed key values. + - returns: An observable sequence only containing the distinct contiguous elements, based on `comparer`, from the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func distinctUntilChanged(_ comparer: @escaping (E, E) -> Bool) -> SharedSequence { + let source = self.asObservable() + .distinctUntilChanged({ $0 }, comparer: comparer) + return SharedSequence(source) + } + + /** + Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer. + + - parameter keySelector: A function to compute the comparison key for each element. + - parameter comparer: Equality comparer for computed key values. + - returns: An observable sequence only containing the distinct contiguous elements, based on a computed key value and the comparer, from the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func distinctUntilChanged(_ keySelector: @escaping (E) -> K, comparer: @escaping (K, K) -> Bool) -> SharedSequence { + let source = self.asObservable() + .distinctUntilChanged(keySelector, comparer: comparer) + return SharedSequence(source) + } +} + + +// MARK: flatMap +extension SharedSequenceConvertibleType { + + /** + Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + + - parameter selector: A transform function to apply to each element. + - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func flatMap(_ selector: @escaping (E) -> SharedSequence) -> SharedSequence { + let source = self.asObservable() + .flatMap(selector) + + return SharedSequence(source) + } +} + +// MARK: merge +extension SharedSequenceConvertibleType where E : SharedSequenceConvertibleType, E.SharingStrategy == SharingStrategy { + + /** + Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence. + + - parameter maxConcurrent: Maximum number of inner observable sequences being subscribed to concurrently. + - returns: The observable sequence that merges the elements of the observable sequences. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func merge() -> SharedSequence { + let source = self.asObservable() + .map { $0.asSharedSequence() } + .merge() + return SharedSequence(source) + } + + /** + Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences. + + - returns: The observable sequence that merges the elements of the inner sequences. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func merge(maxConcurrent: Int) + -> SharedSequence { + let source = self.asObservable() + .map { $0.asSharedSequence() } + .merge(maxConcurrent: maxConcurrent) + return SharedSequence(source) + } +} + +// MARK: throttle +extension SharedSequenceConvertibleType { + + /** + Returns an Observable that emits the first and the latest item emitted by the source Observable during sequential time windows of a specified duration. + + This operator makes sure that no two elements are emitted in less then dueTime. + + - seealso: [debounce operator on reactivex.io](http://reactivex.io/documentation/operators/debounce.html) + + - parameter dueTime: Throttling duration for each element. + - parameter latest: Should latest element received in a dueTime wide time window since last element emission be emitted. + - returns: The throttled sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func throttle(_ dueTime: RxTimeInterval) + -> SharedSequence { + let source = self.asObservable() + .throttle(dueTime, scheduler: SharingStrategy.scheduler) + + return SharedSequence(source) + } + + /** + Ignores elements from an observable sequence which are followed by another element within a specified relative time duration, using the specified scheduler to run throttling timers. + + - parameter dueTime: Throttling duration for each element. + - returns: The throttled sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func debounce(_ dueTime: RxTimeInterval) + -> SharedSequence { + let source = self.asObservable() + .debounce(dueTime, scheduler: SharingStrategy.scheduler) + + return SharedSequence(source) + } +} + +// MARK: scan +extension SharedSequenceConvertibleType { + /** + Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value. + + For aggregation behavior with no intermediate results, see `reduce`. + + - parameter seed: The initial accumulator value. + - parameter accumulator: An accumulator function to be invoked on each element. + - returns: An observable sequence containing the accumulated values. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func scan(_ seed: A, accumulator: @escaping (A, E) -> A) + -> SharedSequence { + let source = self.asObservable() + .scan(seed, accumulator: accumulator) + return SharedSequence(source) + } +} + +// MARK: concat + +extension SharedSequence { + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func concat(_ sequence: S) -> SharedSequence + where S.Iterator.Element == SharedSequence { + let source = Observable.concat(sequence.lazy.map { $0.asObservable() }) + return SharedSequence(source) + } + + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func concat(_ collection: C) -> SharedSequence + where C.Iterator.Element == SharedSequence { + let source = Observable.concat(collection.map { $0.asObservable() }) + return SharedSequence(source) + } +} + +extension Sequence where Iterator.Element : SharedSequenceConvertibleType { + + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "SharingSequence.concat()") + public func concat() + -> SharedSequence { + let source = self.lazy.map { $0.asSharedSequence().asObservable() }.concat() + return SharedSequence(source) + } +} + +extension Collection where Iterator.Element : SharedSequenceConvertibleType { + + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "SharingSequence.concat()") + public func concat() + -> SharedSequence { + let source = self.map { $0.asSharedSequence().asObservable() }.concat() + return SharedSequence(source) + } +} + +// MARK: zip + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + public static func zip(_ collection: C, _ resultSelector: @escaping ([Element]) throws -> R) -> SharedSequence + where C.Iterator.Element == SharedSequence { + let source = Observable.zip(collection.map { $0.asSharedSequence().asObservable() }, resultSelector) + return SharedSequence(source) + } +} + +extension Collection where Iterator.Element : SharedSequenceConvertibleType { + + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "SharedSequence.zip()") + public func zip(_ resultSelector: @escaping ([Generator.Element.E]) throws -> R) -> SharedSequence { + let source = self.map { $0.asSharedSequence().asObservable() }.zip(resultSelector) + return SharedSequence(source) + } +} + +// MARK: combineLatest + +extension SharedSequence { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest(_ collection: C, _ resultSelector: @escaping ([Element]) throws -> R) -> SharedSequence + where C.Iterator.Element == SharedSequence { + let source = Observable.combineLatest(collection.map { $0.asObservable() }, resultSelector) + return SharedSequence(source) + } +} + +extension Collection where Iterator.Element : SharedSequenceConvertibleType { + + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "SharingSequence.combineLatest()") + public func combineLatest(_ resultSelector: @escaping ([Generator.Element.E]) throws -> R) -> SharedSequence { + let source = self.map { $0.asSharedSequence().asObservable() }.combineLatest(resultSelector) + return SharedSequence(source) + } +} + +// MARK: withLatestFrom +extension SharedSequenceConvertibleType { + + /** + Merges two observable sequences into one observable sequence by combining each element from self with the latest element from the second source, if any. + + - parameter second: Second observable source. + - parameter resultSelector: Function to invoke for each element from the self combined with the latest element from the second source, if any. + - returns: An observable sequence containing the result of combining each element of the self with the latest element from the second source, if any, using the specified result selector function. + */ + public func withLatestFrom(_ second: SecondO, resultSelector: @escaping (E, SecondO.E) -> ResultType) -> SharedSequence where SecondO.SharingStrategy == SecondO.SharingStrategy { + let source = self.asObservable() + .withLatestFrom(second.asSharedSequence(), resultSelector: resultSelector) + + return SharedSequence(source) + } + + /** + Merges two observable sequences into one observable sequence by using latest element from the second sequence every time when `self` emitts an element. + + - parameter second: Second observable source. + - returns: An observable sequence containing the result of combining each element of the self with the latest element from the second source, if any, using the specified result selector function. + */ + public func withLatestFrom(_ second: SecondO) -> SharedSequence { + let source = self.asObservable() + .withLatestFrom(second.asSharedSequence()) + + return SharedSequence(source) + } +} + +// MARK: skip +extension SharedSequenceConvertibleType { + + /** + Bypasses a specified number of elements in an observable sequence and then returns the remaining elements. + + - seealso: [skip operator on reactivex.io](http://reactivex.io/documentation/operators/skip.html) + + - parameter count: The number of elements to skip before returning the remaining elements. + - returns: An observable sequence that contains the elements that occur after the specified index in the input sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func skip(_ count: Int) + -> SharedSequence { + let source = self.asObservable() + .skip(count) + return SharedSequence(source) + } +} + +// MARK: startWith +extension SharedSequenceConvertibleType { + + /** + Prepends a value to an observable sequence. + + - seealso: [startWith operator on reactivex.io](http://reactivex.io/documentation/operators/startwith.html) + + - parameter element: Element to prepend to the specified sequence. + - returns: The source sequence prepended with the specified values. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func startWith(_ element: E) + -> SharedSequence { + let source = self.asObservable() + .startWith(element) + + return SharedSequence(source) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence.swift new file mode 100644 index 0000000..646d620 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/SharedSequence.swift @@ -0,0 +1,202 @@ +// +// SharedSequence.swift +// Rx +// +// Created by Krunoslav Zaher on 8/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +/** + Unit that represents observable sequence that shares computation resources with following properties: + + - it never fails + - it delivers events on `SharingStrategy.scheduler` + - sharing strategy is customizable using `SharingStrategy.share` behavior + + `SharedSequence` can be considered a builder pattern for observable sequences that share computation resources. + + To find out more about units and how to use them, please visit `Documentation/Units.md`. +*/ +public struct SharedSequence : SharedSequenceConvertibleType { + public typealias E = Element + public typealias SharingStrategy = S + + let _source: Observable + + init(_ source: Observable) { + self._source = S.share(source) + } + + init(raw: Observable) { + self._source = raw + } + + #if EXPANDABLE_SHARED_SEQUENCE + /** + This method is extension hook in case this unit needs to extended from outside the library. + + By defining `EXPANDABLE_SHARED_SEQUENCE` one agrees that it's up to him to ensure shared sequence + properties are preserved after extension. + */ + public static func createUnsafe(source: O) -> SharedSequence { + return SharedSequence(raw: source.asObservable()) + } + #endif + + /** + - returns: Built observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asObservable() -> Observable { + return _source + } + + /** + - returns: `self` + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asSharedSequence() -> SharedSequence { + return self + } +} + +/** + Different `SharedSequence` sharing strategies must conform to this protocol. + */ +public protocol SharingStrategyProtocol { + /** + Scheduled on which all sequence events will be delivered. + */ + static var scheduler: SchedulerType { get } + + /** + Computation resources sharing strategy for multiple sequence observers. + + E.g. One can choose `shareReplayWhenConnected`, `shareReplay` or `share` + as sequence event sharing strategies, but also do something more exotic, like + implementing promises or lazy loading chains. + */ + static func share(_ source: Observable) -> Observable +} + +/** +A type that can be converted to `SharedSequence`. +*/ +public protocol SharedSequenceConvertibleType : ObservableConvertibleType { + associatedtype SharingStrategy: SharingStrategyProtocol + + /** + Converts self to `SharedSequence`. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + func asSharedSequence() -> SharedSequence +} + +extension SharedSequenceConvertibleType { + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asObservable() -> Observable { + return asSharedSequence().asObservable() + } +} + + +extension SharedSequence { + + /** + Returns an empty observable sequence, using the specified scheduler to send out the single `Completed` message. + + - returns: An observable sequence with no elements. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func empty() -> SharedSequence { + return SharedSequence(Observable.empty().subscribeOn(S.scheduler)) + } + + /** + Returns a non-terminating observable sequence, which can be used to denote an infinite duration. + + - returns: An observable sequence whose observers will never get called. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func never() -> SharedSequence { + return SharedSequence(Observable.never().subscribeOn(S.scheduler)) + } + + /** + Returns an observable sequence that contains a single element. + + - parameter element: Single element in the resulting observable sequence. + - returns: An observable sequence containing the single specified element. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func just(_ element: E) -> SharedSequence { + return SharedSequence(Observable.just(element).subscribeOn(S.scheduler)) + } + + /** + Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. + + - parameter observableFactory: Observable factory function to invoke for each observer that subscribes to the resulting sequence. + - returns: An observable sequence whose observers trigger an invocation of the given observable factory function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func deferred(_ observableFactory: @escaping () -> SharedSequence) + -> SharedSequence { + return SharedSequence(Observable.deferred { observableFactory().asObservable() }) + } + + /** + This method creates a new Observable instance with a variable number of elements. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - parameter elements: Elements to generate. + - returns: The observable sequence whose elements are pulled from the given arguments. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func of(_ elements: E ...) -> SharedSequence { + let source = Observable.from(elements, scheduler: S.scheduler) + return SharedSequence(raw: source) + } +} + +extension SharedSequence where Element : SignedInteger { + /** + Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages. + + - seealso: [interval operator on reactivex.io](http://reactivex.io/documentation/operators/interval.html) + + - parameter period: Period for producing the values in the resulting sequence. + - returns: An observable sequence that produces a value after each period. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func interval(_ period: RxTimeInterval) + -> SharedSequence { + return SharedSequence(Observable.interval(period, scheduler: S.scheduler)) + } +} + +// MARK: timer + +extension SharedSequence where Element: SignedInteger { + /** + Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed, using the specified scheduler to run timers. + + - seealso: [timer operator on reactivex.io](http://reactivex.io/documentation/operators/timer.html) + + - parameter dueTime: Relative time at which to produce the first value. + - parameter period: Period to produce subsequent values. + - returns: An observable sequence that produces a value after due time has elapsed and then each period. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func timer(_ dueTime: RxTimeInterval, period: RxTimeInterval) + -> SharedSequence { + return SharedSequence(Observable.timer(dueTime, period: period, scheduler: S.scheduler)) + } +} + diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/Variable+SharedSequence.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/Variable+SharedSequence.swift new file mode 100644 index 0000000..e63e576 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/SharedSequence/Variable+SharedSequence.swift @@ -0,0 +1,26 @@ +// +// Variable+SharedSequence.swift +// Rx +// +// Created by Krunoslav Zaher on 12/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +extension Variable { + /** + Converts `Variable` to `SharedSequence` unit. + + - returns: Observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asSharedSequence(strategy: SharingStrategy.Type = SharingStrategy.self) -> SharedSequence { + let source = self.asObservable() + .observeOn(SharingStrategy.scheduler) + return SharedSequence(source) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/UIBindingObserver.swift b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/UIBindingObserver.swift new file mode 100644 index 0000000..634a5d1 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/CocoaUnits/UIBindingObserver.swift @@ -0,0 +1,62 @@ +// +// UIBindingObserver.swift +// Rx +// +// Created by Krunoslav Zaher on 2/7/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +/** +Observer that enforces interface binding rules: + * can't bind errors (in debug builds binding of errors causes `fatalError` in release builds errors are being logged) + * ensures binding is performed on main thread + +`UIBindingObserver` doesn't retain target interface and in case owned interface element is released, element isn't bound. +*/ +public class UIBindingObserver : ObserverType where UIElementType: AnyObject { + public typealias E = Value + + weak var UIElement: UIElementType? + + let binding: (UIElementType, Value) -> Void + + /** + Initializes `ViewBindingObserver` using + */ + public init(UIElement: UIElementType, binding: @escaping (UIElementType, Value) -> Void) { + self.UIElement = UIElement + self.binding = binding + } + + /** + Binds next element to owner view as described in `binding`. + */ + public func on(_ event: Event) { + MainScheduler.ensureExecutingOnScheduler(errorMessage: "Element can be bound to user interface only on MainThread.") + + switch event { + case .next(let element): + if let view = self.UIElement { + binding(view, element) + } + case .error(let error): + bindingErrorToInterface(error) + case .completed: + break + } + } + + /** + Erases type of observer. + + - returns: type erased observer. + */ + public func asObserver() -> AnyObserver { + return AnyObserver(eventHandler: on) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/DelegateProxy.swift b/Pods/RxCocoa/RxCocoa/Common/DelegateProxy.swift new file mode 100644 index 0000000..5fa0440 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/DelegateProxy.swift @@ -0,0 +1,273 @@ +// +// DelegateProxy.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +var delegateAssociatedTag: UInt8 = 0 +var dataSourceAssociatedTag: UInt8 = 0 + +/** +Base class for `DelegateProxyType` protocol. + +This implementation is not thread safe and can be used only from one thread (Main thread). +*/ +open class DelegateProxy : _RXDelegateProxy { + + private var sentMessageForSelector = [Selector: PublishSubject<[Any]>]() + private var methodInvokedForSelector = [Selector: PublishSubject<[Any]>]() + + /** + Parent object associated with delegate proxy. + */ + weak private(set) var parentObject: AnyObject? + + /** + Initializes new instance. + + - parameter parentObject: Optional parent object that owns `DelegateProxy` as associated object. + */ + public required init(parentObject: AnyObject) { + self.parentObject = parentObject + + MainScheduler.ensureExecutingOnScheduler() +#if TRACE_RESOURCES + OSAtomicIncrement32(&resourceCount) +#endif + super.init() + } + + /** + Returns observable sequence of invocations of delegate methods. Elements are sent *before method is invoked*. + + Only methods that have `void` return value can be observed using this method because + those methods are used as a notification mechanism. It doesn't matter if they are optional + or not. Observing is performed by installing a hidden associated `PublishSubject` that is + used to dispatch messages to observers. + + Delegate methods that have non `void` return value can't be observed directly using this method + because: + * those methods are not intended to be used as a notification mechanism, but as a behavior customization mechanism + * there is no sensible automatic way to determine a default return value + + In case observing of delegate methods that have return type is required, it can be done by + manually installing a `PublishSubject` or `BehaviorSubject` and implementing delegate method. + + e.g. + + // delegate proxy part (RxScrollViewDelegateProxy) + + let internalSubject = PublishSubject + + public func requiredDelegateMethod(scrollView: UIScrollView, arg1: CGPoint) -> Bool { + internalSubject.on(.next(arg1)) + return self._forwardToDelegate?.requiredDelegateMethod?(scrollView, arg1: arg1) ?? defaultReturnValue + } + + .... + + // reactive property implementation in a real class (`UIScrollView`) + public var property: Observable { + let proxy = RxScrollViewDelegateProxy.proxyForObject(base) + return proxy.internalSubject.asObservable() + } + + **In case calling this method prints "Delegate proxy is already implementing `\(selector)`, + a more performant way of registering might exist.", that means that manual observing method + is required analog to the example above because delegate method has already been implemented.** + + - parameter selector: Selector used to filter observed invocations of delegate methods. + - returns: Observable sequence of arguments passed to `selector` method. + */ + open func sentMessage(_ selector: Selector) -> Observable<[Any]> { + checkSelectorIsObservable(selector) + + let subject = sentMessageForSelector[selector] + + if let subject = subject { + return subject + } + else { + let subject = PublishSubject<[Any]>() + sentMessageForSelector[selector] = subject + return subject + } + } + + /** + Returns observable sequence of invoked delegate methods. Elements are sent *after method is invoked*. + + Only methods that have `void` return value can be observed using this method because + those methods are used as a notification mechanism. It doesn't matter if they are optional + or not. Observing is performed by installing a hidden associated `PublishSubject` that is + used to dispatch messages to observers. + + Delegate methods that have non `void` return value can't be observed directly using this method + because: + * those methods are not intended to be used as a notification mechanism, but as a behavior customization mechanism + * there is no sensible automatic way to determine a default return value + + In case observing of delegate methods that have return type is required, it can be done by + manually installing a `PublishSubject` or `BehaviorSubject` and implementing delegate method. + + e.g. + + // delegate proxy part (RxScrollViewDelegateProxy) + + let internalSubject = PublishSubject + + public func requiredDelegateMethod(scrollView: UIScrollView, arg1: CGPoint) -> Bool { + internalSubject.on(.next(arg1)) + return self._forwardToDelegate?.requiredDelegateMethod?(scrollView, arg1: arg1) ?? defaultReturnValue + } + + .... + + // reactive property implementation in a real class (`UIScrollView`) + public var property: Observable { + let proxy = RxScrollViewDelegateProxy.proxyForObject(base) + return proxy.internalSubject.asObservable() + } + + **In case calling this method prints "Delegate proxy is already implementing `\(selector)`, + a more performant way of registering might exist.", that means that manual observing method + is required analog to the example above because delegate method has already been implemented.** + + - parameter selector: Selector used to filter observed invocations of delegate methods. + - returns: Observable sequence of arguments passed to `selector` method. + */ + open func methodInvoked(_ selector: Selector) -> Observable<[Any]> { + checkSelectorIsObservable(selector) + + let subject = methodInvokedForSelector[selector] + + if let subject = subject { + return subject + } + else { + let subject = PublishSubject<[Any]>() + methodInvokedForSelector[selector] = subject + return subject + } + } + + private func checkSelectorIsObservable(_ selector: Selector) { + MainScheduler.ensureExecutingOnScheduler() + + if hasWiredImplementation(for: selector) { + print("Delegate proxy is already implementing `\(selector)`, a more performant way of registering might exist.") + } + + // It's important to see if super class reponds to selector and not self, + // because super class (_RxDelegateProxy) returns all methods delegate proxy + // can respond to. + // Because of https://github.com/ReactiveX/RxSwift/issues/907 , and possibly + // some other reasons, subclasses could overrride `responds(to:)`, but it shouldn't matter + // for this case. + if !super.responds(to: selector) { + rxFatalError("This class doesn't respond to selector \(selector)") + } + } + + @available(*, deprecated, renamed: "methodInvoked") + open func observe(_ selector: Selector) -> Observable<[Any]> { + return sentMessage(selector) + } + + // proxy + + open override func _sentMessage(_ selector: Selector, withArguments arguments: [Any]) { + sentMessageForSelector[selector]?.on(.next(arguments)) + } + + open override func _methodInvoked(_ selector: Selector, withArguments arguments: [Any]) { + methodInvokedForSelector[selector]?.on(.next(arguments)) + } + + /** + Returns tag used to identify associated object. + + - returns: Associated object tag. + */ + open class func delegateAssociatedObjectTag() -> UnsafeRawPointer { + return _pointer(&delegateAssociatedTag) + } + + /** + Initializes new instance of delegate proxy. + + - returns: Initialized instance of `self`. + */ + open class func createProxyForObject(_ object: AnyObject) -> AnyObject { + return self.init(parentObject: object) + } + + /** + Returns assigned proxy for object. + + - parameter object: Object that can have assigned delegate proxy. + - returns: Assigned delegate proxy or `nil` if no delegate proxy is assigned. + */ + open class func assignedProxyFor(_ object: AnyObject) -> AnyObject? { + let maybeDelegate = objc_getAssociatedObject(object, self.delegateAssociatedObjectTag()) + return castOptionalOrFatalError(maybeDelegate.map { $0 as AnyObject }) + } + + /** + Assigns proxy to object. + + - parameter object: Object that can have assigned delegate proxy. + - parameter proxy: Delegate proxy object to assign to `object`. + */ + open class func assignProxy(_ proxy: AnyObject, toObject object: AnyObject) { + precondition(proxy.isKind(of: self.classForCoder())) + + objc_setAssociatedObject(object, self.delegateAssociatedObjectTag(), proxy, .OBJC_ASSOCIATION_RETAIN) + } + + /** + Sets reference of normal delegate that receives all forwarded messages + through `self`. + + - parameter forwardToDelegate: Reference of delegate that receives all messages through `self`. + - parameter retainDelegate: Should `self` retain `forwardToDelegate`. + */ + open func setForwardToDelegate(_ delegate: AnyObject?, retainDelegate: Bool) { + self._setForward(toDelegate: delegate, retainDelegate: retainDelegate) + } + + /** + Returns reference of normal delegate that receives all forwarded messages + through `self`. + + - returns: Value of reference if set or nil. + */ + open func forwardToDelegate() -> AnyObject? { + return self._forwardToDelegate + } + + deinit { + for v in sentMessageForSelector.values { + v.on(.completed) + } + for v in methodInvokedForSelector.values { + v.on(.completed) + } +#if TRACE_RESOURCES + OSAtomicDecrement32(&resourceCount) +#endif + } + + // MARK: Pointer + + class func _pointer(_ p: UnsafeRawPointer) -> UnsafeRawPointer { + return p + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/DelegateProxyType.swift b/Pods/RxCocoa/RxCocoa/Common/DelegateProxyType.swift new file mode 100644 index 0000000..ef72bc9 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/DelegateProxyType.swift @@ -0,0 +1,280 @@ +// +// DelegateProxyType.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +/** +`DelegateProxyType` protocol enables using both normal delegates and Rx observable sequences with +views that can have only one delegate/datasource registered. + +`Proxies` store information about observers, subscriptions and delegates +for specific views. + +Type implementing `DelegateProxyType` should never be initialized directly. + +To fetch initialized instance of type implementing `DelegateProxyType`, `proxyForObject` method +should be used. + +This is more or less how it works. + + + + +-------------------------------------------+ + | | + | UIView subclass (UIScrollView) | + | | + +-----------+-------------------------------+ + | + | Delegate + | + | + +-----------v-------------------------------+ + | | + | Delegate proxy : DelegateProxyType +-----+----> Observable + | , UIScrollViewDelegate | | + +-----------+-------------------------------+ +----> Observable + | | + | +----> Observable + | | + | forwards events | + | to custom delegate | + | v + +-----------v-------------------------------+ + | | + | Custom delegate (UIScrollViewDelegate) | + | | + +-------------------------------------------+ + + +Since RxCocoa needs to automagically create those Proxys +..and because views that have delegates can be hierarchical + +UITableView : UIScrollView : UIView + +.. and corresponding delegates are also hierarchical + +UITableViewDelegate : UIScrollViewDelegate : NSObject + +.. and sometimes there can be only one proxy/delegate registered, +every view has a corresponding delegate virtual factory method. + +In case of UITableView / UIScrollView, there is + + extension UIScrollView { + public func createRxDelegateProxy() -> RxScrollViewDelegateProxy { + return RxScrollViewDelegateProxy(parentObject: base) + } + .... + + +and override in UITableView + + extension UITableView { + public override func createRxDelegateProxy() -> RxScrollViewDelegateProxy { + .... + + +*/ +public protocol DelegateProxyType : AnyObject { + /** + Creates new proxy for target object. + */ + static func createProxyForObject(_ object: AnyObject) -> AnyObject + + /** + Returns assigned proxy for object. + + - parameter object: Object that can have assigned delegate proxy. + - returns: Assigned delegate proxy or `nil` if no delegate proxy is assigned. + */ + static func assignedProxyFor(_ object: AnyObject) -> AnyObject? + + /** + Assigns proxy to object. + + - parameter object: Object that can have assigned delegate proxy. + - parameter proxy: Delegate proxy object to assign to `object`. + */ + static func assignProxy(_ proxy: AnyObject, toObject object: AnyObject) + + /** + Returns designated delegate property for object. + + Objects can have multiple delegate properties. + + Each delegate property needs to have it's own type implementing `DelegateProxyType`. + + - parameter object: Object that has delegate property. + - returns: Value of delegate property. + */ + static func currentDelegateFor(_ object: AnyObject) -> AnyObject? + + /** + Sets designated delegate property for object. + + Objects can have multiple delegate properties. + + Each delegate property needs to have it's own type implementing `DelegateProxyType`. + + - parameter toObject: Object that has delegate property. + - parameter delegate: Delegate value. + */ + static func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) + + /** + Returns reference of normal delegate that receives all forwarded messages + through `self`. + + - returns: Value of reference if set or nil. + */ + func forwardToDelegate() -> AnyObject? + + /** + Sets reference of normal delegate that receives all forwarded messages + through `self`. + + - parameter forwardToDelegate: Reference of delegate that receives all messages through `self`. + - parameter retainDelegate: Should `self` retain `forwardToDelegate`. + */ + func setForwardToDelegate(_ forwardToDelegate: AnyObject?, retainDelegate: Bool) +} + +@available(*, deprecated:2.5, renamed:"DelegateProxyType.proxyForObject", message:"You can just use normal static protocol extension. E.g. `RxScrollViewDelegateProxy.proxyForObject`") +public func proxyForObject(_ type: P.Type, _ object: AnyObject) -> P { + return P.proxyForObject(object) +} + +extension DelegateProxyType { + /** + Returns existing proxy for object or installs new instance of delegate proxy. + + - parameter object: Target object on which to install delegate proxy. + - returns: Installed instance of delegate proxy. + + + extension Reactive where Base: UISearchBar { + + public var delegate: DelegateProxy { + return RxSearchBarDelegateProxy.proxyForObject(base) + } + + public var text: ControlProperty { + let source: Observable = self.delegate.observe(#selector(UISearchBarDelegate.searchBar(_:textDidChange:))) + ... + } + } + */ + public static func proxyForObject(_ object: AnyObject) -> Self { + MainScheduler.ensureExecutingOnScheduler() + + let maybeProxy = Self.assignedProxyFor(object) as? Self + + let proxy: Self + if let existingProxy = maybeProxy { + proxy = existingProxy + } + else { + proxy = Self.createProxyForObject(object) as! Self + Self.assignProxy(proxy, toObject: object) + assert(Self.assignedProxyFor(object) === proxy) + } + + let currentDelegate: AnyObject? = Self.currentDelegateFor(object) + + if currentDelegate !== proxy { + proxy.setForwardToDelegate(currentDelegate, retainDelegate: false) + assert(proxy.forwardToDelegate() === currentDelegate) + Self.setCurrentDelegate(proxy, toObject: object) + assert(Self.currentDelegateFor(object) === proxy) + assert(proxy.forwardToDelegate() === currentDelegate) + } + + return proxy + } + + /** + Sets forward delegate for `DelegateProxyType` associated with a specific object and return disposable that can be used to unset the forward to delegate. + Using this method will also make sure that potential original object cached selectors are cleared and will report any accidental forward delegate mutations. + + - parameter forwardDelegate: Delegate object to set. + - parameter retainDelegate: Retain `forwardDelegate` while it's being set. + - parameter onProxyForObject: Object that has `delegate` property. + - returns: Disposable object that can be used to clear forward delegate. + */ + public static func installForwardDelegate(_ forwardDelegate: AnyObject, retainDelegate: Bool, onProxyForObject object: AnyObject) -> Disposable { + weak var weakForwardDelegate: AnyObject? = forwardDelegate + + let proxy = Self.proxyForObject(object) + + assert(proxy.forwardToDelegate() === nil, "This is a feature to warn you that there is already a delegate (or data source) set somewhere previously. The action you are trying to perform will clear that delegate (data source) and that means that some of your features that depend on that delegate (data source) being set will likely stop working.\n" + + "If you are ok with this, try to set delegate (data source) to `nil` in front of this operation.\n" + + " This is the source object value: \(object)\n" + + " This this the original delegate (data source) value: \(proxy.forwardToDelegate()!)\n" + + "Hint: Maybe delegate was already set in xib or storyboard and now it's being overwritten in code.\n") + + proxy.setForwardToDelegate(forwardDelegate, retainDelegate: retainDelegate) + + // refresh properties after delegate is set + // some views like UITableView cache `respondsToSelector` + Self.setCurrentDelegate(nil, toObject: object) + Self.setCurrentDelegate(proxy, toObject: object) + + assert(proxy.forwardToDelegate() === forwardDelegate, "Setting of delegate failed:\ncurrent:\n\(proxy.forwardToDelegate())\nexpected:\n\(forwardDelegate)") + + return Disposables.create { + MainScheduler.ensureExecutingOnScheduler() + + let delegate: AnyObject? = weakForwardDelegate + + assert(delegate == nil || proxy.forwardToDelegate() === delegate, "Delegate was changed from time it was first set. Current \(proxy.forwardToDelegate()), and it should have been \(proxy)") + + proxy.setForwardToDelegate(nil, retainDelegate: retainDelegate) + } + } +} + +extension ObservableType { + func subscribeProxyDataSource(ofObject object: AnyObject, dataSource: AnyObject, retainDataSource: Bool, binding: @escaping (P, Event) -> Void) + -> Disposable { + let proxy = P.proxyForObject(object) + let disposable = P.installForwardDelegate(dataSource, retainDelegate: retainDataSource, onProxyForObject: object) + + let subscription = self.asObservable() + .catchError { error in + bindingErrorToInterface(error) + return Observable.empty() + } + // source can never end, otherwise it would release the subscriber, and deallocate the data source + .concat(Observable.never()) + .takeUntil((object as! NSObject).rx.deallocated) + .subscribe { [weak object] (event: Event) in + MainScheduler.ensureExecutingOnScheduler() + + if let object = object { + assert(proxy === P.currentDelegateFor(object), "Proxy changed from the time it was first set.\nOriginal: \(proxy)\nExisting: \(P.currentDelegateFor(object))") + } + + binding(proxy, event) + + switch event { + case .error(let error): + bindingErrorToInterface(error) + disposable.dispose() + case .completed: + disposable.dispose() + default: + break + } + } + + return Disposables.create(subscription, disposable) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/KVORepresentable+CoreGraphics.swift b/Pods/RxCocoa/RxCocoa/Common/KVORepresentable+CoreGraphics.swift new file mode 100644 index 0000000..19abf65 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/KVORepresentable+CoreGraphics.swift @@ -0,0 +1,71 @@ +// +// KVORepresentable+CoreGraphics.swift +// Rx +// +// Created by Krunoslav Zaher on 11/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif +import CoreGraphics + +#if arch(x86_64) || arch(arm64) +let CGRectType = "{CGRect={CGPoint=dd}{CGSize=dd}}" +let CGSizeType = "{CGSize=dd}" +let CGPointType = "{CGPoint=dd}" +#elseif arch(i386) || arch(arm) +let CGRectType = "{CGRect={CGPoint=ff}{CGSize=ff}}" +let CGSizeType = "{CGSize=ff}" +let CGPointType = "{CGPoint=ff}" +#endif + +extension CGRect : KVORepresentable { + public typealias KVOType = NSValue + + /** + Constructs self from `NSValue`. + */ + public init?(KVOValue: KVOType) { + if strcmp(KVOValue.objCType, CGRectType) != 0 { + return nil + } + var typedValue = CGRect(x: 0, y: 0, width: 0, height: 0) + KVOValue.getValue(&typedValue) + self = typedValue + } +} + +extension CGPoint : KVORepresentable { + public typealias KVOType = NSValue + + /** + Constructs self from `NSValue`. + */ + public init?(KVOValue: KVOType) { + if strcmp(KVOValue.objCType, CGPointType) != 0 { + return nil + } + var typedValue = CGPoint(x: 0, y: 0) + KVOValue.getValue(&typedValue) + self = typedValue + } +} + +extension CGSize : KVORepresentable { + public typealias KVOType = NSValue + + /** + Constructs self from `NSValue`. + */ + public init?(KVOValue: KVOType) { + if strcmp(KVOValue.objCType, CGSizeType) != 0 { + return nil + } + var typedValue = CGSize(width: 0, height: 0) + KVOValue.getValue(&typedValue) + self = typedValue + } +} \ No newline at end of file diff --git a/Pods/RxCocoa/RxCocoa/Common/KVORepresentable+Swift.swift b/Pods/RxCocoa/RxCocoa/Common/KVORepresentable+Swift.swift new file mode 100644 index 0000000..a0378a4 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/KVORepresentable+Swift.swift @@ -0,0 +1,104 @@ +// +// KVORepresentable+Swift.swift +// Rx +// +// Created by Krunoslav Zaher on 11/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension Int : KVORepresentable { + public typealias KVOType = NSNumber + + /** + Constructs `Self` using KVO value. + */ + public init?(KVOValue: KVOType) { + self.init(KVOValue.int32Value) + } +} + +extension Int32 : KVORepresentable { + public typealias KVOType = NSNumber + + /** + Constructs `Self` using KVO value. + */ + public init?(KVOValue: KVOType) { + self.init(KVOValue.int32Value) + } +} + +extension Int64 : KVORepresentable { + public typealias KVOType = NSNumber + + /** + Constructs `Self` using KVO value. + */ + public init?(KVOValue: KVOType) { + self.init(KVOValue.int64Value) + } +} + +extension UInt : KVORepresentable { + public typealias KVOType = NSNumber + + /** + Constructs `Self` using KVO value. + */ + public init?(KVOValue: KVOType) { + self.init(KVOValue.uintValue) + } +} + +extension UInt32 : KVORepresentable { + public typealias KVOType = NSNumber + + /** + Constructs `Self` using KVO value. + */ + public init?(KVOValue: KVOType) { + self.init(KVOValue.uint32Value) + } +} + +extension UInt64 : KVORepresentable { + public typealias KVOType = NSNumber + + /** + Constructs `Self` using KVO value. + */ + public init?(KVOValue: KVOType) { + self.init(KVOValue.uint64Value) + } +} + +extension Bool : KVORepresentable { + public typealias KVOType = NSNumber + + /** + Constructs `Self` using KVO value. + */ + public init?(KVOValue: KVOType) { + self.init(KVOValue.boolValue) + } +} + + +extension RawRepresentable where RawValue: KVORepresentable { + /** + Constructs `Self` using optional KVO value. + */ + init?(KVOValue: RawValue.KVOType?) { + guard let KVOValue = KVOValue else { + return nil + } + + guard let rawValue = RawValue(KVOValue: KVOValue) else { + return nil + } + + self.init(rawValue: rawValue) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/KVORepresentable.swift b/Pods/RxCocoa/RxCocoa/Common/KVORepresentable.swift new file mode 100644 index 0000000..c51774b --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/KVORepresentable.swift @@ -0,0 +1,38 @@ +// +// KVORepresentable.swift +// Rx +// +// Created by Krunoslav Zaher on 11/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Type that is KVO representable (KVO mechanism can be used to observe it). +*/ +public protocol KVORepresentable { + /** + Associated KVO type. + */ + associatedtype KVOType + + /** + Constructs `Self` using KVO value. + */ + init?(KVOValue: KVOType) +} + +extension KVORepresentable { + /** + Initializes `KVORepresentable` with optional value. + */ + init?(KVOValue: KVOType?) { + guard let KVOValue = KVOValue else { + return nil + } + + self.init(KVOValue: KVOValue) + } +} + diff --git a/Pods/RxCocoa/RxCocoa/Common/Logging.swift b/Pods/RxCocoa/RxCocoa/Common/Logging.swift new file mode 100644 index 0000000..c937310 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/Logging.swift @@ -0,0 +1,27 @@ +// +// Logging.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 4/3/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Simple logging settings for RxCocoa library. +*/ +public struct Logging { + public typealias LogURLRequest = (URLRequest) -> Bool + + /** + Log URL requests to standard output in curl format. + */ + public static var URLRequests: LogURLRequest = { _ in + #if DEBUG + return true + #else + return false + #endif + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift b/Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift new file mode 100644 index 0000000..94fda3e --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/NSLayoutConstraint+Rx.swift @@ -0,0 +1,43 @@ +// +// NSLayoutConstraint+Rx.swift +// Rx +// +// Created by Krunoslav Zaher on 12/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if os(OSX) +import Cocoa +#else +import UIKit +#endif + +#if !RX_NO_MODULE +import RxSwift +#endif + +#if os(iOS) || os(OSX) || os(tvOS) +extension Reactive where Base: NSLayoutConstraint { + /** + Bindable sink for `constant` property. + */ + public var constant: AnyObserver { + return UIBindingObserver(UIElement: self.base) { constraint, constant in + constraint.constant = constant + }.asObserver() + } + + /** + Bindable sink for `active` property. + */ + @available(iOS 8, OSX 10.10, *) + public var active: AnyObserver { + return UIBindingObserver(UIElement: self.base) { constraint, value in + constraint.isActive = value + }.asObserver() + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/Common/Observable+Bind.swift b/Pods/RxCocoa/RxCocoa/Common/Observable+Bind.swift new file mode 100644 index 0000000..d43594e --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/Observable+Bind.swift @@ -0,0 +1,107 @@ +// +// Observable+Bind.swift +// Rx +// +// Created by Krunoslav Zaher on 8/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +extension ObservableType { + + /** + Creates new subscription and sends elements to observer. + + In this form it's equivalent to `subscribe` method, but it communicates intent better, and enables + writing more consistent binding code. + + - parameter observer: Observer that receives events. + - returns: Disposable object that can be used to unsubscribe the observer. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + public func bindTo(_ observer: O) -> Disposable where O.E == E { + return self.subscribe(observer) + } + + /** + Creates new subscription and sends elements to variable. + + In case error occurs in debug mode, `fatalError` will be raised. + In case error occurs in release mode, `error` will be logged. + + - parameter variable: Target variable for sequence elements. + - returns: Disposable object that can be used to unsubscribe the observer. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + public func bindTo(_ variable: Variable) -> Disposable { + return subscribe { e in + switch e { + case let .next(element): + variable.value = element + case let .error(error): + let error = "Binding error to variable: \(error)" + #if DEBUG + rxFatalError(error) + #else + print(error) + #endif + case .completed: + break + } + } + } + + /** + Subscribes to observable sequence using custom binder function. + + - parameter binder: Function used to bind elements from `self`. + - returns: Object representing subscription. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + public func bindTo(_ binder: (Self) -> R) -> R { + return binder(self) + } + + /** + Subscribes to observable sequence using custom binder function and final parameter passed to binder function + after `self` is passed. + + public func bindTo(binder: Self -> R1 -> R2, curriedArgument: R1) -> R2 { + return binder(self)(curriedArgument) + } + + - parameter binder: Function used to bind elements from `self`. + - parameter curriedArgument: Final argument passed to `binder` to finish binding process. + - returns: Object representing subscription. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + public func bindTo(_ binder: (Self) -> (R1) -> R2, curriedArgument: R1) -> R2 { + return binder(self)(curriedArgument) + } + + + /** + Subscribes an element handler to an observable sequence. + + In case error occurs in debug mode, `fatalError` will be raised. + In case error occurs in release mode, `error` will be logged. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + public func bindNext(_ onNext: @escaping (E) -> Void) -> Disposable { + return subscribe(onNext: onNext, onError: { error in + let error = "Binding error: \(error)" + #if DEBUG + rxFatalError(error) + #else + print(error) + #endif + }) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/Observables/Implementations/ControlTarget.swift b/Pods/RxCocoa/RxCocoa/Common/Observables/Implementations/ControlTarget.swift new file mode 100644 index 0000000..859c197 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/Observables/Implementations/ControlTarget.swift @@ -0,0 +1,92 @@ +// +// ControlTarget.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) || os(OSX) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +#if os(iOS) || os(tvOS) + import UIKit + + typealias Control = UIKit.UIControl + typealias ControlEvents = UIKit.UIControlEvents +#elseif os(OSX) + import Cocoa + + typealias Control = Cocoa.NSControl +#endif + +// This should be only used from `MainScheduler` +class ControlTarget: RxTarget { + typealias Callback = (Control) -> Void + + let selector: Selector = #selector(ControlTarget.eventHandler(_:)) + + weak var control: Control? +#if os(iOS) || os(tvOS) + let controlEvents: UIControlEvents +#endif + var callback: Callback? + #if os(iOS) || os(tvOS) + init(control: Control, controlEvents: UIControlEvents, callback: @escaping Callback) { + MainScheduler.ensureExecutingOnScheduler() + + self.control = control + self.controlEvents = controlEvents + self.callback = callback + + super.init() + + control.addTarget(self, action: selector, for: controlEvents) + + let method = self.method(for: selector) + if method == nil { + rxFatalError("Can't find method") + } + } +#elseif os(OSX) + init(control: Control, callback: @escaping Callback) { + MainScheduler.ensureExecutingOnScheduler() + + self.control = control + self.callback = callback + + super.init() + + control.target = self + control.action = selector + + let method = self.method(for: selector) + if method == nil { + rxFatalError("Can't find method") + } + } +#endif + + func eventHandler(_ sender: Control!) { + if let callback = self.callback, let control = self.control { + callback(control) + } + } + + override func dispose() { + super.dispose() +#if os(iOS) || os(tvOS) + self.control?.removeTarget(self, action: self.selector, for: self.controlEvents) +#elseif os(OSX) + self.control?.target = nil + self.control?.action = nil +#endif + self.callback = nil + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift b/Pods/RxCocoa/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift new file mode 100644 index 0000000..23f1f53 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift @@ -0,0 +1,34 @@ +// +// NSNotificationCenter+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 5/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +extension Reactive where Base: NotificationCenter { + /** + Transforms notifications posted to notification center to observable sequence of notifications. + + - parameter name: Filter notifications by name. + - parameter object: Optional object used to filter notifications. + - returns: Observable sequence of posted notifications. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func notification(_ name: Notification.Name, object: AnyObject? = nil) -> Observable { + return Observable.create { [weak object] observer in + let nsObserver = self.base.addObserver(forName: name, object: object, queue: nil) { notification in + observer.on(.next(notification)) + } + + return Disposables.create { + self.base.removeObserver(nsObserver) + } + } + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx+KVORepresentable.swift b/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx+KVORepresentable.swift new file mode 100644 index 0000000..9b8858c --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx+KVORepresentable.swift @@ -0,0 +1,45 @@ +// +// NSObject+Rx+KVORepresentable.swift +// Rx +// +// Created by Krunoslav Zaher on 11/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +extension Reactive where Base: NSObject { + + /** + Specialization of generic `observe` method. + + This is a special overload because to observe values of some type (for example `Int`), first values of KVO type + need to be observed (`NSNumber`), and then converted to result type. + + For more information take a look at `observe` method. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func observe(_ type: E.Type, _ keyPath: String, options: NSKeyValueObservingOptions = [.new, .initial], retainSelf: Bool = true) -> Observable { + return observe(E.KVOType.self, keyPath, options: options, retainSelf: retainSelf) + .map(E.init) + } +} + +#if !DISABLE_SWIZZLING + // KVO + extension Reactive where Base: NSObject { + /** + Specialization of generic `observeWeakly` method. + + For more information take a look at `observeWeakly` method. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func observeWeakly(_ type: E.Type, _ keyPath: String, options: NSKeyValueObservingOptions = [.new, .initial]) -> Observable { + return observeWeakly(E.KVOType.self, keyPath, options: options) + .map(E.init) + } + } +#endif diff --git a/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx+RawRepresentable.swift b/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx+RawRepresentable.swift new file mode 100644 index 0000000..50f9cac --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx+RawRepresentable.swift @@ -0,0 +1,51 @@ +// +// NSObject+Rx+RawRepresentable.swift +// Rx +// +// Created by Krunoslav Zaher on 11/9/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + +extension Reactive where Base: NSObject { + /** + Specialization of generic `observe` method. + + This specialization first observes `KVORepresentable` value and then converts it to `RawRepresentable` value. + + It is useful for observing bridged ObjC enum values. + + For more information take a look at `observe` method. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func observe(_ type: E.Type, _ keyPath: String, options: NSKeyValueObservingOptions = [.new, .initial], retainSelf: Bool = true) -> Observable where E.RawValue: KVORepresentable { + return observe(E.RawValue.KVOType.self, keyPath, options: options, retainSelf: retainSelf) + .map(E.init) + } +} + +#if !DISABLE_SWIZZLING + + // observeWeakly + RawRepresentable + extension Reactive where Base: NSObject { + + /** + Specialization of generic `observeWeakly` method. + + This specialization first observes `KVORepresentable` value and then converts it to `RawRepresentable` value. + + It is useful for observing bridged ObjC enum values. + + For more information take a look at `observeWeakly` method. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func observeWeakly(_ type: E.Type, _ keyPath: String, options: NSKeyValueObservingOptions = [.new, .initial]) -> Observable where E.RawValue: KVORepresentable { + return observeWeakly(E.RawValue.KVOType.self, keyPath, options: options) + .map(E.init) + } + } +#endif diff --git a/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx.swift b/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx.swift new file mode 100644 index 0000000..60d04aa --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/Observables/NSObject+Rx.swift @@ -0,0 +1,519 @@ +// +// NSObject+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +#if !DISABLE_SWIZZLING +var deallocatingSubjectTriggerContext: UInt8 = 0 +var deallocatingSubjectContext: UInt8 = 0 +#endif +var deallocatedSubjectTriggerContext: UInt8 = 0 +var deallocatedSubjectContext: UInt8 = 0 + +/** +KVO is a tricky mechanism. + +When observing child in a ownership hierarchy, usually retaining observing target is wanted behavior. +When observing parent in a ownership hierarchy, usually retaining target isn't wanter behavior. + +KVO with weak references is especially tricky. For it to work, some kind of swizzling is required. +That can be done by + * replacing object class dynamically (like KVO does) + * by swizzling `dealloc` method on all instances for a class. + * some third method ... + +Both approaches can fail in certain scenarios: + * problems arise when swizzlers return original object class (like KVO does when nobody is observing) + * Problems can arise because replacing dealloc method isn't atomic operation (get implementation, + set implementation). + +Second approach is chosen. It can fail in case there are multiple libraries dynamically trying +to replace dealloc method. In case that isn't the case, it should be ok. +*/ +extension Reactive where Base: NSObject { + + + /** + Observes values on `keyPath` starting from `self` with `options` and retains `self` if `retainSelf` is set. + + `observe` is just a simple and performant wrapper around KVO mechanism. + + * it can be used to observe paths starting from `self` or from ancestors in ownership graph (`retainSelf = false`) + * it can be used to observe paths starting from descendants in ownership graph (`retainSelf = true`) + * the paths have to consist only of `strong` properties, otherwise you are risking crashing the system by not unregistering KVO observer before dealloc. + + If support for weak properties is needed or observing arbitrary or unknown relationships in the + ownership tree, `observeWeakly` is the preferred option. + + - parameter keyPath: Key path of property names to observe. + - parameter options: KVO mechanism notification options. + - parameter retainSelf: Retains self during observation if set `true`. + - returns: Observable sequence of objects on `keyPath`. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func observe(_ type: E.Type, _ keyPath: String, options: NSKeyValueObservingOptions = [.new, .initial], retainSelf: Bool = true) -> Observable { + return KVOObservable(object: base, keyPath: keyPath, options: options, retainTarget: retainSelf).asObservable() + } +} + +#if !DISABLE_SWIZZLING +// KVO +extension Reactive where Base: NSObject { + /** + Observes values on `keyPath` starting from `self` with `options` and doesn't retain `self`. + + It can be used in all cases where `observe` can be used and additionally + + * because it won't retain observed target, it can be used to observe arbitrary object graph whose ownership relation is unknown + * it can be used to observe `weak` properties + + **Since it needs to intercept object deallocation process it needs to perform swizzling of `dealloc` method on observed object.** + + - parameter keyPath: Key path of property names to observe. + - parameter options: KVO mechanism notification options. + - returns: Observable sequence of objects on `keyPath`. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func observeWeakly(_ type: E.Type, _ keyPath: String, options: NSKeyValueObservingOptions = [.new, .initial]) -> Observable { + return observeWeaklyKeyPathFor(base, keyPath: keyPath, options: options) + .map { n in + return n as? E + } + } +} +#endif + +// Dealloc +extension Reactive where Base: AnyObject { + + /** + Observable sequence of object deallocated events. + + After object is deallocated one `()` element will be produced and sequence will immediately complete. + + - returns: Observable sequence of object deallocated events. + */ + public var deallocated: Observable { + return synchronized { + if let deallocObservable = objc_getAssociatedObject(base, &deallocatedSubjectContext) as? DeallocObservable { + return deallocObservable._subject + } + + let deallocObservable = DeallocObservable() + + objc_setAssociatedObject(base, &deallocatedSubjectContext, deallocObservable, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + return deallocObservable._subject + } + } + +#if !DISABLE_SWIZZLING + + /** + Observable sequence of message arguments that completes when object is deallocated. + + Each element is produced before message is invoked on target object. `methodInvoked` + exists in case observing of invoked messages is needed. + + In case an error occurs sequence will fail with `RxCocoaObjCRuntimeError`. + + In case some argument is `nil`, instance of `NSNull()` will be sent. + + - returns: Observable sequence of object deallocating events. + */ + public func sentMessage(_ selector: Selector) -> Observable<[Any]> { + return synchronized { + // in case of dealloc selector replay subject behavior needs to be used + if selector == deallocSelector { + return deallocating.map { _ in [] } + } + + do { + let proxy: MessageSentProxy = try registerMessageInterceptor(selector) + return proxy.messageSent.asObservable() + } + catch let e { + return Observable.error(e) + } + } + } + + /** + Observable sequence of message arguments that completes when object is deallocated. + + Each element is produced after message is invoked on target object. `sentMessage` + exists in case interception of sent messages before they were invoked is needed. + + In case an error occurs sequence will fail with `RxCocoaObjCRuntimeError`. + + In case some argument is `nil`, instance of `NSNull()` will be sent. + + - returns: Observable sequence of object deallocating events. + */ + public func methodInvoked(_ selector: Selector) -> Observable<[Any]> { + return synchronized { + // in case of dealloc selector replay subject behavior needs to be used + if selector == deallocSelector { + return deallocated.map { _ in [] } + } + + + do { + let proxy: MessageSentProxy = try registerMessageInterceptor(selector) + return proxy.methodInvoked.asObservable() + } + catch let e { + return Observable.error(e) + } + } + } + + /** + Observable sequence of object deallocating events. + + When `dealloc` message is sent to `self` one `()` element will be produced and after object is deallocated sequence + will immediately complete. + + In case an error occurs sequence will fail with `RxCocoaObjCRuntimeError`. + + - returns: Observable sequence of object deallocating events. + */ + public var deallocating: Observable<()> { + return synchronized { + do { + let proxy: DeallocatingProxy = try registerMessageInterceptor(deallocSelector) + return proxy.messageSent.asObservable() + } + catch let e { + return Observable.error(e) + } + } + } + + fileprivate func registerMessageInterceptor(_ selector: Selector) throws -> T { + let rxSelector = RX_selector(selector) + let selectorReference = RX_reference_from_selector(rxSelector) + + let subject: T + if let existingSubject = objc_getAssociatedObject(base, selectorReference) as? T { + subject = existingSubject + } + else { + subject = T() + objc_setAssociatedObject( + base, + selectorReference, + subject, + .OBJC_ASSOCIATION_RETAIN_NONATOMIC + ) + } + + if subject.isActive { + return subject + } + + var error: NSError? + let targetImplementation = RX_ensure_observing(base, selector, &error) + if targetImplementation == nil { + throw error?.rxCocoaErrorForTarget(base) ?? RxCocoaError.unknown + } + + subject.targetImplementation = targetImplementation! + + return subject + } +#endif +} + +// MARK: Message interceptors + +#if !DISABLE_SWIZZLING + + fileprivate protocol MessageInterceptorSubject: class { + init() + + var isActive: Bool { + get + } + + var targetImplementation: IMP { get set } + } + + fileprivate final class DeallocatingProxy + : MessageInterceptorSubject + , RXDeallocatingObserver { + typealias E = () + + let messageSent = ReplaySubject<()>.create(bufferSize: 1) + + @objc var targetImplementation: IMP = RX_default_target_implementation() + + var isActive: Bool { + return targetImplementation != RX_default_target_implementation() + } + + init() { + } + + @objc func deallocating() -> Void { + messageSent.on(.next()) + } + + deinit { + messageSent.on(.completed) + } + } + + fileprivate final class MessageSentProxy + : MessageInterceptorSubject + , RXMessageSentObserver { + typealias E = [AnyObject] + + let messageSent = PublishSubject<[Any]>() + let methodInvoked = PublishSubject<[Any]>() + + @objc var targetImplementation: IMP = RX_default_target_implementation() + + var isActive: Bool { + return targetImplementation != RX_default_target_implementation() + } + + init() { + } + + @objc func messageSent(withArguments arguments: [Any]) -> Void { + messageSent.on(.next(arguments)) + } + + @objc func methodInvoked(withArguments arguments: [Any]) -> Void { + methodInvoked.on(.next(arguments)) + } + + deinit { + messageSent.on(.completed) + methodInvoked.on(.completed) + } + } + +#endif + + +fileprivate class DeallocObservable { + let _subject = ReplaySubject.create(bufferSize:1) + + init() { + } + + deinit { + _subject.on(.next(())) + _subject.on(.completed) + } +} + +// MARK: KVO + +fileprivate protocol KVOObservableProtocol { + var target: AnyObject { get } + var keyPath: String { get } + var retainTarget: Bool { get } + var options: NSKeyValueObservingOptions { get } +} + +fileprivate class KVOObserver + : _RXKVOObserver + , Disposable { + typealias Callback = (Any?) -> Void + + var retainSelf: KVOObserver? = nil + + init(parent: KVOObservableProtocol, callback: @escaping Callback) { + #if TRACE_RESOURCES + OSAtomicIncrement32(&resourceCount) + #endif + + super.init(target: parent.target, retainTarget: parent.retainTarget, keyPath: parent.keyPath, options: parent.options, callback: callback) + self.retainSelf = self + } + + override func dispose() { + super.dispose() + self.retainSelf = nil + } + + deinit { + #if TRACE_RESOURCES + OSAtomicDecrement32(&resourceCount) + #endif + } +} + +fileprivate class KVOObservable + : ObservableType + , KVOObservableProtocol { + typealias E = Element? + + unowned var target: AnyObject + var strongTarget: AnyObject? + + var keyPath: String + var options: NSKeyValueObservingOptions + var retainTarget: Bool + + init(object: AnyObject, keyPath: String, options: NSKeyValueObservingOptions, retainTarget: Bool) { + self.target = object + self.keyPath = keyPath + self.options = options + self.retainTarget = retainTarget + if retainTarget { + self.strongTarget = object + } + } + + func subscribe(_ observer: O) -> Disposable where O.E == Element? { + let observer = KVOObserver(parent: self) { (value) in + if value as? NSNull != nil { + observer.on(.next(nil)) + return + } + observer.on(.next(value as? Element)) + } + + return Disposables.create(with: observer.dispose) + } + +} + +#if !DISABLE_SWIZZLING + + fileprivate func observeWeaklyKeyPathFor(_ target: NSObject, keyPath: String, options: NSKeyValueObservingOptions) -> Observable { + let components = keyPath.components(separatedBy: ".").filter { $0 != "self" } + + let observable = observeWeaklyKeyPathFor(target, keyPathSections: components, options: options) + .finishWithNilWhenDealloc(target) + + if !options.intersection(.initial).isEmpty { + return observable + } + else { + return observable + .skip(1) + } + } + + // This should work correctly + // Identifiers can't contain `,`, so the only place where `,` can appear + // is as a delimiter. + // This means there is `W` as element in an array of property attributes. + fileprivate func isWeakProperty(_ properyRuntimeInfo: String) -> Bool { + return properyRuntimeInfo.range(of: ",W,") != nil + } + + fileprivate extension ObservableType where E == AnyObject? { + func finishWithNilWhenDealloc(_ target: NSObject) + -> Observable { + let deallocating = target.rx.deallocating + + return deallocating + .map { _ in + return Observable.just(nil) + } + .startWith(self.asObservable()) + .switchLatest() + } + } + + fileprivate func observeWeaklyKeyPathFor( + _ target: NSObject, + keyPathSections: [String], + options: NSKeyValueObservingOptions + ) -> Observable { + + weak var weakTarget: AnyObject? = target + + let propertyName = keyPathSections[0] + let remainingPaths = Array(keyPathSections[1.. + + // KVO recursion for value changes + return propertyObservable + .flatMapLatest { (nextTarget: AnyObject?) -> Observable in + if nextTarget == nil { + return Observable.just(nil) + } + let nextObject = nextTarget! as? NSObject + + let strongTarget: AnyObject? = weakTarget + + if nextObject == nil { + return Observable.error(RxCocoaError.invalidObjectOnKeyPath(object: nextTarget!, sourceObject: strongTarget ?? NSNull(), propertyName: propertyName)) + } + + // if target is alive, then send change + // if it's deallocated, don't send anything + if strongTarget == nil { + return Observable.empty() + } + + let nextElementsObservable = keyPathSections.count == 1 + ? Observable.just(nextTarget) + : observeWeaklyKeyPathFor(nextObject!, keyPathSections: remainingPaths, options: options) + + if isWeak { + return nextElementsObservable + .finishWithNilWhenDealloc(nextObject!) + } + else { + return nextElementsObservable + } + } + } +#endif + +// MARK Constants + +fileprivate let deallocSelector = NSSelectorFromString("dealloc") + +// MARK: AnyObject + Reactive + +extension Reactive where Base: AnyObject { + func synchronized( _ action: () -> T) -> T { + objc_sync_enter(self.base) + let result = action() + objc_sync_exit(self.base) + return result + } +} + +extension Reactive where Base: AnyObject { + /** + Helper to make sure that `Observable` returned from `createCachedObservable` is only created once. + This is important because there is only one `target` and `action` properties on `NSControl` or `UIBarButtonItem`. + */ + func lazyInstanceObservable(_ key: UnsafeRawPointer, createCachedObservable: () -> T) -> T { + if let value = objc_getAssociatedObject(base, key) { + return value as! T + } + + let observable = createCachedObservable() + + objc_setAssociatedObject(base, key, observable, .OBJC_ASSOCIATION_RETAIN_NONATOMIC) + + return observable + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/Observables/NSURLSession+Rx.swift b/Pods/RxCocoa/RxCocoa/Common/Observables/NSURLSession+Rx.swift new file mode 100644 index 0000000..8e23f8f --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/Observables/NSURLSession+Rx.swift @@ -0,0 +1,238 @@ +// +// NSURLSession+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 3/23/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +/** +RxCocoa URL errors. +*/ +public enum RxCocoaURLError + : Swift.Error + , CustomDebugStringConvertible { + /** + Unknown error occurred. + */ + case unknown + /** + Response is not NSHTTPURLResponse + */ + case nonHTTPResponse(response: URLResponse) + /** + Response is not successful. (not in `200 ..< 300` range) + */ + case httpRequestFailed(response: HTTPURLResponse, data: Data?) + /** + Deserialization error. + */ + case deserializationError(error: Swift.Error) +} + +public extension RxCocoaURLError { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription: String { + switch self { + case .unknown: + return "Unknown error has occurred." + case let .nonHTTPResponse(response): + return "Response is not NSHTTPURLResponse `\(response)`." + case let .httpRequestFailed(response, _): + return "HTTP request failed with `\(response.statusCode)`." + case let .deserializationError(error): + return "Error during deserialization of the response: \(error)" + } + } +} + +func escapeTerminalString(_ value: String) -> String { + return value.replacingOccurrences(of: "\"", with: "\\\"", options:[], range: nil) +} + +func convertURLRequestToCurlCommand(_ request: URLRequest) -> String { + let method = request.httpMethod ?? "GET" + var returnValue = "curl -X \(method) " + + if request.httpMethod == "POST" && request.httpBody != nil { + let maybeBody = NSString(data: request.httpBody!, encoding: String.Encoding.utf8.rawValue) as? String + if let body = maybeBody { + returnValue += "-d \"\(escapeTerminalString(body))\" " + } + } + + for (key, value) in request.allHTTPHeaderFields ?? [:] { + let escapedKey = escapeTerminalString(key as String) + let escapedValue = escapeTerminalString(value as String) + returnValue += "\n -H \"\(escapedKey): \(escapedValue)\" " + } + + let URLString = request.url?.absoluteString ?? "" + + returnValue += "\n\"\(escapeTerminalString(URLString))\"" + + returnValue += " -i -v" + + return returnValue +} + +func convertResponseToString(_ data: Data!, _ response: URLResponse!, _ error: NSError!, _ interval: TimeInterval) -> String { + let ms = Int(interval * 1000) + + if let response = response as? HTTPURLResponse { + if 200 ..< 300 ~= response.statusCode { + return "Success (\(ms)ms): Status \(response.statusCode)" + } + else { + return "Failure (\(ms)ms): Status \(response.statusCode)" + } + } + + if let error = error { + if error.domain == NSURLErrorDomain && error.code == NSURLErrorCancelled { + return "Cancelled (\(ms)ms)" + } + return "Failure (\(ms)ms): NSError > \(error)" + } + + return "" +} + +extension Reactive where Base: URLSession { + /** + Observable sequence of responses for URL request. + + Performing of request starts after observer is subscribed and not after invoking this method. + + **URL requests will be performed per subscribed observer.** + + Any error during fetching of the response will cause observed sequence to terminate with error. + + - parameter request: URL request. + - returns: Observable sequence of URL responses. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func response(_ request: URLRequest) -> Observable<(Data, HTTPURLResponse)> { + return Observable.create { observer in + + // smart compiler should be able to optimize this out + var d: Date? + + if Logging.URLRequests(request) { + d = Date() + } + + let task = self.base.dataTask(with: request) { (data, response, error) in + + if Logging.URLRequests(request) { + let interval = Date().timeIntervalSince(d ?? Date()) + print(convertURLRequestToCurlCommand(request)) + print(convertResponseToString(data, response, error as NSError!, interval)) + } + + guard let response = response, let data = data else { + observer.on(.error(error ?? RxCocoaURLError.unknown)) + return + } + + guard let httpResponse = response as? HTTPURLResponse else { + observer.on(.error(RxCocoaURLError.nonHTTPResponse(response: response))) + return + } + + observer.on(.next(data, httpResponse)) + observer.on(.completed) + } + + + let t = task + t.resume() + + return Disposables.create(with: task.cancel) + } + } + + /** + Observable sequence of response data for URL request. + + Performing of request starts after observer is subscribed and not after invoking this method. + + **URL requests will be performed per subscribed observer.** + + Any error during fetching of the response will cause observed sequence to terminate with error. + + If response is not HTTP response with status code in the range of `200 ..< 300`, sequence + will terminate with `(RxCocoaErrorDomain, RxCocoaError.NetworkError)`. + + - parameter request: URL request. + - returns: Observable sequence of response data. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func data(_ request: URLRequest) -> Observable { + return response(request).map { (data, response) -> Data in + if 200 ..< 300 ~= response.statusCode { + return data + } + else { + throw RxCocoaURLError.httpRequestFailed(response: response, data: data) + } + } + } + + /** + Observable sequence of response JSON for URL request. + + Performing of request starts after observer is subscribed and not after invoking this method. + + **URL requests will be performed per subscribed observer.** + + Any error during fetching of the response will cause observed sequence to terminate with error. + + If response is not HTTP response with status code in the range of `200 ..< 300`, sequence + will terminate with `(RxCocoaErrorDomain, RxCocoaError.NetworkError)`. + + If there is an error during JSON deserialization observable sequence will fail with that error. + + - parameter request: URL request. + - returns: Observable sequence of response JSON. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func JSON(_ request: URLRequest) -> Observable { + return data(request).map { (data) -> AnyObject in + do { + return try JSONSerialization.jsonObject(with: data, options: []) as AnyObject + } catch let error { + throw RxCocoaURLError.deserializationError(error: error) + } + } + } + + /** + Observable sequence of response JSON for GET request with `URL`. + + Performing of request starts after observer is subscribed and not after invoking this method. + + **URL requests will be performed per subscribed observer.** + + Any error during fetching of the response will cause observed sequence to terminate with error. + + If response is not HTTP response with status code in the range of `200 ..< 300`, sequence + will terminate with `(RxCocoaErrorDomain, RxCocoaError.NetworkError)`. + + If there is an error during JSON deserialization observable sequence will fail with that error. + + - parameter URL: URL of `NSURLRequest` request. + - returns: Observable sequence of response JSON. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func JSON(_ URL: Foundation.URL) -> Observable { + return JSON(URLRequest(url: URL)) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/RxCocoa.swift b/Pods/RxCocoa/RxCocoa/Common/RxCocoa.swift new file mode 100644 index 0000000..6f5a71f --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/RxCocoa.swift @@ -0,0 +1,345 @@ +// +// RxCocoa.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +#if os(iOS) + import UIKit +#endif + +/** +RxCocoa errors. +*/ +public enum RxCocoaError + : Swift.Error + , CustomDebugStringConvertible { + /** + Unknown error has occurred. + */ + case unknown + /** + Invalid operation was attempted. + */ + case invalidOperation(object: Any) + /** + Items are not yet bound to user interface but have been requested. + */ + case itemsNotYetBound(object: Any) + /** + Invalid KVO Path. + */ + case invalidPropertyName(object: Any, propertyName: String) + /** + Invalid object on key path. + */ + case invalidObjectOnKeyPath(object: Any, sourceObject: AnyObject, propertyName: String) + /** + Error during swizzling. + */ + case errorDuringSwizzling + /* + Casting error. + */ + case castingError(object: Any, targetType: Any.Type) +} + +#if !DISABLE_SWIZZLING +/** +RxCocoa ObjC runtime interception mechanism. + */ +public enum RxCocoaInterceptionMechanism { + /** + Unknown message interception mechanism. + */ + case unknown + /** + Key value observing interception mechanism. + */ + case kvo +} + +/** +RxCocoa ObjC runtime modification errors. + */ +public enum RxCocoaObjCRuntimeError + : Swift.Error + , CustomDebugStringConvertible { + /** + Unknown error has occurred. + */ + case unknown(target: AnyObject) + + /** + If the object is reporting a different class then it's real class, that means that there is probably + already some interception mechanism in place or something weird is happening. + + The most common case when this would happen is when using a combination of KVO (`observe`) and `sentMessage`. + + This error is easily resolved by just using `sentMessage` observing before `observe`. + + The reason why the other way around could create issues is because KVO will unregister it's interceptor + class and restore original class. Unfortunately that will happen no matter was there another interceptor + subclass registered in hierarchy or not. + + Failure scenario: + * KVO sets class to be `__KVO__OriginalClass` (subclass of `OriginalClass`) + * `sentMessage` sets object class to be `_RX_namespace___KVO__OriginalClass` (subclass of `__KVO__OriginalClass`) + * then unobserving with KVO will restore class to be `OriginalClass` -> failure point (possibly a bug in KVO) + + The reason why changing order of observing works is because any interception method on unregistration + should return object's original real class (if that doesn't happen then it's really easy to argue that's a bug + in that interception mechanism). + + This library won't remove registered interceptor even if there aren't any observers left because + it's highly unlikely it would have any benefit in real world use cases, and it's even more + dangerous. + */ + case objectMessagesAlreadyBeingIntercepted(target: AnyObject, interceptionMechanism: RxCocoaInterceptionMechanism) + + /** + Trying to observe messages for selector that isn't implemented. + */ + case selectorNotImplemented(target: AnyObject) + + /** + Core Foundation classes are usually toll free bridged. Those classes crash the program in case + `object_setClass` is performed on them. + + There is a possibility to just swizzle methods on original object, but since those won't be usual use + cases for this library, then an error will just be reported for now. + */ + case cantInterceptCoreFoundationTollFreeBridgedObjects(target: AnyObject) + + /** + Two libraries have simultaneously tried to modify ObjC runtime and that was detected. This can only + happen in scenarios where multiple interception libraries are used. + + To synchronize other libraries intercepting messages for an object, use `synchronized` on target object and + it's meta-class. + */ + case threadingCollisionWithOtherInterceptionMechanism(target: AnyObject) + + /** + For some reason saving original method implementation under RX namespace failed. + */ + case savingOriginalForwardingMethodFailed(target: AnyObject) + + /** + Intercepting a sent message by replacing a method implementation with `_objc_msgForward` failed for some reason. + */ + case replacingMethodWithForwardingImplementation(target: AnyObject) + + /** + Attempt to intercept one of the performance sensitive methods: + * class + * respondsToSelector: + * methodSignatureForSelector: + * forwardingTargetForSelector: + */ + case observingPerformanceSensitiveMessages(target: AnyObject) + + /** + Message implementation has unsupported return type (for example large struct). The reason why this is a error + is because in some cases intercepting sent messages requires replacing implementation with `_objc_msgForward_stret` + instead of `_objc_msgForward`. + + The unsupported cases should be fairly uncommon. + */ + case observingMessagesWithUnsupportedReturnType(target: AnyObject) +} + +#endif + +// MARK: Debug descriptions + +public extension RxCocoaError { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription: String { + switch self { + case .unknown: + return "Unknown error occurred." + case let .invalidOperation(object): + return "Invalid operation was attempted on `\(object)`." + case let .itemsNotYetBound(object): + return "Data source is set, but items are not yet bound to user interface for `\(object)`." + case let .invalidPropertyName(object, propertyName): + return "Object `\(object)` dosn't have a property named `\(propertyName)`." + case let .invalidObjectOnKeyPath(object, sourceObject, propertyName): + return "Unobservable object `\(object)` was observed as `\(propertyName)` of `\(sourceObject)`." + case .errorDuringSwizzling: + return "Error during swizzling." + case .castingError(let object, let targetType): + return "Error casting `\(object)` to `\(targetType)`" + } + } +} + +#if !DISABLE_SWIZZLING + +public extension RxCocoaObjCRuntimeError { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription: String { + switch self { + case let .unknown(target): + return "Unknown error occurred.\nTarget: `\(target)`" + case let .objectMessagesAlreadyBeingIntercepted(target, interceptionMechanism): + let interceptionMechanismDescription = interceptionMechanism == .kvo ? "KVO" : "other interception mechanism" + return "Collision between RxCocoa interception mechanism and \(interceptionMechanismDescription)." + + " To resolve this conflict please use this interception mechanism first.\nTarget: \(target)" + case let .selectorNotImplemented(target): + return "Trying to observe messages for selector that isn't implemented.\nTarget: \(target)" + case let .cantInterceptCoreFoundationTollFreeBridgedObjects(target): + return "Interception of messages sent to Core Foundation isn't supported.\nTarget: \(target)" + case let .threadingCollisionWithOtherInterceptionMechanism(target): + return "Detected a conflict while modifying ObjC runtime.\nTarget: \(target)" + case let .savingOriginalForwardingMethodFailed(target): + return "Saving original method implementation failed.\nTarget: \(target)" + case let .replacingMethodWithForwardingImplementation(target): + return "Intercepting a sent message by replacing a method implementation with `_objc_msgForward` failed for some reason.\nTarget: \(target)" + case let .observingPerformanceSensitiveMessages(target): + return "Attempt to intercept one of the performance sensitive methods. \nTarget: \(target)" + case let .observingMessagesWithUnsupportedReturnType(target): + return "Attempt to intercept a method with unsupported return type. \nTarget: \(target)" + } + } +} + +#endif + +// MARK: Error binding policies + +func bindingErrorToInterface(_ error: Swift.Error) { + let error = "Binding error to UI: \(error)" +#if DEBUG + rxFatalError(error) +#else + print(error) +#endif +} + +// MARK: Abstract methods + +func rxAbstractMethodWithMessage(_ message: String) -> Swift.Never { + rxFatalError(message) +} + +func rxAbstractMethod() -> Swift.Never { + rxFatalError("Abstract method") +} + +// MARK: casts or fatal error + +// workaround for Swift compiler bug, cheers compiler team :) +func castOptionalOrFatalError(_ value: Any?) -> T? { + if value == nil { + return nil + } + let v: T = castOrFatalError(value) + return v +} + +func castOrThrow(_ resultType: T.Type, _ object: Any) throws -> T { + guard let returnValue = object as? T else { + throw RxCocoaError.castingError(object: object, targetType: resultType) + } + + return returnValue +} + +func castOptionalOrThrow(_ resultType: T.Type, _ object: AnyObject) throws -> T? { + if NSNull().isEqual(object) { + return nil + } + + guard let returnValue = object as? T else { + throw RxCocoaError.castingError(object: object, targetType: resultType) + } + + return returnValue +} + +func castOrFatalError(_ value: AnyObject!, message: String) -> T { + let maybeResult: T? = value as? T + guard let result = maybeResult else { + rxFatalError(message) + } + + return result +} + +func castOrFatalError(_ value: Any!) -> T { + let maybeResult: T? = value as? T + guard let result = maybeResult else { + rxFatalError("Failure converting from \(value) to \(T.self)") + } + + return result +} + +// MARK: Error messages + +let dataSourceNotSet = "DataSource not set" +let delegateNotSet = "Delegate not set" + +#if !DISABLE_SWIZZLING + +// MARK: Conversions `NSError` > `RxCocoaObjCRuntimeError` + +extension Error { + func rxCocoaErrorForTarget(_ target: AnyObject) -> RxCocoaObjCRuntimeError { + let error = self as NSError + + if error.domain == RXObjCRuntimeErrorDomain { + let errorCode = RXObjCRuntimeError(rawValue: error.code) ?? .unknown + + switch errorCode { + case .unknown: + return .unknown(target: target) + case .objectMessagesAlreadyBeingIntercepted: + let isKVO = (error.userInfo[RXObjCRuntimeErrorIsKVOKey] as? NSNumber)?.boolValue ?? false + return .objectMessagesAlreadyBeingIntercepted(target: target, interceptionMechanism: isKVO ? .kvo : .unknown) + case .selectorNotImplemented: + return .selectorNotImplemented(target: target) + case .cantInterceptCoreFoundationTollFreeBridgedObjects: + return .cantInterceptCoreFoundationTollFreeBridgedObjects(target: target) + case .threadingCollisionWithOtherInterceptionMechanism: + return .threadingCollisionWithOtherInterceptionMechanism(target: target) + case .savingOriginalForwardingMethodFailed: + return .savingOriginalForwardingMethodFailed(target: target) + case .replacingMethodWithForwardingImplementation: + return .replacingMethodWithForwardingImplementation(target: target) + case .observingPerformanceSensitiveMessages: + return .observingPerformanceSensitiveMessages(target: target) + case .observingMessagesWithUnsupportedReturnType: + return .observingMessagesWithUnsupportedReturnType(target: target) + } + } + + return RxCocoaObjCRuntimeError.unknown(target: target) + } +} + +#endif + + +// MARK: Shared with RxSwift + +#if !RX_NO_MODULE + +func rxFatalError(_ lastMessage: String) -> Never { + // The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours. + fatalError(lastMessage) +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/Common/RxTarget.swift b/Pods/RxCocoa/RxCocoa/Common/RxTarget.swift new file mode 100644 index 0000000..62ce069 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/RxTarget.swift @@ -0,0 +1,44 @@ +// +// RxTarget.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 7/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif + +class RxTarget : NSObject + , Disposable { + + private var retainSelf: RxTarget? + + override init() { + super.init() + self.retainSelf = self + +#if TRACE_RESOURCES + OSAtomicIncrement32(&resourceCount) +#endif + +#if DEBUG + MainScheduler.ensureExecutingOnScheduler() +#endif + } + + func dispose() { +#if DEBUG + MainScheduler.ensureExecutingOnScheduler() +#endif + self.retainSelf = nil + } + +#if TRACE_RESOURCES + deinit { + OSAtomicDecrement32(&resourceCount) + } +#endif +} diff --git a/Pods/RxCocoa/RxCocoa/Common/SectionedViewDataSourceType.swift b/Pods/RxCocoa/RxCocoa/Common/SectionedViewDataSourceType.swift new file mode 100644 index 0000000..200fd9c --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/SectionedViewDataSourceType.swift @@ -0,0 +1,39 @@ +// +// SectionedViewDataSourceType.swift +// Rx +// +// Created by Krunoslav Zaher on 1/10/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Data source with access to underlying sectioned model. +*/ +public protocol SectionedViewDataSourceType { + /** + Returns model at index path. + + In case data source doesn't contain any sections when this method is being called, `RxCocoaError.ItemsNotYetBound(object: self)` is thrown. + + - parameter indexPath: Model index path + - returns: Model at index path. + */ + func model(_ indexPath: IndexPath) throws -> Any +} + +extension SectionedViewDataSourceType { + /** + Returns model at index path. + + In case data source doesn't contain any sections when this method is being called, `RxCocoaError.ItemsNotYetBound(object: self)` is thrown. + + - parameter indexPath: Model index path + - returns: Model at index path. + */ + @available(*, deprecated, renamed: "model(_:)") + func modelAtIndexPath(_ indexPath: IndexPath) throws -> Any { + return try self.model(indexPath) + } +} diff --git a/Pods/RxCocoa/RxCocoa/Common/TextInput.swift b/Pods/RxCocoa/RxCocoa/Common/TextInput.swift new file mode 100644 index 0000000..beb0e96 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/TextInput.swift @@ -0,0 +1,152 @@ +// +// TextInput.swift +// Rx +// +// Created by Krunoslav Zaher on 5/12/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if !RX_NO_MODULE + import RxSwift +#endif + +#if os(iOS) || os(tvOS) + import UIKit + + /** + Represents text input with reactive extensions. + */ + public struct TextInput { + /** + Base text input to extend. + */ + public let base: Base + + /** + Reactive wrapper for `text` property. + */ + public let text: ControlProperty + + /** + Initializes new text input. + + - parameter base: Base object. + - parameter text: Textual control property. + */ + public init(base: Base, text: ControlProperty) { + self.base = base + self.text = text + } + } + + extension Reactive where Base: UITextField { + /** + Reactive text input. + */ + public var textInput: TextInput { + return TextInput(base: base, text: self.text) + } + } + + extension Reactive where Base: UITextView { + /** + Reactive text input. + */ + public var textInput: TextInput { + return TextInput(base: base, text: self.text) + } + } + + /** + Represents text input with reactive extensions. + */ + @available(*, deprecated, renamed: "TextInput") + public protocol RxTextInput : UITextInput { + @available(*, deprecated, renamed: "rx.textInput.text") + var rx_text: ControlProperty { get } + } + + extension UITextField : RxTextInput { + @available(*, deprecated, renamed: "rx.textInput.text") + public var rx_text: ControlProperty { + return self.rx.text + } + } + + extension UITextView : RxTextInput { + @available(*, deprecated, renamed: "rx.textInput.text") + public var rx_text: ControlProperty { + return self.rx.text + } + } + + +#endif + +#if os(OSX) + import Cocoa + + /** + Represents text input with reactive extensions. + */ + public struct TextInput { + /** + Base text input to extend. + */ + public let base: Base + + /** + Reactive wrapper for `text` property. + */ + public let text: ControlProperty + + /** + Initializes new text input. + + - parameter base: Base object. + - parameter text: Textual control property. + */ + public init(base: Base, text: ControlProperty) { + self.base = base + self.text = text + } + } + + extension Reactive where Base: NSTextField { + /** + Reactive text input. + */ + public var textInput: TextInput { + return TextInput(base: base, text: self.text) + } + } + + /** + Represents text input with reactive extensions. + */ + @available(*, deprecated, renamed: "TextInput") + public protocol RxTextInput : NSTextInput { + + /** + Reactive wrapper for `text` property. + */ + @available(*, deprecated, renamed: "rx.textInput.text") + var rx_text: ControlProperty { get } + } + + @available(*, deprecated) + extension NSTextField : RxTextInput { + /** + Reactive wrapper for `text` property. + */ + @available(*, deprecated, renamed: "rx.textInput.text") + public var rx_text: ControlProperty { + return self.rx.text + } + } + +#endif + + diff --git a/Pods/RxCocoa/RxCocoa/Common/_RX.h b/Pods/RxCocoa/RxCocoa/Common/_RX.h new file mode 100644 index 0000000..cd61cf1 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/_RX.h @@ -0,0 +1,139 @@ +// +// _RX.h +// RxCocoa +// +// Created by Krunoslav Zaher on 7/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import +#import + +/** + ################################################################################ + This file is part of RX private API + ################################################################################ + */ + +#if TRACE_RESOURCES >= 2 +# define DLOG(...) NSLog(__VA_ARGS__) +#else +# define DLOG(...) +#endif + +#if DEBUG +# define ABORT_IN_DEBUG abort(); +#else +# define ABORT_IN_DEBUG +#endif + + +#define SEL_VALUE(x) [NSValue valueWithPointer:(x)] +#define CLASS_VALUE(x) [NSValue valueWithNonretainedObject:(x)] +#define IMP_VALUE(x) [NSValue valueWithPointer:(x)] + +/** + Checks that the local `error` instance exists before assigning it's value by reference. + This macro exists to work around static analysis warnings — `NSError` is always assumed to be `nullable`, even though we explictly define the method parameter as `nonnull`. See http://www.openradar.me/21766176 for more details. + */ +#define RX_SAFE_ERROR(errorValue) if (error != nil) { *error = (errorValue); } + +// Inspired by http://p99.gforge.inria.fr + +// https://gcc.gnu.org/onlinedocs/gcc-2.95.3/cpp_1.html#SEC26 +#define RX_CAT2(_1, _2) _RX_CAT2(_1, _2) + +#define RX_ELEMENT_AT(n, ...) RX_CAT2(_RX_ELEMENT_AT_, n)(__VA_ARGS__) + +#define RX_COUNT(...) RX_ELEMENT_AT(6, ## __VA_ARGS__, 6, 5, 4, 3, 2, 1, 0) + +/** + #define JOIN(context, index, head, tail) head; tail + #define APPLY(context, index, item) item = (context)[index] + + RX_FOR(A, JOIN, APPLY, toto, tutu); + + toto = (A)[0]; tutu = (A)[1]; + */ +#define RX_FOR(context, join, generate, ...) RX_CAT2( _RX_FOR_, RX_COUNT(__VA_ARGS__))(context, 0, join, generate, ## __VA_ARGS__) + +/** + #define JOIN(context, index, head, tail) head tail + #define APPLY(context, index, item) item = (context)[index] + + RX_FOR(A, JOIN, APPLY, toto, tutu); + + , toto = (A)[0], tutu = (A)[1] + */ +#define RX_FOR_COMMA(context, generate, ...) RX_CAT2( _RX_FOR_COMMA_, RX_COUNT(__VA_ARGS__))(context, 0, generate, ## __VA_ARGS__) + +#define RX_INC(x) RX_CAT2(_RX_INC_, x) + +// element at + +#define _RX_ELEMENT_AT_0(x, ...) x +#define _RX_ELEMENT_AT_1(_0, x, ...) x +#define _RX_ELEMENT_AT_2(_0, _1, x, ...) x +#define _RX_ELEMENT_AT_3(_0, _1, _2, x, ...) x +#define _RX_ELEMENT_AT_4(_0, _1, _2, _3, x, ...) x +#define _RX_ELEMENT_AT_5(_0, _1, _2, _3, _4, x, ...) x +#define _RX_ELEMENT_AT_6(_0, _1, _2, _3, _4, _5, x, ...) x + +// rx for + +#define _RX_FOR_0(context, index, join, generate) + +#define _RX_FOR_1(context, index, join, generate, head) \ + generate(context, index, head) + +#define _RX_FOR_2(context, index, join, generate, head, ...) \ + join(context, index, generate(context, index, head), _RX_FOR_1(context, RX_INC(index), join, generate, __VA_ARGS__)) + +#define _RX_FOR_3(context, index, join, generate, head, ...) \ + join(context, index, generate(context, index, head), _RX_FOR_2(context, RX_INC(index), join, generate, __VA_ARGS__)) + +#define _RX_FOR_4(context, index, join, generate, head, ...) \ + join(context, index, generate(context, index, head), _RX_FOR_3(context, RX_INC(index), join, generate, __VA_ARGS__)) + +#define _RX_FOR_5(context, index, join, generate, head, ...) \ + join(context, index, generate(context, index, head), _RX_FOR_4(context, RX_INC(index), join, generate, __VA_ARGS__)) + +#define _RX_FOR_6(context, index, join, generate, head, ...) \ + join(context, index, generate(context, index, head), _RX_FOR_5(context, RX_INC(index), join, generate, __VA_ARGS__)) + +// rx for + +#define _RX_FOR_COMMA_0(context, index, generate) + +#define _RX_FOR_COMMA_1(context, index, generate, head) \ + , generate(context, index, head) + +#define _RX_FOR_COMMA_2(context, index, generate, head, ...) \ + , generate(context, index, head) _RX_FOR_COMMA_1(context, RX_INC(index), generate, __VA_ARGS__) + +#define _RX_FOR_COMMA_3(context, index, generate, head, ...) \ + , generate(context, index, head) _RX_FOR_COMMA_2(context, RX_INC(index), generate, __VA_ARGS__) + +#define _RX_FOR_COMMA_4(context, index, generate, head, ...) \ + , generate(context, index, head) _RX_FOR_COMMA_3(context, RX_INC(index), generate, __VA_ARGS__) + +#define _RX_FOR_COMMA_5(context, index, generate, head, ...) \ + , generate(context, index, head) _RX_FOR_COMMA_4(context, RX_INC(index), generate, __VA_ARGS__) + +#define _RX_FOR_COMMA_6(context, index, generate, head, ...) \ + , generate(context, index, head) _RX_FOR_COMMA_5(context, RX_INC(index), generate, __VA_ARGS__) + + +// rx inc + +#define _RX_INC_0 1 +#define _RX_INC_1 2 +#define _RX_INC_2 3 +#define _RX_INC_3 4 +#define _RX_INC_4 5 +#define _RX_INC_5 6 +#define _RX_INC_6 7 + +// rx cat + +#define _RX_CAT2(_1, _2) _1 ## _2 \ No newline at end of file diff --git a/Pods/RxCocoa/RxCocoa/Common/_RX.m b/Pods/RxCocoa/RxCocoa/Common/_RX.m new file mode 100644 index 0000000..4c5ffe7 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/_RX.m @@ -0,0 +1,10 @@ +// +// _RX.m +// RxCocoa +// +// Created by Krunoslav Zaher on 7/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import "_RX.h" + diff --git a/Pods/RxCocoa/RxCocoa/Common/_RXDelegateProxy.h b/Pods/RxCocoa/RxCocoa/Common/_RXDelegateProxy.h new file mode 100644 index 0000000..523e7ae --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/_RXDelegateProxy.h @@ -0,0 +1,26 @@ +// +// _RXDelegateProxy.h +// RxCocoa +// +// Created by Krunoslav Zaher on 7/4/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface _RXDelegateProxy : NSObject + +@property (nonatomic, weak, readonly) id _forwardToDelegate; + +-(void)_setForwardToDelegate:(id __nullable)forwardToDelegate retainDelegate:(BOOL)retainDelegate; + +-(BOOL)hasWiredImplementationForSelector:(SEL)selector; + +-(void)_sentMessage:(SEL)selector withArguments:(NSArray*)arguments; +-(void)_methodInvoked:(SEL)selector withArguments:(NSArray*)arguments; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Pods/RxCocoa/RxCocoa/Common/_RXDelegateProxy.m b/Pods/RxCocoa/RxCocoa/Common/_RXDelegateProxy.m new file mode 100644 index 0000000..5cf7a5f --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/_RXDelegateProxy.m @@ -0,0 +1,153 @@ +// +// _RXDelegateProxy.m +// RxCocoa +// +// Created by Krunoslav Zaher on 7/4/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import "_RXDelegateProxy.h" +#import "_RX.h" +#import "_RXObjCRuntime.h" + +@interface _RXDelegateProxy () { + id __weak __forwardToDelegate; +} + +@property (nonatomic, strong) id strongForwardDelegate; + +@end + +static NSMutableDictionary *forwardableSelectorsPerClass = nil; + +@implementation _RXDelegateProxy + ++(NSSet*)collectSelectorsForProtocol:(Protocol *)protocol { + NSMutableSet *selectors = [NSMutableSet set]; + + unsigned int protocolMethodCount = 0; + struct objc_method_description *pMethods = protocol_copyMethodDescriptionList(protocol, NO, YES, &protocolMethodCount); + + for (unsigned int i = 0; i < protocolMethodCount; ++i) { + struct objc_method_description method = pMethods[i]; + if (RX_is_method_with_description_void(method)) { + [selectors addObject:SEL_VALUE(method.name)]; + } + } + + free(pMethods); + + unsigned int numberOfBaseProtocols = 0; + Protocol * __unsafe_unretained * pSubprotocols = protocol_copyProtocolList(protocol, &numberOfBaseProtocols); + + for (unsigned int i = 0; i < numberOfBaseProtocols; ++i) { + [selectors unionSet:[self collectSelectorsForProtocol:pSubprotocols[i]]]; + } + + free(pSubprotocols); + + return selectors; +} + ++(void)initialize { + @synchronized (_RXDelegateProxy.class) { + if (forwardableSelectorsPerClass == nil) { + forwardableSelectorsPerClass = [[NSMutableDictionary alloc] init]; + } + + NSMutableSet *allowedSelectors = [NSMutableSet set]; + +#define CLASS_HIERARCHY_MAX_DEPTH 100 + + NSInteger classHierarchyDepth = 0; + Class targetClass = NULL; + + for (classHierarchyDepth = 0, targetClass = self; + classHierarchyDepth < CLASS_HIERARCHY_MAX_DEPTH && targetClass != nil; + ++classHierarchyDepth, targetClass = class_getSuperclass(targetClass) + ) { + unsigned int count; + Protocol *__unsafe_unretained *pProtocols = class_copyProtocolList(targetClass, &count); + + for (unsigned int i = 0; i < count; i++) { + NSSet *selectorsForProtocol = [self collectSelectorsForProtocol:pProtocols[i]]; + [allowedSelectors unionSet:selectorsForProtocol]; + } + + free(pProtocols); + } + + if (classHierarchyDepth == CLASS_HIERARCHY_MAX_DEPTH) { + NSLog(@"Detected weird class hierarchy with depth over %d. Starting with this class -> %@", CLASS_HIERARCHY_MAX_DEPTH, self); +#if DEBUG + abort(); +#endif + } + + forwardableSelectorsPerClass[CLASS_VALUE(self)] = allowedSelectors; + } +} + +-(id)_forwardToDelegate { + return __forwardToDelegate; +} + +-(void)_setForwardToDelegate:(id __nullable)forwardToDelegate retainDelegate:(BOOL)retainDelegate { + __forwardToDelegate = forwardToDelegate; + if (retainDelegate) { + self.strongForwardDelegate = forwardToDelegate; + } + else { + self.strongForwardDelegate = nil; + } +} + +-(BOOL)hasWiredImplementationForSelector:(SEL)selector { + return [super respondsToSelector:selector]; +} + +-(BOOL)canRespondToSelector:(SEL)selector { + @synchronized(_RXDelegateProxy.class) { + NSSet *allowedMethods = forwardableSelectorsPerClass[CLASS_VALUE(self.class)]; + NSAssert(allowedMethods != nil, @"Set of allowed methods not initialized"); + return [allowedMethods containsObject:SEL_VALUE(selector)]; + } +} + +-(BOOL)respondsToSelector:(SEL)aSelector { + return [super respondsToSelector:aSelector] + || [self._forwardToDelegate respondsToSelector:aSelector] + || [self canRespondToSelector:aSelector]; +} + +-(void)forwardInvocation:(NSInvocation *)anInvocation { + BOOL isVoid = RX_is_method_signature_void(anInvocation.methodSignature); + NSArray *arguments = nil; + if (isVoid) { + arguments = RX_extract_arguments(anInvocation); + [self _sentMessage:anInvocation.selector withArguments:arguments]; + } + + if (self._forwardToDelegate && [self._forwardToDelegate respondsToSelector:anInvocation.selector]) { + [anInvocation invokeWithTarget:self._forwardToDelegate]; + } + + if (isVoid) { + [self _methodInvoked:anInvocation.selector withArguments:arguments]; + } +} + +// abstract method +-(void)_sentMessage:(SEL)selector withArguments:(NSArray *)arguments { + +} + +// abstract method +-(void)_methodInvoked:(SEL)selector withArguments:(NSArray *)arguments { + +} + +-(void)dealloc { +} + +@end diff --git a/Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.h b/Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.h new file mode 100644 index 0000000..adcfd0a --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.h @@ -0,0 +1,28 @@ +// +// _RXKVOObserver.h +// RxCocoa +// +// Created by Krunoslav Zaher on 7/11/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import + +/** + ################################################################################ + This file is part of RX private API + ################################################################################ + */ + +// Exists because if written in Swift, reading unowned is disabled during dealloc process +@interface _RXKVOObserver : NSObject + +-(instancetype)initWithTarget:(id)target + retainTarget:(BOOL)retainTarget + keyPath:(NSString*)keyPath + options:(NSKeyValueObservingOptions)options + callback:(void (^)(id))callback; + +-(void)dispose; + +@end diff --git a/Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.m b/Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.m new file mode 100644 index 0000000..4b60e4b --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/_RXKVOObserver.m @@ -0,0 +1,54 @@ +// +// _RXKVOObserver.m +// RxCocoa +// +// Created by Krunoslav Zaher on 7/11/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import "_RXKVOObserver.h" + +@interface _RXKVOObserver () + +@property (nonatomic, unsafe_unretained) id target; +@property (nonatomic, strong ) id retainedTarget; +@property (nonatomic, copy ) NSString *keyPath; +@property (nonatomic, copy ) void (^callback)(id); + +@end + +@implementation _RXKVOObserver + +-(instancetype)initWithTarget:(id)target + retainTarget:(BOOL)retainTarget + keyPath:(NSString*)keyPath + options:(NSKeyValueObservingOptions)options + callback:(void (^)(id))callback { + self = [super init]; + if (!self) return nil; + + self.target = target; + if (retainTarget) { + self.retainedTarget = target; + } + self.keyPath = keyPath; + self.callback = callback; + + [self.target addObserver:self forKeyPath:self.keyPath options:options context:nil]; + + return self; +} + +-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + @synchronized(self) { + self.callback(change[NSKeyValueChangeNewKey]); + } +} + +-(void)dispose { + [self.target removeObserver:self forKeyPath:self.keyPath context:nil]; + self.target = nil; + self.retainedTarget = nil; +} + +@end diff --git a/Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.h b/Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.h new file mode 100644 index 0000000..8d93063 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.h @@ -0,0 +1,128 @@ +// +// _RXObjCRuntime.h +// RxCocoa +// +// Created by Krunoslav Zaher on 7/11/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import + +#if !DISABLE_SWIZZLING + +/** + ################################################################################ + This file is part of RX private API + ################################################################################ + */ + +/** + This flag controls `RELEASE` configuration behavior in case race was detecting while modifying + ObjC runtime. + + In case this value is set to `YES`, after runtime race is detected, `abort()` will be called. + Otherwise, only error will be reported using normal error reporting mechanism. + + In `DEBUG` mode `abort` will be always called in case race is detected. + + Races can't happen in case this is the only library modifying ObjC runtime, but in case there are multiple libraries + changing ObjC runtime, race conditions can occur because there is no way to synchronize multiple libraries unaware of + each other. + + To help remedy this situation this library will use `synchronized` on target object and it's meta-class, but + there aren't any guarantees of how other libraries will behave. + + Default value is `NO`. + + */ +extern BOOL RXAbortOnThreadingHazard; + +/** + Error domain for RXObjCRuntime. + */ +extern NSString * __nonnull const RXObjCRuntimeErrorDomain; + +/** + `userInfo` key with additional information is interceptor probably KVO. + */ +extern NSString * __nonnull const RXObjCRuntimeErrorIsKVOKey; + +typedef NS_ENUM(NSInteger, RXObjCRuntimeError) { + RXObjCRuntimeErrorUnknown = 1, + RXObjCRuntimeErrorObjectMessagesAlreadyBeingIntercepted = 2, + RXObjCRuntimeErrorSelectorNotImplemented = 3, + RXObjCRuntimeErrorCantInterceptCoreFoundationTollFreeBridgedObjects = 4, + RXObjCRuntimeErrorThreadingCollisionWithOtherInterceptionMechanism = 5, + RXObjCRuntimeErrorSavingOriginalForwardingMethodFailed = 6, + RXObjCRuntimeErrorReplacingMethodWithForwardingImplementation = 7, + RXObjCRuntimeErrorObservingPerformanceSensitiveMessages = 8, + RXObjCRuntimeErrorObservingMessagesWithUnsupportedReturnType = 9, +}; + +/** + Transforms normal selector into a selector with RX prefix. + */ +SEL _Nonnull RX_selector(SEL _Nonnull selector); + +/** + Transforms selector into a unique pointer (because of Swift conversion rules) + */ +void * __nonnull RX_reference_from_selector(SEL __nonnull selector); + +/** + Protocol that interception observers must implement. + */ +@protocol RXMessageSentObserver + +/** + In case the same selector is being intercepted for a pair of base/sub classes, + this property will differentiate between interceptors that need to fire. + */ +@property (nonatomic, assign, readonly) IMP __nonnull targetImplementation; + +-(void)messageSentWithArguments:(NSArray* __nonnull)arguments; +-(void)methodInvokedWithArguments:(NSArray* __nonnull)arguments; + +@end + +/** + Protocol that deallocating observer must implement. + */ +@protocol RXDeallocatingObserver + +/** + In case the same selector is being intercepted for a pair of base/sub classes, + this property will differentiate between interceptors that need to fire. + */ +@property (nonatomic, assign, readonly) IMP __nonnull targetImplementation; + +-(void)deallocating; + +@end + +/** + Ensures interceptor is installed on target object. + */ +IMP __nullable RX_ensure_observing(id __nonnull target, SEL __nonnull selector, NSError *__nullable * __nonnull error); + +/** + Extracts arguments for `invocation`. + */ +NSArray * __nonnull RX_extract_arguments(NSInvocation * __nonnull invocation); + +/** + Returns `YES` in case method has `void` return type. + */ +BOOL RX_is_method_with_description_void(struct objc_method_description method); + +/** + Returns `YES` in case methodSignature has `void` return type. + */ +BOOL RX_is_method_signature_void(NSMethodSignature * __nonnull methodSignature); + +/** + Default value for `RXInterceptionObserver.targetImplementation`. + */ +IMP __nonnull RX_default_target_implementation(); + +#endif diff --git a/Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.m b/Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.m new file mode 100644 index 0000000..e3f16f4 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/Common/_RXObjCRuntime.m @@ -0,0 +1,1039 @@ +// +// _RXObjCRuntime.m +// RxCocoa +// +// Created by Krunoslav Zaher on 7/11/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import +#import +#import +#import +#import + +#import "_RX.h" +#import "_RXObjcRuntime.h" + +#if !DISABLE_SWIZZLING + +// self + cmd +#define HIDDEN_ARGUMENT_COUNT 2 + +@class RXObjCRuntime; + +BOOL RXAbortOnThreadingHazard = NO; + +typedef NSInvocation *NSInvocationRef; +typedef NSMethodSignature *NSMethodSignatureRef; +typedef unsigned char rx_uchar; +typedef unsigned short rx_ushort; +typedef unsigned int rx_uint; +typedef unsigned long rx_ulong; +typedef id (^rx_block)(id); +typedef BOOL (^RXInterceptWithOptimizedObserver)(RXObjCRuntime * __nonnull self, Class __nonnull class, SEL __nonnull selector, NSError ** __nonnull error); + +static CFTypeID defaultTypeID; +static SEL deallocSelector; + +static int RxSwizzlingTargetClassKey = 0; + +#if TRACE_RESOURCES +static int32_t numberOInterceptedMethods = 0; +static int32_t numberOfForwardedMethods = 0; +#endif + +#define THREADING_HAZARD(class) \ + NSLog(@"There was a problem swizzling on `%@`.\nYou have probably two libraries performing swizzling in runtime.\nWe didn't want to crash your program, but this is not good ...\nYou an solve this problem by either not using swizzling in this library, removing one of those other libraries, or making sure that swizzling parts are synchronized (only perform them on main thread).\nAnd yes, this message will self destruct when you clear the console, and since it's non deterministic, the problem could still exist and it will be hard for you to reproduce it.", NSStringFromClass(class)); ABORT_IN_DEBUG if (RXAbortOnThreadingHazard) { abort(); } + +#define ALWAYS(condition, message) if (!(condition)) { [NSException raise:@"RX Invalid Operator" format:@"%@", message]; } +#define ALWAYS_WITH_INFO(condition, message) NSAssert((condition), @"%@ [%@] > %@", NSStringFromClass(class), NSStringFromSelector(selector), (message)) +#define C_ALWAYS(condition, message) NSCAssert((condition), @"%@ [%@] > %@", NSStringFromClass(class), NSStringFromSelector(selector), (message)) + +#define RX_PREFIX @"_RX_namespace_" + +#define RX_ARG_id(value) ((value) ?: [NSNull null]) +#define RX_ARG_char(value) [NSNumber numberWithChar:value] +#define RX_ARG_short(value) [NSNumber numberWithShort:value] +#define RX_ARG_int(value) [NSNumber numberWithInt:value] +#define RX_ARG_long(value) [NSNumber numberWithLong:value] +#define RX_ARG_BOOL(value) [NSNumber numberWithBool:value] +#define RX_ARG_SEL(value) [NSNumber valueWithPointer:value] +#define RX_ARG_rx_uchar(value) [NSNumber numberWithUnsignedInt:value] +#define RX_ARG_rx_ushort(value) [NSNumber numberWithUnsignedInt:value] +#define RX_ARG_rx_uint(value) [NSNumber numberWithUnsignedInt:value] +#define RX_ARG_rx_ulong(value) [NSNumber numberWithUnsignedLong:value] +#define RX_ARG_rx_block(value) ((id)(value) ?: [NSNull null]) +#define RX_ARG_float(value) [NSNumber numberWithFloat:value] +#define RX_ARG_double(value) [NSNumber numberWithDouble:value] + +typedef struct supported_type { + const char *encoding; +} supported_type_t; + +static supported_type_t supported_types[] = { + { .encoding = @encode(void)}, + { .encoding = @encode(id)}, + { .encoding = @encode(Class)}, + { .encoding = @encode(void (^)())}, + { .encoding = @encode(char)}, + { .encoding = @encode(short)}, + { .encoding = @encode(int)}, + { .encoding = @encode(long)}, + { .encoding = @encode(long long)}, + { .encoding = @encode(unsigned char)}, + { .encoding = @encode(unsigned short)}, + { .encoding = @encode(unsigned int)}, + { .encoding = @encode(unsigned long)}, + { .encoding = @encode(unsigned long long)}, + { .encoding = @encode(float)}, + { .encoding = @encode(double)}, + { .encoding = @encode(BOOL)}, + { .encoding = @encode(const char*)}, +}; + +NSString * __nonnull const RXObjCRuntimeErrorDomain = @"RXObjCRuntimeErrorDomain"; +NSString * __nonnull const RXObjCRuntimeErrorIsKVOKey = @"RXObjCRuntimeErrorIsKVOKey"; + +BOOL RX_return_type_is_supported(const char *type) { + if (type == nil) { + return NO; + } + + for (int i = 0; i < sizeof(supported_types) / sizeof(supported_type_t); ++i) { + if (supported_types[i].encoding[0] != type[0]) { + continue; + } + if (strcmp(supported_types[i].encoding, type) == 0) { + return YES; + } + } + + return NO; +} + +static BOOL RX_method_has_supported_return_type(Method method) { + const char *rawEncoding = method_getTypeEncoding(method); + ALWAYS(rawEncoding != nil, @"Example encoding method is nil."); + + NSMethodSignature *methodSignature = [NSMethodSignature signatureWithObjCTypes:rawEncoding]; + ALWAYS(methodSignature != nil, @"Method signature method is nil."); + + return RX_return_type_is_supported(methodSignature.methodReturnType); +} + +SEL __nonnull RX_selector(SEL __nonnull selector) { + NSString *selectorString = NSStringFromSelector(selector); + return NSSelectorFromString([RX_PREFIX stringByAppendingString:selectorString]); +} + +BOOL RX_is_method_signature_void(NSMethodSignature * __nonnull methodSignature) { + const char *methodReturnType = methodSignature.methodReturnType; + return strcmp(methodReturnType, @encode(void)) == 0; +} + +BOOL RX_is_method_with_description_void(struct objc_method_description method) { + return strncmp(method.types, @encode(void), 1) == 0; +} + +// inspired by https://github.com/ReactiveCocoa/ReactiveCocoa/blob/swift-development/ReactiveCocoa/Objective-C/NSInvocation%2BRACTypeParsing.m +// awesome work +id __nonnull RX_extract_argument_at_index(NSInvocation * __nonnull invocation, NSUInteger index) { + const char *argumentType = [invocation.methodSignature getArgumentTypeAtIndex:index]; + +#define RETURN_VALUE(type) \ + else if (strcmp(argumentType, @encode(type)) == 0) {\ + type val = 0; \ + [invocation getArgument:&val atIndex:index]; \ + return @(val); \ + } + + // Skip const type qualifier. + if (argumentType[0] == 'r') { + argumentType++; + } + + if (strcmp(argumentType, @encode(id)) == 0 + || strcmp(argumentType, @encode(Class)) == 0 + || strcmp(argumentType, @encode(void (^)())) == 0 + ) { + __unsafe_unretained id argument = nil; + [invocation getArgument:&argument atIndex:index]; + return argument; + } + RETURN_VALUE(char) + RETURN_VALUE(short) + RETURN_VALUE(int) + RETURN_VALUE(long) + RETURN_VALUE(long long) + RETURN_VALUE(unsigned char) + RETURN_VALUE(unsigned short) + RETURN_VALUE(unsigned int) + RETURN_VALUE(unsigned long) + RETURN_VALUE(unsigned long long) + RETURN_VALUE(float) + RETURN_VALUE(double) + RETURN_VALUE(BOOL) + RETURN_VALUE(const char *) + else { + NSUInteger size = 0; + NSGetSizeAndAlignment(argumentType, &size, NULL); + NSCParameterAssert(size > 0); + uint8_t data[size]; + [invocation getArgument:&data atIndex:index]; + + return [NSValue valueWithBytes:&data objCType:argumentType]; + } +} + +NSArray *RX_extract_arguments(NSInvocation *invocation) { + NSUInteger numberOfArguments = invocation.methodSignature.numberOfArguments; + NSUInteger numberOfVisibleArguments = numberOfArguments - HIDDEN_ARGUMENT_COUNT; + + NSCParameterAssert(numberOfVisibleArguments >= 0); + + NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:numberOfVisibleArguments]; + + for (NSUInteger index = HIDDEN_ARGUMENT_COUNT; index < numberOfArguments; ++index) { + [arguments addObject:RX_extract_argument_at_index(invocation, index) ?: [NSNull null]]; + } + + return arguments; +} + +void * __nonnull RX_reference_from_selector(SEL __nonnull selector) { + return selector; +} + +static BOOL RX_forward_invocation(id __nonnull __unsafe_unretained self, NSInvocation *invocation) { + SEL originalSelector = RX_selector(invocation.selector); + + id messageSentObserver = objc_getAssociatedObject(self, originalSelector); + + if (messageSentObserver != nil) { + NSArray *arguments = RX_extract_arguments(invocation); + [messageSentObserver messageSentWithArguments:arguments]; + } + + if ([self respondsToSelector:originalSelector]) { + invocation.selector = originalSelector; + [invocation invokeWithTarget:self]; + + if (messageSentObserver != nil) { + NSArray *arguments = RX_extract_arguments(invocation); + [messageSentObserver methodInvokedWithArguments:arguments]; + } + + return YES; + } + + return NO; +} + +static BOOL RX_responds_to_selector(id __nonnull __unsafe_unretained self, SEL selector) { + Class class = object_getClass(self); + if (class == nil) { return NO; } + + Method m = class_getInstanceMethod(class, selector); + return m != nil; + +} + +static NSMethodSignatureRef RX_method_signature(id __nonnull __unsafe_unretained self, SEL selector) { + Class class = object_getClass(self); + if (class == nil) { return nil; } + + Method method = class_getInstanceMethod(class, selector); + if (method == nil) { return nil; } + + const char *encoding = method_getTypeEncoding(method); + if (encoding == nil) { return nil; } + + return [NSMethodSignature signatureWithObjCTypes:encoding]; +} + +static NSString * __nonnull RX_method_encoding(Method __nonnull method) { + const char *typeEncoding = method_getTypeEncoding(method); + ALWAYS(typeEncoding != nil, @"Method encoding is nil."); + + NSString *encoding = [NSString stringWithCString:typeEncoding encoding:NSASCIIStringEncoding]; + ALWAYS(encoding != nil, @"Can't convert encoding to NSString."); + return encoding; +} + +// inspired by +// https://github.com/mikeash/MAZeroingWeakRef/blob/master/Source/MAZeroingWeakRef.m +// https://github.com/ReactiveCocoa/ReactiveCocoa/blob/swift-development/ReactiveCocoa/Objective-C/NSObject%2BRACDeallocating.m +// https://github.com/steipete/Aspects +@interface RXObjCRuntime: NSObject + +@property (nonatomic, assign) pthread_mutex_t lock; + +@property (nonatomic, strong) NSMutableSet *classesThatSupportObservingByForwarding; +@property (nonatomic, strong) NSMutableDictionary *> *forwardedSelectorsByClass; + +@property (nonatomic, strong) NSMutableDictionary *dynamicSubclassByRealClass; +@property (nonatomic, strong) NSMutableDictionary*> *interceptorIMPbySelectorsByClass; + ++(RXObjCRuntime*)instance; + +-(void)performLocked:(void (^)(RXObjCRuntime* __nonnull))action; +-(IMP __nullable)ensurePrepared:(id __nonnull)target forObserving:(SEL __nonnull)selector error:(NSError** __nonnull)error; +-(BOOL)ensureSwizzledSelector:(SEL __nonnull)selector + ofClass:(Class __nonnull)class + newImplementationGenerator:(IMP(^)())newImplementationGenerator +replacementImplementationGenerator:(IMP (^)(IMP originalImplementation))replacementImplementationGenerator + error:(NSError ** __nonnull)error; + + ++(void)registerOptimizedObserver:(RXInterceptWithOptimizedObserver)registration encodedAs:(SEL)selector; + +@end + +/** + All API methods perform work on locked instance of `RXObjCRuntime`. In that way it's easy to prove + that every action is properly locked. + */ +IMP __nullable RX_ensure_observing(id __nonnull target, SEL __nonnull selector, NSError ** __nonnull error) { + __block IMP __nonnull targetImplementation = nil; + // Target is the second object that needs to be synchronized to TRY to make sure other swizzling framework + // won't do something in parallel. + // Even though this is too fine grained locking and more coarse grained locks should exist, this is just in case + // someone calls this method directly without any external lock. + @synchronized(target) { + // The only other resource that all other swizzling libraries have in common without introducing external + // dependencies is class object. + // + // It is polite to try to synchronize it in hope other unknown entities will also attempt to do so. + // It's like trying to figure out how to communicate with aliens without actually communicating, + // save for the fact that aliens are people, programmers, authors of swizzling libraries. + @synchronized([target class]) { + [[RXObjCRuntime instance] performLocked:^(RXObjCRuntime * __nonnull self) { + targetImplementation = [self ensurePrepared:target + forObserving:selector + error:error]; + }]; + } + } + + return targetImplementation; +} + +IMP __nonnull RX_default_target_implementation() { + return _objc_msgForward; +} + +// bodies + +#define FORWARD_BODY(invocation) if (RX_forward_invocation(self, NAME_CAT(_, 0, invocation))) { return; } + +#define RESPONDS_TO_SELECTOR_BODY(selector) if (RX_responds_to_selector(self, NAME_CAT(_, 0, selector))) return YES; + +#define CLASS_BODY(...) return actAsClass; + +#define METHOD_SIGNATURE_FOR_SELECTOR_BODY(selector) \ + NSMethodSignatureRef methodSignature = RX_method_signature(self, NAME_CAT(_, 0, selector)); \ + if (methodSignature != nil) { \ + return methodSignature; \ + } + +#define DEALLOCATING_BODY(...) \ + id observer = objc_getAssociatedObject(self, rxSelector); \ + if (observer != nil && observer.targetImplementation == thisIMP) { \ + [observer deallocating]; \ + } + +#define OBSERVE_BODY(...) \ + id observer = objc_getAssociatedObject(self, rxSelector); \ + \ + if (observer != nil && observer.targetImplementation == thisIMP) { \ + [observer messageSentWithArguments:@[COMMA_DELIMITED_ARGUMENTS(__VA_ARGS__)]]; \ + } \ + + +#define OBSERVE_INVOKED_BODY(...) \ + if (observer != nil && observer.targetImplementation == thisIMP) { \ + [observer methodInvokedWithArguments:@[COMMA_DELIMITED_ARGUMENTS(__VA_ARGS__)]]; \ + } \ + + +#define BUILD_ARG_WRAPPER(type) RX_ARG_ ## type //RX_ARG_ ## type + +#define CAT(_1, _2, head, tail) RX_CAT2(head, tail) +#define SEPARATE_BY_COMMA(_1, _2, head, tail) head, tail +#define SEPARATE_BY_SPACE(_1, _2, head, tail) head tail +#define SEPARATE_BY_UNDERSCORE(head, tail) RX_CAT2(RX_CAT2(head, _), tail) + +#define UNDERSCORE_TYPE_CAT(_1, index, type) RX_CAT2(_, type) // generates -> _type +#define NAME_CAT(_1, index, type) SEPARATE_BY_UNDERSCORE(type, index) // generates -> type_0 +#define TYPE_AND_NAME_CAT(_1, index, type) type SEPARATE_BY_UNDERSCORE(type, index) // generates -> type type_0 +#define NOT_NULL_ARGUMENT_CAT(_1, index, type) BUILD_ARG_WRAPPER(type)(NAME_CAT(_1, index, type)) // generates -> ((id)(type_0) ?: [NSNull null]) +#define EXAMPLE_PARAMETER(_1, index, type) RX_CAT2(_, type):(type)SEPARATE_BY_UNDERSCORE(type, index) // generates -> _type:(type)type_0 +#define SELECTOR_PART(_1, index, type) RX_CAT2(_, type:) // generates -> _type: + +#define COMMA_DELIMITED_ARGUMENTS(...) RX_FOR(_, SEPARATE_BY_COMMA, NOT_NULL_ARGUMENT_CAT, ## __VA_ARGS__) +#define ARGUMENTS(...) RX_FOR_COMMA(_, NAME_CAT, ## __VA_ARGS__) +#define DECLARE_ARGUMENTS(...) RX_FOR_COMMA(_, TYPE_AND_NAME_CAT, ## __VA_ARGS__) + +// optimized observe methods + +#define GENERATE_METHOD_IDENTIFIER(...) RX_CAT2(swizzle, RX_FOR(_, CAT, UNDERSCORE_TYPE_CAT, ## __VA_ARGS__)) + +#define GENERATE_OBSERVE_METHOD_DECLARATION(...) \ + -(BOOL)GENERATE_METHOD_IDENTIFIER(__VA_ARGS__):(Class __nonnull)class \ + selector:(SEL)selector \ + error:(NSError ** __nonnull)error { \ + + +#define BUILD_EXAMPLE_METHOD(return_value, ...) \ + +(return_value)RX_CAT2(RX_CAT2(example_, return_value), RX_FOR(_, SEPARATE_BY_SPACE, EXAMPLE_PARAMETER, ## __VA_ARGS__)) {} + +#define BUILD_EXAMPLE_METHOD_SELECTOR(return_value, ...) \ + RX_CAT2(RX_CAT2(example_, return_value), RX_FOR(_, SEPARATE_BY_SPACE, SELECTOR_PART, ## __VA_ARGS__)) + +#define SWIZZLE_OBSERVE_METHOD(return_value, ...) \ + @interface RXObjCRuntime (GENERATE_METHOD_IDENTIFIER(return_value, ## __VA_ARGS__)) \ + @end \ + \ + @implementation RXObjCRuntime(GENERATE_METHOD_IDENTIFIER(return_value, ## __VA_ARGS__)) \ + BUILD_EXAMPLE_METHOD(return_value, ## __VA_ARGS__) \ + SWIZZLE_METHOD(return_value, GENERATE_OBSERVE_METHOD_DECLARATION(return_value, ## __VA_ARGS__), OBSERVE_BODY, OBSERVE_INVOKED_BODY, ## __VA_ARGS__) \ + \ + +(void)load { \ + __unused SEL exampleSelector = @selector(BUILD_EXAMPLE_METHOD_SELECTOR(return_value, ## __VA_ARGS__)); \ + [self registerOptimizedObserver:^BOOL(RXObjCRuntime * __nonnull self, Class __nonnull class, \ + SEL __nonnull selector, NSError **__nonnull error) { \ + return [self GENERATE_METHOD_IDENTIFIER(return_value, ## __VA_ARGS__):class selector:selector error:error]; \ + } encodedAs:exampleSelector]; \ + } \ + \ + @end \ + +// infrastructure method + +#define NO_BODY(...) + +#define SWIZZLE_INFRASTRUCTURE_METHOD(return_value, method_name, parameters, method_selector, body, ...) \ + SWIZZLE_METHOD(return_value, -(BOOL)method_name:(Class __nonnull)class parameters error:(NSError **__nonnull)error \ + { \ + SEL selector = method_selector; , body, NO_BODY, __VA_ARGS__) \ + + +// common base + +#define SWIZZLE_METHOD(return_value, method_prototype, body, invoked_body, ...) \ +method_prototype \ + __unused SEL rxSelector = RX_selector(selector); \ + IMP (^newImplementationGenerator)() = ^() { \ + __block IMP thisIMP = nil; \ + id newImplementation = ^return_value(__unsafe_unretained id self DECLARE_ARGUMENTS(__VA_ARGS__)) { \ + body(__VA_ARGS__) \ + \ + struct objc_super superInfo = { \ + .receiver = self, \ + .super_class = class_getSuperclass(class) \ + }; \ + \ + return_value (*msgSend)(struct objc_super *, SEL DECLARE_ARGUMENTS(__VA_ARGS__)) \ + = (__typeof__(msgSend))objc_msgSendSuper; \ + @try { \ + return msgSend(&superInfo, selector ARGUMENTS(__VA_ARGS__)); \ + } \ + @finally { invoked_body(__VA_ARGS__) } \ + }; \ + \ + thisIMP = imp_implementationWithBlock(newImplementation); \ + return thisIMP; \ + }; \ + \ + IMP (^replacementImplementationGenerator)(IMP) = ^(IMP originalImplementation) { \ + __block return_value (*originalImplementationTyped)(__unsafe_unretained id, SEL DECLARE_ARGUMENTS(__VA_ARGS__) ) \ + = (__typeof__(originalImplementationTyped))(originalImplementation); \ + \ + __block IMP thisIMP = nil; \ + id implementationReplacement = ^return_value(__unsafe_unretained id self DECLARE_ARGUMENTS(__VA_ARGS__) ) { \ + body(__VA_ARGS__) \ + @try { \ + return originalImplementationTyped(self, selector ARGUMENTS(__VA_ARGS__)); \ + } \ + @finally { invoked_body(__VA_ARGS__) } \ + }; \ + \ + thisIMP = imp_implementationWithBlock(implementationReplacement); \ + return thisIMP; \ + }; \ + \ + return [self ensureSwizzledSelector:selector \ + ofClass:class \ + newImplementationGenerator:newImplementationGenerator \ + replacementImplementationGenerator:replacementImplementationGenerator \ + error:error]; \ + } \ + + +@interface RXObjCRuntime (InfrastructureMethods) +@end + +// MARK: Infrastructure Methods + +@implementation RXObjCRuntime (InfrastructureMethods) + +SWIZZLE_INFRASTRUCTURE_METHOD( + void, + swizzleForwardInvocation, + , + @selector(forwardInvocation:), + FORWARD_BODY, + NSInvocationRef +) +SWIZZLE_INFRASTRUCTURE_METHOD( + BOOL, + swizzleRespondsToSelector, + , + @selector(respondsToSelector:), + RESPONDS_TO_SELECTOR_BODY, + SEL +) +SWIZZLE_INFRASTRUCTURE_METHOD( + Class __nonnull, + swizzleClass, + toActAs:(Class)actAsClass, + @selector(class), + CLASS_BODY +) +SWIZZLE_INFRASTRUCTURE_METHOD( + NSMethodSignatureRef, + swizzleMethodSignatureForSelector, + , + @selector(methodSignatureForSelector:), + METHOD_SIGNATURE_FOR_SELECTOR_BODY, + SEL +) +SWIZZLE_INFRASTRUCTURE_METHOD( + void, + swizzleDeallocating, + , + deallocSelector, + DEALLOCATING_BODY +) + +@end + +// MARK: Optimized intercepting methods for specific combination of parameter types + +SWIZZLE_OBSERVE_METHOD(void) + +SWIZZLE_OBSERVE_METHOD(void, id) +SWIZZLE_OBSERVE_METHOD(void, char) +SWIZZLE_OBSERVE_METHOD(void, short) +SWIZZLE_OBSERVE_METHOD(void, int) +SWIZZLE_OBSERVE_METHOD(void, long) +SWIZZLE_OBSERVE_METHOD(void, rx_uchar) +SWIZZLE_OBSERVE_METHOD(void, rx_ushort) +SWIZZLE_OBSERVE_METHOD(void, rx_uint) +SWIZZLE_OBSERVE_METHOD(void, rx_ulong) +SWIZZLE_OBSERVE_METHOD(void, rx_block) +SWIZZLE_OBSERVE_METHOD(void, float) +SWIZZLE_OBSERVE_METHOD(void, double) +SWIZZLE_OBSERVE_METHOD(void, SEL) + +SWIZZLE_OBSERVE_METHOD(void, id, id) +SWIZZLE_OBSERVE_METHOD(void, id, char) +SWIZZLE_OBSERVE_METHOD(void, id, short) +SWIZZLE_OBSERVE_METHOD(void, id, int) +SWIZZLE_OBSERVE_METHOD(void, id, long) +SWIZZLE_OBSERVE_METHOD(void, id, rx_uchar) +SWIZZLE_OBSERVE_METHOD(void, id, rx_ushort) +SWIZZLE_OBSERVE_METHOD(void, id, rx_uint) +SWIZZLE_OBSERVE_METHOD(void, id, rx_ulong) +SWIZZLE_OBSERVE_METHOD(void, id, rx_block) +SWIZZLE_OBSERVE_METHOD(void, id, float) +SWIZZLE_OBSERVE_METHOD(void, id, double) +SWIZZLE_OBSERVE_METHOD(void, id, SEL) + +// MARK: RXObjCRuntime + +@implementation RXObjCRuntime + +static RXObjCRuntime *_instance = nil; +static NSMutableDictionary *optimizedObserversByMethodEncoding = nil; + ++(RXObjCRuntime*)instance { + return _instance; +} + ++(void)initialize { + _instance = [[RXObjCRuntime alloc] init]; + defaultTypeID = CFGetTypeID((CFTypeRef)RXObjCRuntime.class); // just need a reference of some object not from CF + deallocSelector = NSSelectorFromString(@"dealloc"); + NSAssert(_instance != nil, @"Failed to initialize swizzling"); +} + +-(instancetype)init { + self = [super init]; + if (!self) return nil; + + self.classesThatSupportObservingByForwarding = [NSMutableSet set]; + self.forwardedSelectorsByClass = [NSMutableDictionary dictionary]; + + self.dynamicSubclassByRealClass = [NSMutableDictionary dictionary]; + self.interceptorIMPbySelectorsByClass = [NSMutableDictionary dictionary]; + + pthread_mutexattr_t lock_attr; + pthread_mutexattr_init(&lock_attr); + pthread_mutexattr_settype(&lock_attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&_lock, &lock_attr); + pthread_mutexattr_destroy(&lock_attr); + + return self; +} + +-(void)performLocked:(void (^)(RXObjCRuntime* __nonnull))action { + pthread_mutex_lock(&_lock); + action(self); + pthread_mutex_unlock(&_lock); +} + ++(void)registerOptimizedObserver:(RXInterceptWithOptimizedObserver)registration encodedAs:(SEL)selector { + Method exampleEncodingMethod = class_getClassMethod(self, selector); + ALWAYS(exampleEncodingMethod != nil, @"Example encoding method is nil."); + + NSString *methodEncoding = RX_method_encoding(exampleEncodingMethod); + + if (optimizedObserversByMethodEncoding == nil) { + optimizedObserversByMethodEncoding = [NSMutableDictionary dictionary]; + } + + DLOG(@"Added optimized method: %@ (%@)", methodEncoding, NSStringFromSelector(selector)); + ALWAYS(optimizedObserversByMethodEncoding[methodEncoding] == nil, @"Optimized observer already registered") + optimizedObserversByMethodEncoding[methodEncoding] = registration; +} + +/** + This is the main entry point for observing messages sent to arbitrary objects. + */ +-(IMP __nullable)ensurePrepared:(id __nonnull)target forObserving:(SEL __nonnull)selector error:(NSError** __nonnull)error { + Method instanceMethod = class_getInstanceMethod([target class], selector); + if (instanceMethod == nil) { + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorSelectorNotImplemented + userInfo:nil]); + return nil; + } + + if (selector == @selector(class) + || selector == @selector(forwardingTargetForSelector:) + || selector == @selector(methodSignatureForSelector:) + || selector == @selector(respondsToSelector:)) { + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorObservingPerformanceSensitiveMessages + userInfo:nil]); + return nil; + } + + // For `dealloc` message, original implementation will be swizzled. + // This is a special case because observing `dealloc` message is performed when `observeWeakly` is used. + // + // Some toll free bridged classes don't handle `object_setClass` well and cause crashes. + // + // To make `deallocating` as robust as possible, original implementation will be replaced. + if (selector == deallocSelector) { + Class __nonnull deallocSwizzingTarget = [target class]; + IMP interceptorIMPForSelector = [self interceptorImplementationForSelector:selector forClass:deallocSwizzingTarget]; + if (interceptorIMPForSelector != nil) { + return interceptorIMPForSelector; + } + + if (![self swizzleDeallocating:deallocSwizzingTarget error:error]) { + return nil; + } + + interceptorIMPForSelector = [self interceptorImplementationForSelector:selector forClass:deallocSwizzingTarget]; + if (interceptorIMPForSelector != nil) { + return interceptorIMPForSelector; + } + } + else { + Class __nullable swizzlingImplementorClass = [self prepareTargetClassForObserving:target error:error]; + if (swizzlingImplementorClass == nil) { + return nil; + } + + NSString *methodEncoding = RX_method_encoding(instanceMethod); + RXInterceptWithOptimizedObserver optimizedIntercept = optimizedObserversByMethodEncoding[methodEncoding]; + + if (!RX_method_has_supported_return_type(instanceMethod)) { + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorObservingMessagesWithUnsupportedReturnType + userInfo:nil]); + + return nil; + } + + // optimized interception method + if (optimizedIntercept != nil) { + IMP interceptorIMPForSelector = [self interceptorImplementationForSelector:selector forClass:swizzlingImplementorClass]; + if (interceptorIMPForSelector != nil) { + return interceptorIMPForSelector; + } + + if (!optimizedIntercept(self, swizzlingImplementorClass, selector, error)) { + return nil; + } + + interceptorIMPForSelector = [self interceptorImplementationForSelector:selector forClass:swizzlingImplementorClass]; + if (interceptorIMPForSelector != nil) { + return interceptorIMPForSelector; + } + } + // default fallback to observing by forwarding messages + else { + if ([self forwardingSelector:selector forClass:swizzlingImplementorClass]) { + return RX_default_target_implementation(); + } + + if (![self observeByForwardingMessages:swizzlingImplementorClass + selector:selector + target:target + error:error]) { + return nil; + } + + if ([self forwardingSelector:selector forClass:swizzlingImplementorClass]) { + return RX_default_target_implementation(); + } + } + } + + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorUnknown + userInfo:nil]); + + return nil; +} + +-(Class __nullable)prepareTargetClassForObserving:(id __nonnull)target error:(NSError **__nonnull)error { + Class swizzlingClass = objc_getAssociatedObject(target, &RxSwizzlingTargetClassKey); + if (swizzlingClass != nil) { + return swizzlingClass; + } + + Class __nonnull wannaBeClass = [target class]; + /** + Core Foundation classes are usually toll free bridged. Those classes crash the program in case + `object_setClass` is performed on them. + + There is a possibility to just swizzle methods on original object, but since those won't be usual use + cases for this library, then an error will just be reported for now. + */ + BOOL isThisTollFreeFoundationClass = CFGetTypeID((CFTypeRef)target) != defaultTypeID; + + if (isThisTollFreeFoundationClass) { + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorCantInterceptCoreFoundationTollFreeBridgedObjects + userInfo:nil]); + return nil; + } + + /** + If the object is reporting a different class then what it's real class, that means that there is probably + already some interception mechanism in place or something weird is happening. + + Most common case when this would happen is when using KVO (`observe`) and `sentMessage`. + + This error is easily resolved by just using `sentMessage` observing before `observe`. + + The reason why other way around could create issues is because KVO will unregister it's interceptor + class and restore original class. Unfortunately that will happen no matter was there another interceptor + subclass registered in hierarchy or not. + + Failure scenario: + * KVO sets class to be `__KVO__OriginalClass` (subclass of `OriginalClass`) + * `sentMessage` sets object class to be `_RX_namespace___KVO__OriginalClass` (subclass of `__KVO__OriginalClass`) + * then unobserving with KVO will restore class to be `OriginalClass` -> failure point + + The reason why changing order of observing works is because any interception method should return + object's original real class (if that doesn't happen then it's really easy to argue that's a bug + in that other library). + + This library won't remove registered interceptor even if there aren't any observers left because + it's highly unlikely it would have any benefit in real world use cases, and it's even more + dangerous. + */ + if ([target class] != object_getClass(target)) { + BOOL isKVO = [target respondsToSelector:NSSelectorFromString(@"_isKVOA")]; + + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorObjectMessagesAlreadyBeingIntercepted + userInfo:@{ + RXObjCRuntimeErrorIsKVOKey : @(isKVO) + }]); + return nil; + } + + Class __nullable dynamicFakeSubclass = [self ensureHasDynamicFakeSubclass:wannaBeClass error:error]; + + if (dynamicFakeSubclass == nil) { + return nil; + } + + Class previousClass = object_setClass(target, dynamicFakeSubclass); + if (previousClass != wannaBeClass) { + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorThreadingCollisionWithOtherInterceptionMechanism + userInfo:nil]); + THREADING_HAZARD(wannaBeClass); + return nil; + } + + objc_setAssociatedObject(target, &RxSwizzlingTargetClassKey, dynamicFakeSubclass, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + return dynamicFakeSubclass; +} + + +-(BOOL)forwardingSelector:(SEL)selector forClass:(Class __nonnull)class { + return [self.forwardedSelectorsByClass[CLASS_VALUE(class)] containsObject:SEL_VALUE(selector)]; +} + +-(void)registerForwardedSelector:(SEL)selector forClass:(Class __nonnull)class { + NSValue *classValue = CLASS_VALUE(class); + + NSMutableSet *forwardedSelectors = self.forwardedSelectorsByClass[classValue]; + + if (forwardedSelectors == nil) { + forwardedSelectors = [NSMutableSet set]; + self.forwardedSelectorsByClass[classValue] = forwardedSelectors; + } + + [forwardedSelectors addObject:SEL_VALUE(selector)]; +} + +-(BOOL)observeByForwardingMessages:(Class __nonnull)swizzlingImplementorClass + selector:(SEL)selector + target:(id __nonnull)target + error:(NSError **__nonnull)error { + if (![self ensureForwardingMethodsAreSwizzled:swizzlingImplementorClass error:error]) { + return NO; + } + + ALWAYS(![self forwardingSelector:selector forClass:swizzlingImplementorClass], @"Already observing selector for class"); + +#if TRACE_RESOURCES + OSAtomicIncrement32(&numberOfForwardedMethods); +#endif + SEL rxSelector = RX_selector(selector); + + Method instanceMethod = class_getInstanceMethod(swizzlingImplementorClass, selector); + ALWAYS(instanceMethod != nil, @"Instance method is nil"); + + const char* methodEncoding = method_getTypeEncoding(instanceMethod); + ALWAYS(methodEncoding != nil, @"Method encoding is nil."); + NSMethodSignature *methodSignature = [NSMethodSignature signatureWithObjCTypes:methodEncoding]; + ALWAYS(methodSignature != nil, @"Method signature is invalid."); + + IMP implementation = method_getImplementation(instanceMethod); + + if (implementation == nil) { + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorSelectorNotImplemented + userInfo:nil]); + + return NO; + } + + if (!class_addMethod(swizzlingImplementorClass, rxSelector, implementation, methodEncoding)) { + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorSavingOriginalForwardingMethodFailed + userInfo:nil]); + return NO; + } + + if (!class_addMethod(swizzlingImplementorClass, selector, _objc_msgForward, methodEncoding)) { + if (implementation != method_setImplementation(instanceMethod, _objc_msgForward)) { + RX_SAFE_ERROR([NSError errorWithDomain:RXObjCRuntimeErrorDomain + code:RXObjCRuntimeErrorReplacingMethodWithForwardingImplementation + userInfo:nil]); + THREADING_HAZARD(swizzlingImplementorClass); + return NO; + } + } + + DLOG(@"Rx uses forwarding to observe `%@` for `%@`.", NSStringFromSelector(selector), swizzlingImplementorClass); + [self registerForwardedSelector:selector forClass:swizzlingImplementorClass]; + + return YES; +} + +/** + If object don't have some weird behavior, claims it's the same class that runtime shows, + then dynamic subclass is created (only this instance will have performance hit). + + In case something weird is detected, then original base class is being swizzled and all instances + will have somewhat reduced performance. + + This is especially handy optimization for weak KVO. Nobody will swizzle for example `NSString`, + but to know when instance of a `NSString` was deallocated, performance hit will be only felt on a + single instance of `NSString`, not all instances of `NSString`s. + */ +-(Class __nullable)ensureHasDynamicFakeSubclass:(Class __nonnull)class error:(NSError **)error { + Class dynamicFakeSubclass = self.dynamicSubclassByRealClass[CLASS_VALUE(class)]; + if (dynamicFakeSubclass != nil) { + return dynamicFakeSubclass; + } + + NSString *dynamicFakeSubclassName = [RX_PREFIX stringByAppendingString:NSStringFromClass(class)]; + const char *dynamicFakeSubclassNameRaw = dynamicFakeSubclassName.UTF8String; + dynamicFakeSubclass = objc_allocateClassPair(class, dynamicFakeSubclassNameRaw, 0); + ALWAYS(dynamicFakeSubclass != nil, @"Class not generated"); + + if (![self swizzleClass:dynamicFakeSubclass toActAs:class error:error]) { + return nil; + } + + objc_registerClassPair(dynamicFakeSubclass); + + [self.dynamicSubclassByRealClass setObject:dynamicFakeSubclass forKey:CLASS_VALUE(class)]; + ALWAYS(self.dynamicSubclassByRealClass[CLASS_VALUE(class)] != nil, @"Class not registered"); + + return dynamicFakeSubclass; +} + +-(BOOL)ensureForwardingMethodsAreSwizzled:(Class __nonnull)class error:(NSError ** __nonnull)error { + NSValue *classValue = CLASS_VALUE(class); + if ([self.classesThatSupportObservingByForwarding containsObject:classValue]) { + return YES; + } + + if (![self swizzleForwardInvocation:class error:error]) { return NO; } + if (![self swizzleMethodSignatureForSelector:class error:error]) { return NO; } + if (![self swizzleRespondsToSelector:class error:error]) { return NO; } + + [self.classesThatSupportObservingByForwarding addObject:classValue]; + + return YES; +} + +-(void)registerInterceptedSelector:(SEL)selector implementation:(IMP)implementation forClass:(Class)class { + NSValue * __nonnull classValue = CLASS_VALUE(class); + NSValue * __nonnull selectorValue = SEL_VALUE(selector); + + NSMutableDictionary *swizzledIMPBySelectorsForClass = self.interceptorIMPbySelectorsByClass[classValue]; + + if (swizzledIMPBySelectorsForClass == nil) { + swizzledIMPBySelectorsForClass = [NSMutableDictionary dictionary]; + self.interceptorIMPbySelectorsByClass[classValue] = swizzledIMPBySelectorsForClass; + } + + swizzledIMPBySelectorsForClass[selectorValue] = IMP_VALUE(implementation); + + ALWAYS([self interceptorImplementationForSelector:selector forClass:class] != nil, @"Class should have been swizzled"); +} + +-(IMP)interceptorImplementationForSelector:(SEL)selector forClass:(Class)class { + NSValue * __nonnull classValue = CLASS_VALUE(class); + NSValue * __nonnull selectorValue = SEL_VALUE(selector); + + NSMutableDictionary *swizzledIMPBySelectorForClass = self.interceptorIMPbySelectorsByClass[classValue]; + + NSValue *impValue = swizzledIMPBySelectorForClass[selectorValue]; + return impValue.pointerValue; +} + +-(BOOL)ensureSwizzledSelector:(SEL __nonnull)selector + ofClass:(Class __nonnull)class + newImplementationGenerator:(IMP(^)())newImplementationGenerator +replacementImplementationGenerator:(IMP (^)(IMP originalImplementation))replacementImplementationGenerator + error:(NSError ** __nonnull)error { + if ([self interceptorImplementationForSelector:selector forClass:class] != nil) { + DLOG(@"Trying to register same intercept at least once, this sounds like a possible bug"); + return YES; + } + +#if TRACE_RESOURCES + OSAtomicIncrement32(&numberOInterceptedMethods); +#endif + + DLOG(@"Rx is swizzling `%@` for `%@`", NSStringFromSelector(selector), class); + + Method existingMethod = class_getInstanceMethod(class, selector); + ALWAYS(existingMethod != nil, @"Method doesn't exist"); + + const char *encoding = method_getTypeEncoding(existingMethod); + ALWAYS(encoding != nil, @"Encoding is nil"); + + IMP newImplementation = newImplementationGenerator(); + + if (class_addMethod(class, selector, newImplementation, encoding)) { + // new method added, job done + [self registerInterceptedSelector:selector implementation:newImplementation forClass:class]; + + return YES; + } + + imp_removeBlock(newImplementation); + + // if add fails, that means that method already exists on targetClass + Method existingMethodOnTargetClass = existingMethod; + + IMP originalImplementation = method_getImplementation(existingMethodOnTargetClass); + ALWAYS(originalImplementation != nil, @"Method must exist."); + IMP implementationReplacementIMP = replacementImplementationGenerator(originalImplementation); + ALWAYS(implementationReplacementIMP != nil, @"Method must exist."); + IMP originalImplementationAfterChange = method_setImplementation(existingMethodOnTargetClass, implementationReplacementIMP); + ALWAYS(originalImplementation != nil, @"Method must exist."); + + // If method replacing failed, who knows what happened, better not trying again, otherwise program can get + // corrupted. + [self registerInterceptedSelector:selector implementation:implementationReplacementIMP forClass:class]; + + // ¯\_(ツ)_/¯ + if (originalImplementationAfterChange != originalImplementation) { + THREADING_HAZARD(class); + return NO; + } + + return YES; +} + +@end + +#if TRACE_RESOURCES + +NSInteger RX_number_of_dynamic_subclasses() { + __block NSInteger count = 0; + [[RXObjCRuntime instance] performLocked:^(RXObjCRuntime * __nonnull self) { + count = self.dynamicSubclassByRealClass.count; + }]; + + return count; +} + +NSInteger RX_number_of_forwarding_enabled_classes() { + __block NSInteger count = 0; + [[RXObjCRuntime instance] performLocked:^(RXObjCRuntime * __nonnull self) { + count = self.classesThatSupportObservingByForwarding.count; + }]; + + return count; +} + +NSInteger RX_number_of_intercepting_classes() { + __block NSInteger count = 0; + [[RXObjCRuntime instance] performLocked:^(RXObjCRuntime * __nonnull self) { + count = self.interceptorIMPbySelectorsByClass.count; + }]; + + return count; +} + +NSInteger RX_number_of_forwarded_methods() { + return numberOfForwardedMethods; +} + +NSInteger RX_number_of_swizzled_methods() { + return numberOInterceptedMethods; +} + +#endif + +#endif diff --git a/Pods/RxCocoa/RxCocoa/RxCocoa.h b/Pods/RxCocoa/RxCocoa/RxCocoa.h new file mode 100644 index 0000000..7436904 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/RxCocoa.h @@ -0,0 +1,19 @@ +// +// RxCocoa.h +// RxCocoa +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#import +#import "_RX.h" +#import "_RXDelegateProxy.h" +#import "_RXKVOObserver.h" +#import "_RXObjCRuntime.h" + +//! Project version number for RxCocoa. +FOUNDATION_EXPORT double RxCocoaVersionNumber; + +//! Project version string for RxCocoa. +FOUNDATION_EXPORT const unsigned char RxCocoaVersionString[]; \ No newline at end of file diff --git a/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift b/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift new file mode 100644 index 0000000..b8f139d --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxCollectionViewReactiveArrayDataSource.swift @@ -0,0 +1,108 @@ +// +// RxCollectionViewReactiveArrayDataSource.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +// objc monkey business +class _RxCollectionViewReactiveArrayDataSource + : NSObject + , UICollectionViewDataSource { + + @objc(numberOfSectionsInCollectionView:) + func numberOfSections(in: UICollectionView) -> Int { + return 1 + } + + func _collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 0 + } + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return _collectionView(collectionView, numberOfItemsInSection: section) + } + + fileprivate func _collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + rxAbstractMethod() + } + + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + return _collectionView(collectionView, cellForItemAt: indexPath) + } +} + +class RxCollectionViewReactiveArrayDataSourceSequenceWrapper + : RxCollectionViewReactiveArrayDataSource + , RxCollectionViewDataSourceType { + typealias Element = S + + override init(cellFactory: @escaping CellFactory) { + super.init(cellFactory: cellFactory) + } + + func collectionView(_ collectionView: UICollectionView, observedEvent: Event) { + UIBindingObserver(UIElement: self) { collectionViewDataSource, sectionModels in + let sections = Array(sectionModels) + collectionViewDataSource.collectionView(collectionView, observedElements: sections) + }.on(observedEvent) + } +} + + +// Please take a look at `DelegateProxyType.swift` +class RxCollectionViewReactiveArrayDataSource + : _RxCollectionViewReactiveArrayDataSource + , SectionedViewDataSourceType { + + typealias CellFactory = (UICollectionView, Int, Element) -> UICollectionViewCell + + var itemModels: [Element]? = nil + + func modelAtIndex(_ index: Int) -> Element? { + return itemModels?[index] + } + + func model(_ indexPath: IndexPath) throws -> Any { + precondition(indexPath.section == 0) + guard let item = itemModels?[indexPath.item] else { + throw RxCocoaError.itemsNotYetBound(object: self) + } + return item + } + + var cellFactory: CellFactory + + init(cellFactory: @escaping CellFactory) { + self.cellFactory = cellFactory + } + + // data source + + override func _collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return itemModels?.count ?? 0 + } + + override func _collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + return cellFactory(collectionView, indexPath.item, itemModels![indexPath.item]) + } + + // reactive + + func collectionView(_ collectionView: UICollectionView, observedElements: [Element]) { + self.itemModels = observedElements + + collectionView.reloadData() + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift b/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift new file mode 100644 index 0000000..db2db94 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/DataSources/RxTableViewReactiveArrayDataSource.swift @@ -0,0 +1,104 @@ +// +// RxTableViewReactiveArrayDataSource.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/26/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +// objc monkey business +class _RxTableViewReactiveArrayDataSource + : NSObject + , UITableViewDataSource { + + func numberOfSections(in tableView: UITableView) -> Int { + return 1 + } + + func _tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 0 + } + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return _tableView(tableView, numberOfRowsInSection: section) + } + + fileprivate func _tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + rxAbstractMethod() + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return _tableView(tableView, cellForRowAt: indexPath) + } +} + + +class RxTableViewReactiveArrayDataSourceSequenceWrapper + : RxTableViewReactiveArrayDataSource + , RxTableViewDataSourceType { + typealias Element = S + + override init(cellFactory: @escaping CellFactory) { + super.init(cellFactory: cellFactory) + } + + func tableView(_ tableView: UITableView, observedEvent: Event) { + UIBindingObserver(UIElement: self) { tableViewDataSource, sectionModels in + let sections = Array(sectionModels) + tableViewDataSource.tableView(tableView, observedElements: sections) + }.on(observedEvent) + } +} + +// Please take a look at `DelegateProxyType.swift` +class RxTableViewReactiveArrayDataSource + : _RxTableViewReactiveArrayDataSource + , SectionedViewDataSourceType { + typealias CellFactory = (UITableView, Int, Element) -> UITableViewCell + + var itemModels: [Element]? = nil + + func modelAtIndex(_ index: Int) -> Element? { + return itemModels?[index] + } + + func model(_ indexPath: IndexPath) throws -> Any { + precondition(indexPath.section == 0) + guard let item = itemModels?[indexPath.item] else { + throw RxCocoaError.itemsNotYetBound(object: self) + } + return item + } + + let cellFactory: CellFactory + + init(cellFactory: @escaping CellFactory) { + self.cellFactory = cellFactory + } + + override func _tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return itemModels?.count ?? 0 + } + + override func _tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return cellFactory(tableView, indexPath.item, itemModels![indexPath.row]) + } + + // reactive + + func tableView(_ tableView: UITableView, observedElements: [Element]) { + self.itemModels = observedElements + + tableView.reloadData() + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Events/ItemEvents.swift b/Pods/RxCocoa/RxCocoa/iOS/Events/ItemEvents.swift new file mode 100644 index 0000000..66f4293 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Events/ItemEvents.swift @@ -0,0 +1,16 @@ +// +// ItemEvents.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/20/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +import UIKit + +#if os(iOS) || os(tvOS) +public typealias ItemMovedEvent = (sourceIndex: IndexPath, destinationIndex: IndexPath) +public typealias WillDisplayCellEvent = (cell: UITableViewCell, indexPath: IndexPath) +public typealias DidEndDisplayingCellEvent = (cell: UITableViewCell, indexPath: IndexPath) +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift new file mode 100644 index 0000000..bed941c --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/NSTextStorage+Rx.swift @@ -0,0 +1,43 @@ +// +// NSTextStorage+Rx.swift +// Rx +// +// Created by Segii Shulga on 12/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) +import Foundation + +#if !RX_NO_MODULE + import RxSwift +#endif + import UIKit + +extension Reactive where Base: NSTextStorage { + + /** + Reactive wrapper for `delegate`. + + For more information take a look at `DelegateProxyType` protocol documentation. + */ + public var delegate:DelegateProxy { + return RxTextStorageDelegateProxy.proxyForObject(base) + } + + /** + Reactive wrapper for `delegate` message. + */ + public var didProcessEditingRangeChangeInLength: Observable<(editedMask:NSTextStorageEditActions, editedRange:NSRange, delta:Int)> { + return delegate + .methodInvoked(#selector(NSTextStorageDelegate.textStorage(_:didProcessEditing:range:changeInLength:))) + .map { a in + let editedMask = NSTextStorageEditActions(rawValue: try castOrThrow(UInt.self, a[1]) ) + let editedRange = try castOrThrow(NSValue.self, a[2]).rangeValue + let delta = try castOrThrow(Int.self, a[3]) + + return (editedMask, editedRange, delta) + } + } +} +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift b/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift new file mode 100644 index 0000000..a4edc76 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift @@ -0,0 +1,36 @@ +// +// RxCollectionViewDataSourceType.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +/** +Marks data source as `UICollectionView` reactive data source enabling it to be used with one of the `bindTo` methods. +*/ +public protocol RxCollectionViewDataSourceType /*: UICollectionViewDataSource*/ { + + /** + Type of elements that can be bound to collection view. + */ + associatedtype Element + + /** + New observable sequence event observed. + + - parameter collectionView: Bound collection view. + - parameter observedEvent: Event + */ + func collectionView(_ collectionView: UICollectionView, observedEvent: Event) -> Void +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift b/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift new file mode 100644 index 0000000..aeddc9b --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift @@ -0,0 +1,36 @@ +// +// RxTableViewDataSourceType.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/26/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +/** +Marks data source as `UITableView` reactive data source enabling it to be used with one of the `bindTo` methods. +*/ +public protocol RxTableViewDataSourceType /*: UITableViewDataSource*/ { + + /** + Type of elements that can be bound to table view. + */ + associatedtype Element + + /** + New observable sequence event observed. + + - parameter tableView: Bound table view. + - parameter observedEvent: Event + */ + func tableView(_ tableView: UITableView, observedEvent: Event) -> Void +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift new file mode 100644 index 0000000..5bd5926 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift @@ -0,0 +1,120 @@ +// +// RxCollectionViewDataSourceProxy.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet() + +class CollectionViewDataSourceNotSet + : NSObject + , UICollectionViewDataSource { + + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return 0 + } + + // The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath: + func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + rxAbstractMethodWithMessage(dataSourceNotSet) + } + +} + +/** + For more information take a look at `DelegateProxyType`. + */ +public class RxCollectionViewDataSourceProxy + : DelegateProxy + , UICollectionViewDataSource + , DelegateProxyType { + + /** + Typed parent object. + */ + public weak private(set) var collectionView: UICollectionView? + + private weak var _requiredMethodsDataSource: UICollectionViewDataSource? = collectionViewDataSourceNotSet + + /** + Initializes `RxCollectionViewDataSourceProxy` + + - parameter parentObject: Parent object for delegate proxy. + */ + public required init(parentObject: AnyObject) { + self.collectionView = (parentObject as! UICollectionView) + super.init(parentObject: parentObject) + } + + // MARK: delegate + + /** + Required delegate method implementation. + */ + public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + return (_requiredMethodsDataSource ?? collectionViewDataSourceNotSet).collectionView(collectionView, numberOfItemsInSection: section) + } + + /** + Required delegate method implementation. + */ + public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + return (_requiredMethodsDataSource ?? collectionViewDataSourceNotSet).collectionView(collectionView, cellForItemAt: indexPath) + } + + // MARK: proxy + + /** + For more information take a look at `DelegateProxyType`. + */ + public override class func createProxyForObject(_ object: AnyObject) -> AnyObject { + let collectionView = (object as! UICollectionView) + + return castOrFatalError(collectionView.createRxDataSourceProxy()) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public override class func delegateAssociatedObjectTag() -> UnsafeRawPointer { + return _pointer(&dataSourceAssociatedTag) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { + let collectionView: UICollectionView = castOrFatalError(object) + collectionView.dataSource = castOptionalOrFatalError(delegate) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { + let collectionView: UICollectionView = castOrFatalError(object) + return collectionView.dataSource + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public override func setForwardToDelegate(_ forwardToDelegate: AnyObject?, retainDelegate: Bool) { + let requiredMethodsDataSource: UICollectionViewDataSource? = castOptionalOrFatalError(forwardToDelegate) + _requiredMethodsDataSource = requiredMethodsDataSource ?? collectionViewDataSourceNotSet + super.setForwardToDelegate(forwardToDelegate, retainDelegate: retainDelegate) + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift new file mode 100644 index 0000000..b2c5933 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift @@ -0,0 +1,41 @@ +// +// RxCollectionViewDelegateProxy.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +/** + For more information take a look at `DelegateProxyType`. + */ +public class RxCollectionViewDelegateProxy + : RxScrollViewDelegateProxy + , UICollectionViewDelegate + , UICollectionViewDelegateFlowLayout { + + /** + Typed parent object. + */ + public weak private(set) var collectionView: UICollectionView? + + /** + Initializes `RxCollectionViewDelegateProxy` + + - parameter parentObject: Parent object for delegate proxy. + */ + public required init(parentObject: AnyObject) { + self.collectionView = (parentObject as! UICollectionView) + super.init(parentObject: parentObject) + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift new file mode 100644 index 0000000..29ed397 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxPickerViewDelegateProxy.swift @@ -0,0 +1,38 @@ +// +// RxPickerViewDelegateProxy.swift +// Rx +// +// Created by Segii Shulga on 5/12/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) + + import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif +import UIKit + +public class RxPickerViewDelegateProxy + : DelegateProxy + , DelegateProxyType + , UIPickerViewDelegate { + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { + let pickerView: UIPickerView = castOrFatalError(object) + pickerView.delegate = castOptionalOrFatalError(delegate) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { + let pickerView: UIPickerView = castOrFatalError(object) + return pickerView.delegate + } +} +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift new file mode 100644 index 0000000..3d2bf2e --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxScrollViewDelegateProxy.swift @@ -0,0 +1,101 @@ +// +// RxScrollViewDelegateProxy.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +/** + For more information take a look at `DelegateProxyType`. +*/ +public class RxScrollViewDelegateProxy + : DelegateProxy + , UIScrollViewDelegate + , DelegateProxyType { + + fileprivate var _contentOffsetSubject: ReplaySubject? + + /** + Typed parent object. + */ + public weak fileprivate(set) var scrollView: UIScrollView? + + /** + Optimized version used for observing content offset changes. + */ + internal var contentOffsetSubject: Observable { + if _contentOffsetSubject == nil { + let replaySubject = ReplaySubject.create(bufferSize:1) + _contentOffsetSubject = replaySubject + replaySubject.on(.next(self.scrollView?.contentOffset ?? CGPoint.zero)) + } + + return _contentOffsetSubject! + } + + /** + Initializes `RxScrollViewDelegateProxy` + + - parameter parentObject: Parent object for delegate proxy. + */ + public required init(parentObject: AnyObject) { + self.scrollView = (parentObject as! UIScrollView) + super.init(parentObject: parentObject) + } + + // MARK: delegate methods + + /** + For more information take a look at `DelegateProxyType`. + */ + public func scrollViewDidScroll(_ scrollView: UIScrollView) { + if let contentOffset = _contentOffsetSubject { + contentOffset.on(.next(scrollView.contentOffset)) + } + self._forwardToDelegate?.scrollViewDidScroll?(scrollView) + } + + // MARK: delegate proxy + + /** + For more information take a look at `DelegateProxyType`. + */ + public override class func createProxyForObject(_ object: AnyObject) -> AnyObject { + let scrollView = (object as! UIScrollView) + + return castOrFatalError(scrollView.createRxDelegateProxy()) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { + let scrollView: UIScrollView = castOrFatalError(object) + scrollView.delegate = castOptionalOrFatalError(delegate) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { + let scrollView: UIScrollView = castOrFatalError(object) + return scrollView.delegate + } + + deinit { + if let contentOffset = _contentOffsetSubject { + contentOffset.on(.completed) + } + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift new file mode 100644 index 0000000..aea343c --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchBarDelegateProxy.swift @@ -0,0 +1,56 @@ +// +// RxSearchBarDelegateProxy.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 7/4/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +/** + For more information take a look at `DelegateProxyType`. + */ +public class RxSearchBarDelegateProxy + : DelegateProxy + , UISearchBarDelegate + , DelegateProxyType { + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { + let searchBar: UISearchBar = castOrFatalError(object) + return searchBar.delegate + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { + let searchBar: UISearchBar = castOrFatalError(object) + searchBar.delegate = castOptionalOrFatalError(delegate) + } + + // MARK: Delegate proxy methods + +#if os(iOS) + /** + For more information take a look at `DelegateProxyType`. + */ + public override class func createProxyForObject(_ object: AnyObject) -> AnyObject { + let searchBar = (object as! UISearchBar) + + return castOrFatalError(searchBar.createRxDelegateProxy()) + } +#endif + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift new file mode 100644 index 0000000..2273fc2 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxSearchControllerDelegateProxy.swift @@ -0,0 +1,44 @@ +// +// RxSearchControllerDelegateProxy.swift +// Rx +// +// Created by Segii Shulga on 3/17/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) + + import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + import UIKit + +/** + For more information take a look at `DelegateProxyType`. + */ +@available(iOS 8.0, *) +public class RxSearchControllerDelegateProxy + : DelegateProxy + , DelegateProxyType + , UISearchControllerDelegate { + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { + let searchController: UISearchController = castOrFatalError(object) + searchController.delegate = castOptionalOrFatalError(delegate) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { + let searchController: UISearchController = castOrFatalError(object) + return searchController.delegate + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift new file mode 100644 index 0000000..931695c --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTabBarDelegateProxy.swift @@ -0,0 +1,52 @@ +// +// RxTabBarDelegateProxy.swift +// Rx +// +// Created by Jesse Farless on 5/14/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) +import Foundation +import UIKit + +#if !RX_NO_MODULE +import RxSwift +#endif + +/** + For more information take a look at `DelegateProxyType`. + */ +public class RxTabBarDelegateProxy + : DelegateProxy + , UITabBarDelegate + , DelegateProxyType { + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { + let tabBar: UITabBar = castOrFatalError(object) + return tabBar.delegate + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { + let tabBar: UITabBar = castOrFatalError(object) + tabBar.delegate = castOptionalOrFatalError(delegate) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public override class func createProxyForObject(_ object: AnyObject) -> AnyObject { + let tabBar = (object as! UITabBar) + + return castOrFatalError(tabBar.createRxDelegateProxy()) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift new file mode 100644 index 0000000..083dec0 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift @@ -0,0 +1,218 @@ +// +// RxTableViewDataSourceProxy.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +let tableViewDataSourceNotSet = TableViewDataSourceNotSet() + +class TableViewDataSourceNotSet + : NSObject + , UITableViewDataSource { + + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return 0 + } + + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + rxAbstractMethodWithMessage(dataSourceNotSet) + } +} + +/** + For more information take a look at `DelegateProxyType`. + */ +public class RxTableViewDataSourceProxy + : DelegateProxy + , UITableViewDataSource + , DelegateProxyType { + + /** + Typed parent object. + */ + public weak fileprivate(set) var tableView: UITableView? + + // issue https://github.com/ReactiveX/RxSwift/issues/907 + private var _numberOfObservers = 0 + private var _commitForRowAtSequenceSentMessage: CachedCommitForRowAt? = nil + private var _commitForRowAtSequenceMethodInvoked: CachedCommitForRowAt? = nil + + fileprivate class Counter { + var hasObservers: Bool = false + } + + fileprivate class CachedCommitForRowAt { + let sequence: Observable<[Any]> + let counter: Counter + + var hasObservers: Bool { + return counter.hasObservers + } + + init(sequence: Observable<[Any]>, counter: Counter) { + self.sequence = sequence + self.counter = counter + } + + static func createFor(commitForRowAt: Observable<[Any]>, proxy: RxTableViewDataSourceProxy) -> CachedCommitForRowAt { + let counter = Counter() + + let commitForRowAtSequence = commitForRowAt.do(onSubscribe: { [weak proxy] in + counter.hasObservers = true + proxy?.refreshTableViewDataSource() + }, onDispose: { [weak proxy] in + counter.hasObservers = false + proxy?.refreshTableViewDataSource() + }) + .subscribeOn(MainScheduler()) + .share() + + return CachedCommitForRowAt(sequence: commitForRowAtSequence, counter: counter) + } + } + + fileprivate weak var _requiredMethodsDataSource: UITableViewDataSource? = tableViewDataSourceNotSet + + /** + Initializes `RxTableViewDataSourceProxy` + + - parameter parentObject: Parent object for delegate proxy. + */ + public required init(parentObject: AnyObject) { + self.tableView = (parentObject as! UITableView) + super.init(parentObject: parentObject) + } + + // MARK: delegate + + /** + Required delegate method implementation. + */ + public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + return (_requiredMethodsDataSource ?? tableViewDataSourceNotSet).tableView(tableView, numberOfRowsInSection: section) + } + + /** + Required delegate method implementation. + */ + public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + return (_requiredMethodsDataSource ?? tableViewDataSourceNotSet).tableView(tableView, cellForRowAt: indexPath) + } + + // MARK: proxy + + /** + For more information take a look at `DelegateProxyType`. + */ + public override class func createProxyForObject(_ object: AnyObject) -> AnyObject { + let tableView = (object as! UITableView) + + return castOrFatalError(tableView.createRxDataSourceProxy()) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public override class func delegateAssociatedObjectTag() -> UnsafeRawPointer { + return _pointer(&dataSourceAssociatedTag) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { + let tableView: UITableView = castOrFatalError(object) + tableView.dataSource = castOptionalOrFatalError(delegate) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { + let tableView: UITableView = castOrFatalError(object) + return tableView.dataSource + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public override func setForwardToDelegate(_ forwardToDelegate: AnyObject?, retainDelegate: Bool) { + let requiredMethodsDataSource: UITableViewDataSource? = castOptionalOrFatalError(forwardToDelegate) + _requiredMethodsDataSource = requiredMethodsDataSource ?? tableViewDataSourceNotSet + super.setForwardToDelegate(forwardToDelegate, retainDelegate: retainDelegate) + } + + override open func methodInvoked(_ selector: Selector) -> Observable<[Any]> { + MainScheduler.ensureExecutingOnScheduler() + + // This is special behavior for commit:forRowAt: + // If proxy data source responds to this selector then table view will show + // swipe to delete option even when nobody is observing. + // https://github.com/ReactiveX/RxSwift/issues/907 + if selector == #selector(UITableViewDataSource.tableView(_:commit:forRowAt:)) { + guard let commitForRowAtSequenceMethodInvoked = _commitForRowAtSequenceMethodInvoked else { + let commitForRowAtSequenceMethodInvoked = CachedCommitForRowAt.createFor(commitForRowAt: super.methodInvoked(selector), proxy: self) + _commitForRowAtSequenceMethodInvoked = commitForRowAtSequenceMethodInvoked + return commitForRowAtSequenceMethodInvoked.sequence + } + + return commitForRowAtSequenceMethodInvoked.sequence + } + + return super.methodInvoked(selector) + } + + override open func sentMessage(_ selector: Selector) -> Observable<[Any]> { + MainScheduler.ensureExecutingOnScheduler() + + // This is special behavior for commit:forRowAt: + // If proxy data source responds to this selector then table view will show + // swipe to delete option even when nobody is observing. + // https://github.com/ReactiveX/RxSwift/issues/907 + if selector == #selector(UITableViewDataSource.tableView(_:commit:forRowAt:)) { + guard let commitForRowAtSequenceSentMessage = _commitForRowAtSequenceSentMessage else { + let commitForRowAtSequenceSentMessage = CachedCommitForRowAt.createFor(commitForRowAt: super.sentMessage(selector), proxy: self) + _commitForRowAtSequenceSentMessage = commitForRowAtSequenceSentMessage + return commitForRowAtSequenceSentMessage.sequence + } + + return commitForRowAtSequenceSentMessage.sequence + } + + return super.sentMessage(selector) + } + + // https://github.com/ReactiveX/RxSwift/issues/907 + private func refreshTableViewDataSource() { + if self.tableView?.dataSource === self { + self.tableView?.dataSource = nil + self.tableView?.dataSource = self + } + } + + override open func responds(to aSelector: Selector!) -> Bool { + // https://github.com/ReactiveX/RxSwift/issues/907 + let commitForRowAtSelector = #selector(UITableViewDataSource.tableView(_:commit:forRowAt:)) + if aSelector == commitForRowAtSelector { + // without `as? UITableViewDataSource` `responds(to:)` fails, 🍻 compiler team + let forwardDelegateResponds = (self.forwardToDelegate() as? UITableViewDataSource)?.responds(to: commitForRowAtSelector) + return (_commitForRowAtSequenceSentMessage?.hasObservers ?? false) + || (_commitForRowAtSequenceMethodInvoked?.hasObservers ?? false) + || (forwardDelegateResponds ?? false) + } + + return super.responds(to: aSelector) + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift new file mode 100644 index 0000000..2618404 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift @@ -0,0 +1,42 @@ +// +// RxTableViewDelegateProxy.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 6/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +/** + For more information take a look at `DelegateProxyType`. +*/ +public class RxTableViewDelegateProxy + : RxScrollViewDelegateProxy + , UITableViewDelegate { + + + /** + Typed parent object. + */ + public weak private(set) var tableView: UITableView? + + /** + Initializes `RxTableViewDelegateProxy` + + - parameter parentObject: Parent object for delegate proxy. + */ + public required init(parentObject: AnyObject) { + self.tableView = (parentObject as! UITableView) + super.init(parentObject: parentObject) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift new file mode 100644 index 0000000..d546d4c --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextStorageDelegateProxy.swift @@ -0,0 +1,41 @@ +// +// RxTextStorageDelegateProxy.swift +// Rx +// +// Created by Segii Shulga on 12/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + + import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + import UIKit + +public class RxTextStorageDelegateProxy + : DelegateProxy + , DelegateProxyType + , NSTextStorageDelegate { + + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func setCurrentDelegate(_ delegate: AnyObject?, toObject object: AnyObject) { + let textStorage: NSTextStorage = castOrFatalError(object) + textStorage.delegate = castOptionalOrFatalError(delegate) + } + + /** + For more information take a look at `DelegateProxyType`. + */ + public class func currentDelegateFor(_ object: AnyObject) -> AnyObject? { + let textStorage: NSTextStorage = castOrFatalError(object) + return textStorage.delegate + } + + +} +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift new file mode 100644 index 0000000..3caf7ba --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/Proxies/RxTextViewDelegateProxy.swift @@ -0,0 +1,56 @@ +// +// RxTextViewDelegateProxy.swift +// RxCocoa +// +// Created by Yuta ToKoRo on 7/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +/** + For more information take a look at `DelegateProxyType`. +*/ +public class RxTextViewDelegateProxy + : RxScrollViewDelegateProxy + , UITextViewDelegate { + + /** + Typed parent object. + */ + public weak private(set) var textView: UITextView? + + /** + Initializes `RxTextViewDelegateProxy` + + - parameter parentObject: Parent object for delegate proxy. + */ + public required init(parentObject: AnyObject) { + self.textView = (parentObject as! UITextView) + super.init(parentObject: parentObject) + } + + // MARK: delegate methods + + /** + For more information take a look at `DelegateProxyType`. + */ + @objc public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { + /** + We've had some issues with observing text changes. This is here just in case we need the same hack in future and that + we wouldn't need to change the public interface. + */ + let forwardToDelegate = self.forwardToDelegate() as? UITextViewDelegate + return forwardToDelegate?.textView?(textView, + shouldChangeTextIn: range, + replacementText: text) ?? true + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift new file mode 100644 index 0000000..7e19a3a --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIActivityIndicatorView+Rx.swift @@ -0,0 +1,33 @@ +// +// UIActivityIndicatorView+Rx.swift +// Rx +// +// Created by Ivan Persidskiy on 02/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) +import UIKit + +#if !RX_NO_MODULE +import RxSwift +#endif + +extension Reactive where Base: UIActivityIndicatorView { + + /** + Bindable sink for `startAnimating()`, `stopAnimating()` methods. + */ + public var animating: AnyObserver { + return UIBindingObserver(UIElement: self.base) { activityIndicator, active in + if active { + activityIndicator.startAnimating() + } else { + activityIndicator.stopAnimating() + } + }.asObserver() + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift new file mode 100644 index 0000000..432b387 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIAlertAction+Rx.swift @@ -0,0 +1,33 @@ +// +// UIAlertAction+Rx.swift +// Rx +// +// Created by Andrew Breckenridge on 5/7/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit + +#if !RX_NO_MODULE +import RxSwift +#endif + +extension Reactive where Base: UIAlertAction { + + /** + Bindable sink for `enabled` property. + */ + public var enabled: AnyObserver { + return UIBindingObserver(UIElement: self.base) { alertAction, value in + alertAction.isEnabled = value + }.asObserver() + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift new file mode 100644 index 0000000..08aa552 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIApplication+Rx.swift @@ -0,0 +1,30 @@ +// +// UIApplication+Rx.swift +// RxExample +// +// Created by Mads Bøgeskov on 18/01/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if os(iOS) + import UIKit + +#if !RX_NO_MODULE + import RxSwift +#endif + + extension Reactive where Base: UIApplication { + + /** + Bindable sink for `networkActivityIndicatorVisible`. + */ + public var networkActivityIndicatorVisible: AnyObserver { + return UIBindingObserver(UIElement: self.base) { application, active in + application.isNetworkActivityIndicatorVisible = active + }.asObserver() + } + } +#endif + diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIBarButtonItem+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIBarButtonItem+Rx.swift new file mode 100644 index 0000000..45979e4 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIBarButtonItem+Rx.swift @@ -0,0 +1,86 @@ +// +// UIBarButtonItem+Rx.swift +// RxCocoa +// +// Created by Daniel Tartaglia on 5/31/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +var rx_tap_key: UInt8 = 0 + +extension Reactive where Base: UIBarButtonItem { + + /** + Bindable sink for `enabled` property. + */ + public var enabled: AnyObserver { + return UIBindingObserver(UIElement: self.base) { UIElement, value in + UIElement.isEnabled = value + }.asObserver() + } + + /** + Reactive wrapper for target action pattern on `self`. + */ + public var tap: ControlEvent { + let source = lazyInstanceObservable(&rx_tap_key) { () -> Observable in + Observable.create { [weak control = self.base] observer in + guard let control = control else { + observer.on(.completed) + return Disposables.create() + } + let target = BarButtonItemTarget(barButtonItem: control) { + observer.on(.next()) + } + return target + } + .takeUntil(self.deallocated) + .share() + } + + return ControlEvent(events: source) + } +} + + +@objc +class BarButtonItemTarget: RxTarget { + typealias Callback = () -> Void + + weak var barButtonItem: UIBarButtonItem? + var callback: Callback! + + init(barButtonItem: UIBarButtonItem, callback: @escaping () -> Void) { + self.barButtonItem = barButtonItem + self.callback = callback + super.init() + barButtonItem.target = self + barButtonItem.action = #selector(BarButtonItemTarget.action(_:)) + } + + override func dispose() { + super.dispose() +#if DEBUG + MainScheduler.ensureExecutingOnScheduler() +#endif + + barButtonItem?.target = nil + barButtonItem?.action = nil + + callback = nil + } + + func action(_ sender: AnyObject) { + callback() + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift new file mode 100644 index 0000000..a308075 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIButton+Rx.swift @@ -0,0 +1,68 @@ +// +// UIButton+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 3/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UIButton { + + /** + Reactive wrapper for `TouchUpInside` control event. + */ + public var tap: ControlEvent { + return controlEvent(.touchUpInside) + } +} + +#endif + +#if os(tvOS) + +import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif +import UIKit + +extension Reactive where Base: UIButton { + + /** + Reactive wrapper for `PrimaryActionTriggered` control event. + */ + public var primaryAction: ControlEvent { + return controlEvent(.primaryActionTriggered) + } + +} + +#endif + +#if os(iOS) || os(tvOS) + + import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + import UIKit + +extension Reactive where Base: UIButton { + /** + Reactive wrapper for `setTitle(_:controlState:)` + */ + public func title(controlState: UIControlState = []) -> AnyObserver { + return UIBindingObserver(UIElement: self.base) { (button, title) -> () in + button.setTitle(title, for: controlState) + }.asObserver() + } +} +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UICollectionView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UICollectionView+Rx.swift new file mode 100644 index 0000000..b469102 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UICollectionView+Rx.swift @@ -0,0 +1,450 @@ +// +// UICollectionView+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 4/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +// Items + +extension Reactive where Base: UICollectionView { + + /** + Binds sequences of elements to collection view items. + + - parameter source: Observable sequence of items. + - parameter cellFactory: Transform between sequence elements and view cells. + - returns: Disposable object that can be used to unbind. + + Example + + let items = Observable.just([ + 1, + 2, + 3 + ]) + + items + .bindTo(collectionView.rx.items) { (collectionView, row, element) in + let indexPath = IndexPath(forItem: row, inSection: 0) + let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell + cell.value?.text = "\(element) @ \(row)" + return cell + } + .addDisposableTo(disposeBag) + */ + public func items + (_ source: O) + -> (_ cellFactory: @escaping (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell) + -> Disposable where O.E == S { + return { cellFactory in + let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper(cellFactory: cellFactory) + return self.items(dataSource: dataSource)(source) + } + + } + + /** + Binds sequences of elements to collection view items. + + - parameter cellIdentifier: Identifier used to dequeue cells. + - parameter source: Observable sequence of items. + - parameter configureCell: Transform between sequence elements and view cells. + - parameter cellType: Type of table view cell. + - returns: Disposable object that can be used to unbind. + + Example + + let items = Observable.just([ + 1, + 2, + 3 + ]) + + items + .bindTo(collectionView.rx.items(cellIdentifier: "Cell", cellType: NumberCell.self)) { (row, element, cell) in + cell.value?.text = "\(element) @ \(row)" + } + .addDisposableTo(disposeBag) + */ + public func items + (cellIdentifier: String, cellType: Cell.Type = Cell.self) + -> (_ source: O) + -> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void) + -> Disposable where O.E == S { + return { source in + return { configureCell in + let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper { (cv, i, item) in + let indexPath = IndexPath(item: i, section: 0) + let cell = cv.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! Cell + configureCell(i, item, cell) + return cell + } + + return self.items(dataSource: dataSource)(source) + } + } + } + + + /** + Binds sequences of elements to collection view items using a custom reactive data used to perform the transformation. + + - parameter dataSource: Data source used to transform elements to view cells. + - parameter source: Observable sequence of items. + - returns: Disposable object that can be used to unbind. + + Example + + let dataSource = RxCollectionViewSectionedReloadDataSource>() + + let items = Observable.just([ + SectionModel(model: "First section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Second section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Third section", items: [ + 1.0, + 2.0, + 3.0 + ]) + ]) + + dataSource.configureCell = { (dataSource, cv, indexPath, element) in + let cell = cv.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell + cell.value?.text = "\(element) @ row \(indexPath.row)" + return cell + } + + items + .bindTo(collectionView.rx.items(dataSource: dataSource)) + .addDisposableTo(disposeBag) + */ + public func items< + DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource, + O: ObservableType> + (dataSource: DataSource) + -> (_ source: O) + -> Disposable where DataSource.Element == O.E + { + return { source in + // This is called for sideeffects only, and to make sure delegate proxy is in place when + // data source is being bound. + // This is needed because theoretically the data source subscription itself might + // call `self.rx_delegate`. If that happens, it might cause weird side effects since + // setting data source will set delegate, and UICollectionView might get into a weird state. + // Therefore it's better to set delegate proxy first, just to be sure. + _ = self.delegate + // Strong reference is needed because data source is in use until result subscription is disposed + return source.subscribeProxyDataSource(ofObject: self.base, dataSource: dataSource, retainDataSource: true) { [weak collectionView = self.base] (_: RxCollectionViewDataSourceProxy, event) -> Void in + guard let collectionView = collectionView else { + return + } + dataSource.collectionView(collectionView, observedEvent: event) + } + } + } +} + +extension UICollectionView { + + /** + Factory method that enables subclasses to implement their own `delegate`. + + - returns: Instance of delegate proxy that wraps `delegate`. + */ + public override func createRxDelegateProxy() -> RxScrollViewDelegateProxy { + return RxCollectionViewDelegateProxy(parentObject: self) + } + + /** + Factory method that enables subclasses to implement their own `rx.dataSource`. + + - returns: Instance of delegate proxy that wraps `dataSource`. + */ + public func createRxDataSourceProxy() -> RxCollectionViewDataSourceProxy { + return RxCollectionViewDataSourceProxy(parentObject: self) + } + +} + +extension Reactive where Base: UICollectionView { + + /** + Reactive wrapper for `dataSource`. + + For more information take a look at `DelegateProxyType` protocol documentation. + */ + public var dataSource: DelegateProxy { + return RxCollectionViewDataSourceProxy.proxyForObject(base) + } + + /** + Installs data source as forwarding delegate on `rx.dataSource`. + Data source won't be retained. + + It enables using normal delegate mechanism with reactive delegate mechanism. + + - parameter dataSource: Data source object. + - returns: Disposable object that can be used to unbind the data source. + */ + public func setDataSource(_ dataSource: UICollectionViewDataSource) + -> Disposable { + return RxCollectionViewDataSourceProxy.installForwardDelegate(dataSource, retainDelegate: false, onProxyForObject: self.base) + } + + /** + Reactive wrapper for `delegate` message `collectionView:didSelectItemAtIndexPath:`. + */ + public var itemSelected: ControlEvent { + let source = delegate.methodInvoked(#selector(UICollectionViewDelegate.collectionView(_:didSelectItemAt:))) + .map { a in + return a[1] as! IndexPath + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `collectionView:didSelectItemAtIndexPath:`. + */ + public var itemDeselected: ControlEvent { + let source = delegate.methodInvoked(#selector(UICollectionViewDelegate.collectionView(_:didDeselectItemAt:))) + .map { a in + return a[1] as! IndexPath + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `collectionView:didSelectItemAtIndexPath:`. + + It can be only used when one of the `rx.itemsWith*` methods is used to bind observable sequence, + or any other data source conforming to `SectionedViewDataSourceType` protocol. + + ``` + collectionView.rx.modelSelected(MyModel.self) + .map { ... + ``` + */ + public func modelSelected(_ modelType: T.Type) -> ControlEvent { + let source: Observable = itemSelected.flatMap { [weak view = self.base as UICollectionView] indexPath -> Observable in + guard let view = view else { + return Observable.empty() + } + + return Observable.just(try view.rx.model(indexPath)) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `collectionView:didSelectItemAtIndexPath:`. + + It can be only used when one of the `rx.itemsWith*` methods is used to bind observable sequence, + or any other data source conforming to `SectionedViewDataSourceType` protocol. + + ``` + collectionView.rx.modelDeselected(MyModel.self) + .map { ... + ``` + */ + public func modelDeselected(_ modelType: T.Type) -> ControlEvent { + let source: Observable = itemDeselected.flatMap { [weak view = self.base as UICollectionView] indexPath -> Observable in + guard let view = view else { + return Observable.empty() + } + + return Observable.just(try view.rx.model(indexPath)) + } + + return ControlEvent(events: source) + } + + /** + Syncronous helper method for retrieving a model at indexPath through a reactive data source + */ + public func model(_ indexPath: IndexPath) throws -> T { + let dataSource: SectionedViewDataSourceType = castOrFatalError(self.dataSource.forwardToDelegate(), message: "This method only works in case one of the `rx.itemsWith*` methods was used.") + + let element = try dataSource.model(indexPath) + + return element as! T + } +} +#endif + +#if os(tvOS) + +extension Reactive where Base: UICollectionView { + + /** + Reactive wrapper for `delegate` message `collectionView:didUpdateFocusInContext:withAnimationCoordinator:`. + */ + public var didUpdateFocusInContextWithAnimationCoordinator: ControlEvent<(context: UIFocusUpdateContext, animationCoordinator: UIFocusAnimationCoordinator)> { + + let source = delegate.observe(#selector(UICollectionViewDelegate.collectionView(_:didUpdateFocusIn:with:))) + .map { a -> (context: UIFocusUpdateContext, animationCoordinator: UIFocusAnimationCoordinator) in + let context = a[1] as! UIFocusUpdateContext + let animationCoordinator = a[2] as! UIFocusAnimationCoordinator + return (context: context, animationCoordinator: animationCoordinator) + } + + return ControlEvent(events: source) + } +} +#endif + +#if os(iOS) || os(tvOS) + +extension UICollectionView { + + /** + Binds sequences of elements to collection view items. + + - parameter cellIdentifier: Identifier used to dequeue cells. + - parameter source: Observable sequence of items. + - parameter configureCell: Transform between sequence elements and view cells. + - parameter cellType: Type of table view cell. + - returns: Disposable object that can be used to unbind. + + Example + + let items = Observable.just([ + 1, + 2, + 3 + ]) + + items + .bindTo(collectionView.rx.items(cellIdentifier: "Cell", cellType: NumberCell.self)) { (row, element, cell) in + cell.value?.text = "\(element) @ \(row)" + } + .addDisposableTo(disposeBag) + */ + @available(*, deprecated, renamed: "rx.items(cellIdentifier:cellType:_:_:)") + public func rx_itemsWithCellIdentifier + (_ cellIdentifier: String, cellType: Cell.Type = Cell.self) + -> (_ source: O) + -> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void) + -> Disposable where O.E == S { + return { source in + return { configureCell in + return self.rx.items(cellIdentifier: cellIdentifier, cellType: cellType)(source)(configureCell) + } + } + } + + + /** + Binds sequences of elements to collection view items. + + - parameter source: Observable sequence of items. + - parameter cellFactory: Transform between sequence elements and view cells. + - returns: Disposable object that can be used to unbind. + + Example + + let items = Observable.just([ + 1, + 2, + 3 + ]) + + items + .bindTo(collectionView.rx.items) { (collectionView, row, element) in + let indexPath = IndexPath(forItem: row, inSection: 0) + let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell + cell.value?.text = "\(element) @ \(row)" + return cell + } + .addDisposableTo(disposeBag) + */ + @available(*, deprecated, renamed: "rx.items(_:_:)") + public func rx_itemsWithCellFactory + (_ source: O) + -> (_ cellFactory: @escaping (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell) + -> Disposable where O.E == S { + return { cellFactory in + return self.rx.items(source)(cellFactory) + } + } + + /** + Binds sequences of elements to collection view items using a custom reactive data used to perform the transformation. + + - parameter dataSource: Data source used to transform elements to view cells. + - parameter source: Observable sequence of items. + - returns: Disposable object that can be used to unbind. + + Example + + let dataSource = RxCollectionViewSectionedReloadDataSource>() + + let items = Observable.just([ + SectionModel(model: "First section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Second section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Third section", items: [ + 1.0, + 2.0, + 3.0 + ]) + ]) + + dataSource.configureCell = { (dataSource, cv, indexPath, element) in + let cell = cv.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell + cell.value?.text = "\(element) @ row \(indexPath.row)" + return cell + } + + items + .bindTo(collectionView.rx.items(dataSource: dataSource)) + .addDisposableTo(disposeBag) + */ + @available(*, deprecated, renamed: "rx.items(dataSource:_:)") + public func rx_itemsWithDataSource< + DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource, + O: ObservableType> + (_ dataSource: DataSource) + -> (_ source: O) + -> Disposable where DataSource.Element == O.E + { + return { source in + return self.rx.items(dataSource: dataSource)(source) + } + } + + /** + Syncronous helper method for retrieving a model at indexPath through a reactive data source + */ + @available(*, deprecated, renamed: "rx.model(_:)") + public func model(_ indexPath: IndexPath) throws -> T { + return try self.rx.model(indexPath) + } +} +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift new file mode 100644 index 0000000..2f9c45a --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIControl+Rx.swift @@ -0,0 +1,92 @@ +// +// UIControl+Rx.swift +// RxCocoa +// +// Created by Daniel Tartaglia on 5/23/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UIControl { + + /** + Bindable sink for `enabled` property. + */ + public var enabled: AnyObserver { + return UIBindingObserver(UIElement: self.base) { control, value in + control.isEnabled = value + }.asObserver() + } + + /** + Bindable sink for `selected` property. + */ + public var selected: AnyObserver { + return UIBindingObserver(UIElement: self.base) { control, selected in + control.isSelected = selected + }.asObserver() + } + + /** + Reactive wrapper for target action pattern. + + - parameter controlEvents: Filter for observed event types. + */ + public func controlEvent(_ controlEvents: UIControlEvents) -> ControlEvent { + let source: Observable = Observable.create { [weak control = self.base] observer in + MainScheduler.ensureExecutingOnScheduler() + + guard let control = control else { + observer.on(.completed) + return Disposables.create() + } + + let controlTarget = ControlTarget(control: control, controlEvents: controlEvents) { + control in + observer.on(.next()) + } + + return Disposables.create(with: controlTarget.dispose) + }.takeUntil(deallocated) + + return ControlEvent(events: source) + } + + /** + You might be wondering why the ugly `as!` casts etc, well, for some reason if + Swift compiler knows C is UIControl type and optimizations are turned on, it will crash. + */ + static func value(_ control: C, getter: @escaping (C) -> T, setter: @escaping (C, T) -> Void) -> ControlProperty { + let source: Observable = Observable.create { [weak weakControl = control] observer in + guard let control = weakControl else { + observer.on(.completed) + return Disposables.create() + } + + observer.on(.next(getter(control))) + + let controlTarget = ControlTarget(control: control as! UIControl, controlEvents: [.allEditingEvents, .valueChanged]) { _ in + if let control = weakControl { + observer.on(.next(getter(control))) + } + } + + return Disposables.create(with: controlTarget.dispose) + } + .takeUntil((control as NSObject).rx.deallocated) + + let bindingObserver = UIBindingObserver(UIElement: control, binding: setter) + + return ControlProperty(values: source, valueSink: bindingObserver) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIDatePicker+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIDatePicker+Rx.swift new file mode 100644 index 0000000..ce494f1 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIDatePicker+Rx.swift @@ -0,0 +1,35 @@ +// +// UIDatePicker+Rx.swift +// RxCocoa +// +// Created by Daniel Tartaglia on 5/31/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UIDatePicker { + + /** + Reactive wrapper for `date` property. + */ + public var date: ControlProperty { + return UIControl.rx.value( + self.base, + getter: { datePicker in + datePicker.date + }, setter: { datePicker, value in + datePicker.date = value + } + ) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIGestureRecognizer+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIGestureRecognizer+Rx.swift new file mode 100644 index 0000000..2493e4e --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIGestureRecognizer+Rx.swift @@ -0,0 +1,81 @@ +// +// UIGestureRecognizer+Rx.swift +// Touches +// +// Created by Carlos García on 10/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + + +// This should be only used from `MainScheduler` +class GestureTarget: RxTarget { + typealias Callback = (Recognizer) -> Void + + let selector = #selector(ControlTarget.eventHandler(_:)) + + weak var gestureRecognizer: Recognizer? + var callback: Callback? + + init(_ gestureRecognizer: Recognizer, callback: @escaping Callback) { + self.gestureRecognizer = gestureRecognizer + self.callback = callback + + super.init() + + gestureRecognizer.addTarget(self, action: selector) + + let method = self.method(for: selector) + if method == nil { + fatalError("Can't find method") + } + } + + func eventHandler(_ sender: UIGestureRecognizer!) { + if let callback = self.callback, let gestureRecognizer = self.gestureRecognizer { + callback(gestureRecognizer) + } + } + + override func dispose() { + super.dispose() + + self.gestureRecognizer?.removeTarget(self, action: self.selector) + self.callback = nil + } +} + +extension Reactive where Base: UIGestureRecognizer { + + /** + Reactive wrapper for gesture recognizer events. + */ + public var event: ControlEvent { + let source: Observable = Observable.create { [weak control = self.base] observer in + MainScheduler.ensureExecutingOnScheduler() + + guard let control = control else { + observer.on(.completed) + return Disposables.create() + } + + let observer = GestureTarget(control) { + control in + observer.on(.next(control)) + } + + return observer + }.takeUntil(deallocated) + + return ControlEvent(events: source) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift new file mode 100644 index 0000000..495cc25 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIImageView+Rx.swift @@ -0,0 +1,74 @@ +// +// UIImageView+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 4/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UIImageView { + + /** + Bindable sink for `image` property. + */ + public var image: AnyObserver { + return image(transitionType: nil) + } + + /** + Bindable sink for `image` property. + + - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) + */ + @available(*, deprecated, renamed: "image(transitionType:)") + public func imageAnimated(_ transitionType: String?) -> AnyObserver { + return UIBindingObserver(UIElement: base) { imageView, image in + if let transitionType = transitionType { + if image != nil { + let transition = CATransition() + transition.duration = 0.25 + transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + transition.type = transitionType + imageView.layer.add(transition, forKey: kCATransition) + } + } + else { + imageView.layer.removeAllAnimations() + } + imageView.image = image + }.asObserver() + } + + /** + Bindable sink for `image` property. + + - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) + */ + public func image(transitionType: String? = nil) -> AnyObserver { + return UIBindingObserver(UIElement: base) { imageView, image in + if let transitionType = transitionType { + if image != nil { + let transition = CATransition() + transition.duration = 0.25 + transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + transition.type = transitionType + imageView.layer.add(transition, forKey: kCATransition) + } + } + else { + imageView.layer.removeAllAnimations() + } + imageView.image = image + }.asObserver() + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift new file mode 100644 index 0000000..2b8c880 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UILabel+Rx.swift @@ -0,0 +1,39 @@ +// +// UILabel+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 4/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UILabel { + + /** + Bindable sink for `text` property. + */ + public var text: AnyObserver { + return UIBindingObserver(UIElement: self.base) { label, text in + label.text = text + }.asObserver() + } + + /** + Bindable sink for `attributedText` property. + */ + public var attributedText: AnyObserver { + return UIBindingObserver(UIElement: self.base) { label, text in + label.attributedText = text + }.asObserver() + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift new file mode 100644 index 0000000..3552d9f --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UINavigationItem+Rx.swift @@ -0,0 +1,29 @@ +// +// UINavigationItem+Rx.swift +// Rx +// +// Created by kumapo on 2016/05/09. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +extension Reactive where Base: UINavigationItem { + /** + Bindable sink for `title` property. + */ + public var title: AnyObserver { + return UIBindingObserver(UIElement: self.base) { navigationItem, text in + navigationItem.title = text + }.asObserver() + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift new file mode 100644 index 0000000..8323994 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIPageControl+Rx.swift @@ -0,0 +1,29 @@ +// +// UIPageControl+Rx.swift +// Rx +// +// Created by Francesco Puntillo on 14/04/2016. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UIPageControl { + + /** + Bindable sink for `currentPage` property. + */ + public var currentPage: AnyObserver { + return UIBindingObserver(UIElement: self.base) { controller, page in + controller.currentPage = page + }.asObserver() + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift new file mode 100644 index 0000000..df93b47 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIPickerView+Rx.swift @@ -0,0 +1,36 @@ +// +// UIPickerView+Rx.swift +// Rx +// +// Created by Segii Shulga on 5/12/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) + + import Foundation +#if !RX_NO_MODULE + import RxSwift +#endif + import UIKit + +extension Reactive where Base: UIPickerView { + /** + Reactive wrapper for `delegate`. + For more information take a look at `DelegateProxyType` protocol documentation. + */ + public var delegate: DelegateProxy { + return RxPickerViewDelegateProxy.proxyForObject(base) + } + + public var itemSelected: ControlEvent<(Int, Int)> { + let source = delegate + .methodInvoked(#selector(UIPickerViewDelegate.pickerView(_:didSelectRow:inComponent:))) + .map { + return (try castOrThrow(Int.self, $0[1]), try castOrThrow(Int.self, $0[2])) + } + return ControlEvent(events: source) + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift new file mode 100644 index 0000000..26f70cc --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIProgressView+Rx.swift @@ -0,0 +1,30 @@ +// +// UIProgressView+Rx.swift +// Rx +// +// Created by Samuel Bae on 2/27/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UIProgressView { + + /** + Bindable sink for `progress` property + */ + public var progress: AnyObserver { + return UIBindingObserver(UIElement: self.base) { progressView, progress in + progressView.progress = progress + }.asObserver() + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift new file mode 100644 index 0000000..69b54dc --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIRefreshControl+Rx.swift @@ -0,0 +1,33 @@ +// +// UIRefreshControl+Rx.swift +// RxCocoa +// +// Created by Yosuke Ishikawa on 1/31/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) +import UIKit + +#if !RX_NO_MODULE +import RxSwift +#endif + +extension Reactive where Base: UIRefreshControl { + + /** + Bindable sink for `beginRefreshing()`, `endRefreshing()` methods. + */ + public var refreshing: AnyObserver { + return UIBindingObserver(UIElement: self.base) { refreshControl, refresh in + if refresh { + refreshControl.beginRefreshing() + } else { + refreshControl.endRefreshing() + } + }.asObserver() + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift new file mode 100644 index 0000000..a7f798d --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIScrollView+Rx.swift @@ -0,0 +1,78 @@ +// +// UIScrollView+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 4/3/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension UIScrollView { + + /** + Factory method that enables subclasses to implement their own `delegate`. + + - returns: Instance of delegate proxy that wraps `delegate`. + */ + public func createRxDelegateProxy() -> RxScrollViewDelegateProxy { + return RxScrollViewDelegateProxy(parentObject: self) + } + +} + +extension Reactive where Base: UIScrollView { + + /** + Reactive wrapper for `delegate`. + + For more information take a look at `DelegateProxyType` protocol documentation. + */ + public var delegate: DelegateProxy { + return RxScrollViewDelegateProxy.proxyForObject(base) + } + + /** + Reactive wrapper for `contentOffset`. + */ + public var contentOffset: ControlProperty { + let proxy = RxScrollViewDelegateProxy.proxyForObject(base) + + let bindingObserver = UIBindingObserver(UIElement: self.base) { scrollView, contentOffset in + scrollView.contentOffset = contentOffset + } + + return ControlProperty(values: proxy.contentOffsetSubject, valueSink: bindingObserver) + } + + /** + Bindable sink for `scrollEnabled` property. + */ + public var scrollEnabled: AnyObserver { + return UIBindingObserver(UIElement: self.base) { scrollView, scrollEnabled in + scrollView.isScrollEnabled = scrollEnabled + }.asObserver() + } + + /** + Installs delegate as forwarding delegate on `delegate`. + Delegate won't be retained. + + It enables using normal delegate mechanism with reactive delegate mechanism. + + - parameter delegate: Delegate object. + - returns: Disposable object that can be used to unbind the delegate. + */ + public func setDelegate(_ delegate: UIScrollViewDelegate) + -> Disposable { + return RxScrollViewDelegateProxy.installForwardDelegate(delegate, retainDelegate: false, onProxyForObject: self.base) + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift new file mode 100644 index 0000000..015687d --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UISearchBar+Rx.swift @@ -0,0 +1,155 @@ +// +// UISearchBar+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 3/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + + +#if os(iOS) + extension UISearchBar { + /** + Factory method that enables subclasses to implement their own `delegate`. + + - returns: Instance of delegate proxy that wraps `delegate`. + */ + public func createRxDelegateProxy() -> RxSearchBarDelegateProxy { + return RxSearchBarDelegateProxy(parentObject: self) + } + + } +#endif + +extension Reactive where Base: UISearchBar { + + /** + Reactive wrapper for `delegate`. + + For more information take a look at `DelegateProxyType` protocol documentation. + */ + public var delegate: DelegateProxy { + return RxSearchBarDelegateProxy.proxyForObject(base) + } + + /** + Reactive wrapper for `text` property. + */ + public var text: ControlProperty { + let source: Observable = Observable.deferred { [weak searchBar = self.base as UISearchBar] () -> Observable in + let text = searchBar?.text ?? "" + + return (searchBar?.rx.delegate.methodInvoked(#selector(UISearchBarDelegate.searchBar(_:textDidChange:))) ?? Observable.empty()) + .map { a in + return a[1] as? String ?? "" + } + .startWith(text) + } + + let bindingObserver = UIBindingObserver(UIElement: self.base) { (searchBar, text: String) in + searchBar.text = text + } + + return ControlProperty(values: source, valueSink: bindingObserver) + } + + /** + Reactive wrapper for `selectedScopeButtonIndex` property. + */ + public var selectedScopeButtonIndex: ControlProperty { + let source: Observable = Observable.deferred { [weak source = self.base as UISearchBar] () -> Observable in + let index = source?.selectedScopeButtonIndex ?? 0 + + return (source?.rx.delegate.methodInvoked(#selector(UISearchBarDelegate.searchBar(_:selectedScopeButtonIndexDidChange:))) ?? Observable.empty()) + .map { a in + return try castOrThrow(Int.self, a[1]) + } + .startWith(index) + } + + let bindingObserver = UIBindingObserver(UIElement: self.base) { (searchBar, index: Int) in + searchBar.selectedScopeButtonIndex = index + } + + return ControlProperty(values: source, valueSink: bindingObserver) + } + +#if os(iOS) + /** + Reactive wrapper for delegate method `searchBarCancelButtonClicked`. + */ + public var cancelButtonClicked: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UISearchBarDelegate.searchBarCancelButtonClicked(_:))) + .map { _ in + return () + } + return ControlEvent(events: source) + } + + /** + Reactive wrapper for delegate method `searchBarBookmarkButtonClicked`. + */ + public var bookmarkButtonClicked: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UISearchBarDelegate.searchBarBookmarkButtonClicked(_:))) + .map { _ in + return () + } + return ControlEvent(events: source) + } + + /** + Reactive wrapper for delegate method `searchBarResultsListButtonClicked`. + */ + public var resultsListButtonClicked: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UISearchBarDelegate.searchBarResultsListButtonClicked(_:))) + .map { _ in + return () + } + return ControlEvent(events: source) + } +#endif + + /** + Reactive wrapper for delegate method `searchBarSearchButtonClicked`. + */ + public var searchButtonClicked: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UISearchBarDelegate.searchBarSearchButtonClicked(_:))) + .map { _ in + return () + } + return ControlEvent(events: source) + } + + /** + Reactive wrapper for delegate method `searchBarTextDidBeginEditing`. + */ + public var textDidBeginEditing: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UISearchBarDelegate.searchBarTextDidBeginEditing(_:))) + .map { _ in + return () + } + return ControlEvent(events: source) + } + + /** + Reactive wrapper for delegate method `searchBarTextDidEndEditing`. + */ + public var textDidEndEditing: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UISearchBarDelegate.searchBarTextDidEndEditing(_:))) + .map { _ in + return () + } + return ControlEvent(events: source) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift new file mode 100644 index 0000000..aec1ccc --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UISearchController+Rx.swift @@ -0,0 +1,71 @@ +// +// UISearchController+Rx.swift +// Rx +// +// Created by Segii Shulga on 3/17/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if os(iOS) + import Foundation + +#if !RX_NO_MODULE + import RxSwift +#endif + import UIKit + +@available(iOS 8.0, *) +extension Reactive where Base: UISearchController { + /** + Reactive wrapper for `delegate`. + For more information take a look at `DelegateProxyType` protocol documentation. + */ + public var delegate: DelegateProxy { + return RxSearchControllerDelegateProxy.proxyForObject(base) + } + /** + Reactive wrapper for `delegate` message. + */ + public var didDismiss: Observable { + return delegate + .methodInvoked( #selector(UISearchControllerDelegate.didDismissSearchController(_:))) + .map {_ in} + } + /** + Reactive wrapper for `delegate` message. + */ + public var didPresent: Observable { + return delegate + .methodInvoked(#selector(UISearchControllerDelegate.didPresentSearchController(_:))) + .map {_ in} + } + /** + Reactive wrapper for `delegate` message. + */ + public var present: Observable { + return delegate + .methodInvoked( #selector(UISearchControllerDelegate.presentSearchController(_:))) + .map {_ in} + } + /** + Reactive wrapper for `delegate` message. + */ + public var willDismiss: Observable { + return delegate + .methodInvoked(#selector(UISearchControllerDelegate.willDismissSearchController(_:))) + .map {_ in} + } + /** + Reactive wrapper for `delegate` message. + */ + public var willPresent: Observable { + return delegate + .methodInvoked( #selector(UISearchControllerDelegate.willPresentSearchController(_:))) + .map {_ in} + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UISegmentedControl+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UISegmentedControl+Rx.swift new file mode 100644 index 0000000..6d7eeab --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UISegmentedControl+Rx.swift @@ -0,0 +1,35 @@ +// +// UISegmentedControl+Rx.swift +// RxCocoa +// +// Created by Carlos García on 8/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + + +extension Reactive where Base: UISegmentedControl { + + /** + Reactive wrapper for `selectedSegmentIndex` property. + */ + public var value: ControlProperty { + return UIControl.rx.value( + self.base, + getter: { segmentedControl in + segmentedControl.selectedSegmentIndex + }, setter: { segmentedControl, value in + segmentedControl.selectedSegmentIndex = value + } + ) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UISlider+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UISlider+Rx.swift new file mode 100644 index 0000000..c188529 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UISlider+Rx.swift @@ -0,0 +1,35 @@ +// +// UISlider+Rx.swift +// RxCocoa +// +// Created by Alexander van der Werff on 28/05/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UISlider { + + /** + Reactive wrapper for `value` property. + */ + public var value: ControlProperty { + return UIControl.rx.value( + self.base, + getter: { slider in + slider.value + }, setter: { slider, value in + slider.value = value + } + ) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIStepper+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIStepper+Rx.swift new file mode 100644 index 0000000..0b9aaa9 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIStepper+Rx.swift @@ -0,0 +1,36 @@ +// +// UIStepper+Rx.swift +// RxCocoa +// +// Created by Yuta ToKoRo on 9/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +extension Reactive where Base: UIStepper { + + /** + Reactive wrapper for `value` property. + */ + public var value: ControlProperty { + return UIControl.rx.value( + self.base, + getter: { stepper in + stepper.value + }, setter: { stepper, value in + stepper.value = value + } + ) + } + +} + +#endif + diff --git a/Pods/RxCocoa/RxCocoa/iOS/UISwitch+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UISwitch+Rx.swift new file mode 100644 index 0000000..995b886 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UISwitch+Rx.swift @@ -0,0 +1,40 @@ +// +// UISwitch+Rx.swift +// RxCocoa +// +// Created by Carlos García on 8/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) + +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + + +extension Reactive where Base: UISwitch { + + /** + Reactive wrapper for `on` property. + + **⚠️Unlike other controls, Apple is reusing instances of UISwitch or a there is a leak, + so underlying observable sequence won't complete when nothing holds a strong reference + to UISwitch.⚠️** + */ + public var value: ControlProperty { + return UIControl.rx.value( + self.base, + getter: { uiSwitch in + uiSwitch.isOn + }, setter: { uiSwitch, value in + uiSwitch.isOn = value + } + ) + } + +} + +#endif + diff --git a/Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift new file mode 100644 index 0000000..f269a0f --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UITabBar+Rx.swift @@ -0,0 +1,119 @@ +// +// UITabBar+Rx.swift +// Rx +// +// Created by Jesse Farless on 5/13/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) +import Foundation +import UIKit + +#if !RX_NO_MODULE +import RxSwift +#endif + +/** + iOS only + */ +#if os(iOS) +extension Reactive where Base: UITabBar { + + /** + Reactive wrapper for `delegate` message `tabBar:willBeginCustomizingItems:`. + */ + public var willBeginCustomizing: ControlEvent<[UITabBarItem]> { + + let source = delegate.methodInvoked(#selector(UITabBarDelegate.tabBar(_:willBeginCustomizing:))) + .map { a in + return try castOrThrow([UITabBarItem].self, a[1]) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tabBar:didBeginCustomizingItems:`. + */ + public var didBeginCustomizing: ControlEvent<[UITabBarItem]> { + let source = delegate.methodInvoked(#selector(UITabBarDelegate.tabBar(_:didBeginCustomizing:))) + .map { a in + return try castOrThrow([UITabBarItem].self, a[1]) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tabBar:willEndCustomizingItems:changed:`. + */ + public var willEndCustomizing: ControlEvent<([UITabBarItem], Bool)> { + let source = delegate.methodInvoked(#selector(UITabBarDelegate.tabBar(_:willEndCustomizing:changed:))) + .map { (a: [Any]) -> (([UITabBarItem], Bool)) in + let items = try castOrThrow([UITabBarItem].self, a[1]) + let changed = try castOrThrow(Bool.self, a[2]) + return (items, changed) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tabBar:didEndCustomizingItems:changed:`. + */ + public var didEndCustomizing: ControlEvent<([UITabBarItem], Bool)> { + let source = delegate.methodInvoked(#selector(UITabBarDelegate.tabBar(_:didEndCustomizing:changed:))) + .map { (a: [Any]) -> (([UITabBarItem], Bool)) in + let items = try castOrThrow([UITabBarItem].self, a[1]) + let changed = try castOrThrow(Bool.self, a[2]) + return (items, changed) + } + + return ControlEvent(events: source) + } + +} +#endif + +/** + iOS and tvOS + */ +extension UITabBar { + + /** + Factory method that enables subclasses to implement their own `delegate`. + + - returns: Instance of delegate proxy that wraps `delegate`. + */ + public func createRxDelegateProxy() -> RxTabBarDelegateProxy { + return RxTabBarDelegateProxy(parentObject: self) + } + +} + +extension Reactive where Base: UITabBar { + /** + Reactive wrapper for `delegate`. + + For more information take a look at `DelegateProxyType` protocol documentation. + */ + public var delegate: DelegateProxy { + return RxTabBarDelegateProxy.proxyForObject(base) + } + + /** + Reactive wrapper for `delegate` message `tabBar:didSelectItem:`. + */ + public var didSelectItem: ControlEvent { + let source = delegate.methodInvoked(#selector(UITabBarDelegate.tabBar(_:didSelect:))) + .map { a in + return try castOrThrow(UITabBarItem.self, a[1]) + } + + return ControlEvent(events: source) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift new file mode 100644 index 0000000..fc170ad --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UITabBarItem+Rx.swift @@ -0,0 +1,30 @@ +// +// UITabBarItem+Rx.swift +// Rx +// +// Created by Mateusz Derks on 04/03/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + + import Foundation + import UIKit +#if !RX_NO_MODULE + import RxSwift +#endif + +extension Reactive where Base: UITabBarItem { + + /** + Bindable sink for `badgeValue` property. + */ + public var badgeValue: AnyObserver { + return UIBindingObserver(UIElement: self.base) { tabBarItem, badgeValue in + tabBarItem.badgeValue = badgeValue + }.asObserver() + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift new file mode 100644 index 0000000..084a115 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UITableView+Rx.swift @@ -0,0 +1,543 @@ +// +// UITableView+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 4/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +// Items + +extension Reactive where Base: UITableView { + + /** + Binds sequences of elements to table view rows. + + - parameter source: Observable sequence of items. + - parameter cellFactory: Transform between sequence elements and view cells. + - returns: Disposable object that can be used to unbind. + + Example: + + let items = Observable.just([ + "First Item", + "Second Item", + "Third Item" + ]) + + items + .bindTo(tableView.rx.items) { (tableView, row, element) in + let cell = tableView.dequeueReusableCellWithIdentifier("Cell")! + cell.textLabel?.text = "\(element) @ row \(row)" + return cell + } + .addDisposableTo(disposeBag) + + */ + public func items + (_ source: O) + -> (_ cellFactory: @escaping (UITableView, Int, S.Iterator.Element) -> UITableViewCell) + -> Disposable + where O.E == S { + return { cellFactory in + let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper(cellFactory: cellFactory) + return self.items(dataSource: dataSource)(source) + } + } + + /** + Binds sequences of elements to table view rows. + + - parameter cellIdentifier: Identifier used to dequeue cells. + - parameter source: Observable sequence of items. + - parameter configureCell: Transform between sequence elements and view cells. + - parameter cellType: Type of table view cell. + - returns: Disposable object that can be used to unbind. + + Example: + + let items = Observable.just([ + "First Item", + "Second Item", + "Third Item" + ]) + + items + .bindTo(tableView.items(cellIdentifier: "Cell", cellType: UITableViewCell.self)) { (row, element, cell) in + cell.textLabel?.text = "\(element) @ row \(row)" + } + .addDisposableTo(disposeBag) + */ + public func items + (cellIdentifier: String, cellType: Cell.Type = Cell.self) + -> (_ source: O) + -> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void) + -> Disposable + where O.E == S { + return { source in + return { configureCell in + let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper { (tv, i, item) in + let indexPath = IndexPath(item: i, section: 0) + let cell = tv.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! Cell + configureCell(i, item, cell) + return cell + } + return self.items(dataSource: dataSource)(source) + } + } + } + + + /** + Binds sequences of elements to table view rows using a custom reactive data used to perform the transformation. + This method will retain the data source for as long as the subscription isn't disposed (result `Disposable` + being disposed). + In case `source` observable sequence terminates sucessfully, the data source will present latest element + until the subscription isn't disposed. + + - parameter dataSource: Data source used to transform elements to view cells. + - parameter source: Observable sequence of items. + - returns: Disposable object that can be used to unbind. + + Example + + let dataSource = RxTableViewSectionedReloadDataSource>() + + let items = Observable.just([ + SectionModel(model: "First section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Second section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Third section", items: [ + 1.0, + 2.0, + 3.0 + ]) + ]) + + dataSource.configureCell = { (dataSource, tv, indexPath, element) in + let cell = tv.dequeueReusableCellWithIdentifier("Cell")! + cell.textLabel?.text = "\(element) @ row \(indexPath.row)" + return cell + } + + items + .bindTo(tableView.rx.items(dataSource: dataSource)) + .addDisposableTo(disposeBag) + */ + public func items< + DataSource: RxTableViewDataSourceType & UITableViewDataSource, + O: ObservableType> + (dataSource: DataSource) + -> (_ source: O) + -> Disposable + where DataSource.Element == O.E { + return { source in + // This is called for sideeffects only, and to make sure delegate proxy is in place when + // data source is being bound. + // This is needed because theoretically the data source subscription itself might + // call `self.rx_delegate`. If that happens, it might cause weird side effects since + // setting data source will set delegate, and UITableView might get into a weird state. + // Therefore it's better to set delegate proxy first, just to be sure. + _ = self.delegate + // Strong reference is needed because data source is in use until result subscription is disposed + return source.subscribeProxyDataSource(ofObject: self.base, dataSource: dataSource, retainDataSource: true) { [weak tableView = self.base] (_: RxTableViewDataSourceProxy, event) -> Void in + guard let tableView = tableView else { + return + } + dataSource.tableView(tableView, observedEvent: event) + } + } + } + +} + +extension UITableView { + + /** + Factory method that enables subclasses to implement their own `delegate`. + + - returns: Instance of delegate proxy that wraps `delegate`. + */ + public override func createRxDelegateProxy() -> RxScrollViewDelegateProxy { + return RxTableViewDelegateProxy(parentObject: self) + } + + /** + Factory method that enables subclasses to implement their own `rx.dataSource`. + + - returns: Instance of delegate proxy that wraps `dataSource`. + */ + public func createRxDataSourceProxy() -> RxTableViewDataSourceProxy { + return RxTableViewDataSourceProxy(parentObject: self) + } + +} + +extension Reactive where Base: UITableView { + /** + Reactive wrapper for `dataSource`. + + For more information take a look at `DelegateProxyType` protocol documentation. + */ + public var dataSource: DelegateProxy { + return RxTableViewDataSourceProxy.proxyForObject(base) + } + + /** + Installs data source as forwarding delegate on `rx.dataSource`. + Data source won't be retained. + + It enables using normal delegate mechanism with reactive delegate mechanism. + + - parameter dataSource: Data source object. + - returns: Disposable object that can be used to unbind the data source. + */ + public func setDataSource(_ dataSource: UITableViewDataSource) + -> Disposable { + return RxTableViewDataSourceProxy.installForwardDelegate(dataSource, retainDelegate: false, onProxyForObject: self.base) + } + + // events + + /** + Reactive wrapper for `delegate` message `tableView:didSelectRowAtIndexPath:`. + */ + public var itemSelected: ControlEvent { + let source = self.delegate.methodInvoked(#selector(UITableViewDelegate.tableView(_:didSelectRowAt:))) + .map { a in + return try castOrThrow(IndexPath.self, a[1]) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:didDeselectRowAtIndexPath:`. + */ + public var itemDeselected: ControlEvent { + let source = self.delegate.methodInvoked(#selector(UITableViewDelegate.tableView(_:didDeselectRowAt:))) + .map { a in + return try castOrThrow(IndexPath.self, a[1]) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:accessoryButtonTappedForRowWithIndexPath:`. + */ + public var itemAccessoryButtonTapped: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UITableViewDelegate.tableView(_:accessoryButtonTappedForRowWith:))) + .map { a in + return try castOrThrow(IndexPath.self, a[1]) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:commitEditingStyle:forRowAtIndexPath:`. + */ + public var itemInserted: ControlEvent { + let source = self.dataSource.methodInvoked(#selector(UITableViewDataSource.tableView(_:commit:forRowAt:))) + .filter { a in + return UITableViewCellEditingStyle(rawValue: (try castOrThrow(NSNumber.self, a[1])).intValue) == .insert + } + .map { a in + return (try castOrThrow(IndexPath.self, a[2])) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:commitEditingStyle:forRowAtIndexPath:`. + */ + public var itemDeleted: ControlEvent { + let source = self.dataSource.methodInvoked(#selector(UITableViewDataSource.tableView(_:commit:forRowAt:))) + .filter { a in + return UITableViewCellEditingStyle(rawValue: (try castOrThrow(NSNumber.self, a[1])).intValue) == .delete + } + .map { a in + return try castOrThrow(IndexPath.self, a[2]) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:moveRowAtIndexPath:toIndexPath:`. + */ + public var itemMoved: ControlEvent { + let source: Observable = self.dataSource.methodInvoked(#selector(UITableViewDataSource.tableView(_:moveRowAt:to:))) + .map { a in + return (try castOrThrow(IndexPath.self, a[1]), try castOrThrow(IndexPath.self, a[2])) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:willDisplayCell:forRowAtIndexPath:`. + */ + public var willDisplayCell: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UITableViewDelegate.tableView(_:willDisplay:forRowAt:))) + .map { a in + return (try castOrThrow(UITableViewCell.self, a[1]), try castOrThrow(IndexPath.self, a[2])) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:didEndDisplayingCell:forRowAtIndexPath:`. + */ + public var didEndDisplayingCell: ControlEvent { + let source: Observable = self.delegate.methodInvoked(#selector(UITableViewDelegate.tableView(_:didEndDisplaying:forRowAt:))) + .map { a in + return (try castOrThrow(UITableViewCell.self, a[1]), try castOrThrow(IndexPath.self, a[2])) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:didSelectRowAtIndexPath:`. + + It can be only used when one of the `rx.itemsWith*` methods is used to bind observable sequence, + or any other data source conforming to `SectionedViewDataSourceType` protocol. + + ``` + tableView.rx.modelSelected(MyModel.self) + .map { ... + ``` + */ + public func modelSelected(_ modelType: T.Type) -> ControlEvent { + let source: Observable = self.itemSelected.flatMap { [weak view = self.base as UITableView] indexPath -> Observable in + guard let view = view else { + return Observable.empty() + } + + return Observable.just(try view.rx.model(indexPath)) + } + + return ControlEvent(events: source) + } + + /** + Reactive wrapper for `delegate` message `tableView:didDeselectRowAtIndexPath:`. + + It can be only used when one of the `rx.itemsWith*` methods is used to bind observable sequence, + or any other data source conforming to `SectionedViewDataSourceType` protocol. + + ``` + tableView.rx.modelDeselected(MyModel.self) + .map { ... + ``` + */ + public func modelDeselected(_ modelType: T.Type) -> ControlEvent { + let source: Observable = self.itemDeselected.flatMap { [weak view = self.base as UITableView] indexPath -> Observable in + guard let view = view else { + return Observable.empty() + } + + return Observable.just(try view.rx.model(indexPath)) + } + + return ControlEvent(events: source) + } + + /** + Synchronous helper method for retrieving a model at indexPath through a reactive data source. + */ + public func model(_ indexPath: IndexPath) throws -> T { + let dataSource: SectionedViewDataSourceType = castOrFatalError(self.dataSource.forwardToDelegate(), message: "This method only works in case one of the `rx.items*` methods was used.") + + let element = try dataSource.model(indexPath) + + return castOrFatalError(element) + } +} + +#endif + +#if os(tvOS) + + extension Reactive where Base: UITableView { + + /** + Reactive wrapper for `delegate` message `tableView:didUpdateFocusInContext:withAnimationCoordinator:`. + */ + public var didUpdateFocusInContextWithAnimationCoordinator: ControlEvent<(context: UIFocusUpdateContext, animationCoordinator: UIFocusAnimationCoordinator)> { + + let source = delegate.observe(#selector(UITableViewDelegate.tableView(_:didUpdateFocusIn:with:))) + .map { a -> (context: UIFocusUpdateContext, animationCoordinator: UIFocusAnimationCoordinator) in + let context = a[1] as! UIFocusUpdateContext + let animationCoordinator = try castOrThrow(UIFocusAnimationCoordinator.self, a[2]) + return (context: context, animationCoordinator: animationCoordinator) + } + + return ControlEvent(events: source) + } + } +#endif + +#if os(iOS) || os(tvOS) + +// deprecated APIs +extension UITableView { + + /** + Binds sequences of elements to table view rows. + + - parameter source: Observable sequence of items. + - parameter cellFactory: Transform between sequence elements and view cells. + - returns: Disposable object that can be used to unbind. + + Example: + + let items = Observable.just([ + "First Item", + "Second Item", + "Third Item" + ]) + + items + .bindTo(tableView.rx.itemsWithCellFactory) { (tableView, row, element) in + let cell = tableView.dequeueReusableCellWithIdentifier("Cell")! + cell.textLabel?.text = "\(element) @ row \(row)" + return cell + } + .addDisposableTo(disposeBag) + + */ + @available(*, deprecated, renamed: "rx.items(_:_:)") + public func rx_itemsWithCellFactory + (_ source: O) + -> (_ cellFactory: @escaping (UITableView, Int, S.Iterator.Element) -> UITableViewCell) + -> Disposable + where O.E == S { + return { cellFactory in + return self.rx.items(source)(cellFactory) + } + } + + /** + Binds sequences of elements to table view rows. + + - parameter cellIdentifier: Identifier used to dequeue cells. + - parameter source: Observable sequence of items. + - parameter configureCell: Transform between sequence elements and view cells. + - parameter cellType: Type of table view cell. + - returns: Disposable object that can be used to unbind. + + Example: + + let items = Observable.just([ + "First Item", + "Second Item", + "Third Item" + ]) + + items + .bindTo(tableView.rx.items(cellIdentifier: "Cell", cellType: UITableViewCell.self)) { (row, element, cell) in + cell.textLabel?.text = "\(element) @ row \(row)" + } + .addDisposableTo(disposeBag) + */ + @available(*, deprecated, renamed: "rx.items(cellIdentifier:cellType:_:_:)") + public func rx_itemsWithCellIdentifier + (_ cellIdentifier: String, cellType: Cell.Type = Cell.self) + -> (_ source: O) + -> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void) + -> Disposable + where O.E == S { + return { source in + return { configureCell in + return self.rx.items(cellIdentifier: cellIdentifier, cellType: cellType)(source)(configureCell) + } + } + } + + /** + Binds sequences of elements to table view rows using a custom reactive data used to perform the transformation. + This method will retain the data source for as long as the subscription isn't disposed (result `Disposable` + being disposed). + In case `source` observable sequence terminates sucessfully, the data source will present latest element + until the subscription isn't disposed. + + - parameter dataSource: Data source used to transform elements to view cells. + - parameter source: Observable sequence of items. + - returns: Disposable object that can be used to unbind. + + Example + + let dataSource = RxTableViewSectionedReloadDataSource>() + + let items = Observable.just([ + SectionModel(model: "First section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Second section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Third section", items: [ + 1.0, + 2.0, + 3.0 + ]) + ]) + + dataSource.configureCell = { (dataSource, tv, indexPath, element) in + let cell = tv.dequeueReusableCellWithIdentifier("Cell")! + cell.textLabel?.text = "\(element) @ row \(indexPath.row)" + return cell + } + + items + .bindTo(tableView.rx.items(dataSoruce: dataSource)) + .addDisposableTo(disposeBag) + */ + @available(*, deprecated, renamed: "rx.items(dataSource:_:)") + public func rx_itemsWithDataSource< + DataSource: RxTableViewDataSourceType & UITableViewDataSource, + O: ObservableType> + (_ dataSource: DataSource) + -> (_ source: O) + -> Disposable + where DataSource.Element == O.E + { + return { source in + return self.rx.items(dataSource: dataSource)(source) + } + } + + /** + Synchronous helper method for retrieving a model at indexPath through a reactive data source. + */ + @available(*, deprecated, renamed: "rx.model(_:)") + public func rx_modelAtIndexPath(_ indexPath: IndexPath) throws -> T { + return try self.rx.model(indexPath) + } + +} +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift new file mode 100644 index 0000000..79344bb --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UITextField+Rx.swift @@ -0,0 +1,40 @@ +// +// UITextField+Rx.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +#if !RX_NO_MODULE +import RxSwift +#endif +import UIKit + +extension Reactive where Base: UITextField { + + /** + Reactive wrapper for `text` property. + */ + public var text: ControlProperty { + return UIControl.rx.value( + base, + getter: { textField in + textField.text ?? "" + }, setter: { textField, value in + // This check is important because setting text value always clears control state + // including marked text selection which is imporant for proper input + // when IME input method is used. + if textField.text != value { + textField.text = value + } + } + ) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift new file mode 100644 index 0000000..a528359 --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UITextView+Rx.swift @@ -0,0 +1,111 @@ +// +// UITextView+Rx.swift +// RxCocoa +// +// Created by Yuta ToKoRo on 7/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + + + +extension UITextView { + + /** + Factory method that enables subclasses to implement their own `delegate`. + + - returns: Instance of delegate proxy that wraps `delegate`. + */ + public override func createRxDelegateProxy() -> RxScrollViewDelegateProxy { + return RxTextViewDelegateProxy(parentObject: self) + } +} + +extension Reactive where Base: UITextView { + /** + Reactive wrapper for `text` property. + */ + public var text: ControlProperty { + let source: Observable = Observable.deferred { [weak textView = self.base] in + let text = textView?.text ?? "" + + let textChanged = textView?.textStorage + // This project uses text storage notifications because + // that's the only way to catch autocorrect changes + // in all cases. Other suggestions are welcome. + .rx.didProcessEditingRangeChangeInLength + // This observe on is here because text storage + // will emit event while process is not completely done, + // so rebinding a value will cause an exception to be thrown. + .observeOn(MainScheduler.asyncInstance) + .map { _ in + return textView?.textStorage.string ?? "" + } + ?? Observable.empty() + + return textChanged + .startWith(text) + } + + let bindingObserver = UIBindingObserver(UIElement: self.base) { (textView, text: String) in + // This check is important because setting text value always clears control state + // including marked text selection which is imporant for proper input + // when IME input method is used. + if textView.text != text { + textView.text = text + } + } + + return ControlProperty(values: source, valueSink: bindingObserver) + } + + /** + Reactive wrapper for `delegate` message. + */ + public var didBeginEditing: ControlEvent<()> { + return ControlEvent<()>(events: self.delegate.methodInvoked(#selector(UITextViewDelegate.textViewDidBeginEditing(_:))) + .map { a in + return () + }) + } + + /** + Reactive wrapper for `delegate` message. + */ + public var didEndEditing: ControlEvent<()> { + return ControlEvent<()>(events: self.delegate.methodInvoked(#selector(UITextViewDelegate.textViewDidEndEditing(_:))) + .map { a in + return () + }) + } + + /** + Reactive wrapper for `delegate` message. + */ + public var didChange: ControlEvent<()> { + return ControlEvent<()>(events: self.delegate.methodInvoked(#selector(UITextViewDelegate.textViewDidChange(_:))) + .map { a in + return () + }) + } + + /** + Reactive wrapper for `delegate` message. + */ + public var didChangeSelection: ControlEvent<()> { + return ControlEvent<()>(events: self.delegate.methodInvoked(#selector(UITextViewDelegate.textViewDidChangeSelection(_:))) + .map { a in + return () + }) + } + +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift new file mode 100644 index 0000000..5c67ded --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIView+Rx.swift @@ -0,0 +1,37 @@ +// +// UIView+Rx.swift +// Rx +// +// Created by Krunoslav Zaher on 12/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(iOS) || os(tvOS) + +import Foundation +import UIKit +#if !RX_NO_MODULE +import RxSwift +#endif + +extension Reactive where Base: UIView { + /** + Bindable sink for `hidden` property. + */ + public var hidden: AnyObserver { + return UIBindingObserver(UIElement: self.base) { view, hidden in + view.isHidden = hidden + }.asObserver() + } + + /** + Bindable sink for `alpha` property. + */ + public var alpha: AnyObserver { + return UIBindingObserver(UIElement: self.base) { view, alpha in + view.alpha = alpha + }.asObserver() + } +} + +#endif diff --git a/Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift b/Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift new file mode 100644 index 0000000..2a284bd --- /dev/null +++ b/Pods/RxCocoa/RxCocoa/iOS/UIViewController+Rx.swift @@ -0,0 +1,29 @@ +// +// UIViewController+Rx.swift +// Rx +// +// Created by Kyle Fuller on 27/05/2016. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if os(iOS) + import UIKit + +#if !RX_NO_MODULE + import RxSwift +#endif + + extension Reactive where Base: UIViewController { + + /** + Bindable sink for `title`. + */ + public var title: AnyObserver { + return UIBindingObserver(UIElement: self.base) { viewController, title in + viewController.title = title + }.asObserver() + } + } +#endif diff --git a/Pods/RxSwift/LICENSE.md b/Pods/RxSwift/LICENSE.md new file mode 100644 index 0000000..d6765d9 --- /dev/null +++ b/Pods/RxSwift/LICENSE.md @@ -0,0 +1,9 @@ +**The MIT License** +**Copyright © 2015 Krunoslav Zaher** +**All rights reserved.** + +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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +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. \ No newline at end of file diff --git a/Pods/RxSwift/README.md b/Pods/RxSwift/README.md new file mode 100644 index 0000000..5e47efa --- /dev/null +++ b/Pods/RxSwift/README.md @@ -0,0 +1,198 @@ +Miss Electric Eel 2016 RxSwift: ReactiveX for Swift +====================================== + +[![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux%28experimental%29-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) + +## About Rx + +**:warning: This readme describes RxSwift 3.0 version that requires Swift 3.0.** + +**:warning: If you are looking for Swift 2.3 compatible version, please take a look at RxSwift ~> 2.0 versions and [swift-2.3](https://github.com/ReactiveX/RxSwift/tree/rxswift-2.0) branch.** + +Rx is a [generic abstraction of computation](https://youtu.be/looJcaeboBY) expressed through `Observable` interface. + +This is a Swift version of [Rx](https://github.com/Reactive-Extensions/Rx.NET). + +It tries to port as many concepts from the original version as possible, but some concepts were adapted for more pleasant and performant integration with iOS/OSX environment. + +Cross platform documentation can be found on [ReactiveX.io](http://reactivex.io/). + +Like the original Rx, its intention is to enable easy composition of asynchronous operations and event/data streams. + +KVO observing, async operations and streams are all unified under [abstraction of sequence](Documentation/GettingStarted.md#observables-aka-sequences). This is the reason why Rx is so simple, elegant and powerful. + +## I came here because I want to ... + +###### ... understand + +* [why use rx?](Documentation/Why.md) +* [the basics, getting started with RxSwift](Documentation/GettingStarted.md) +* [units](Documentation/Units.md) - what is `Driver`, `ControlProperty`, and `Variable` ... and why do they exist? +* [testing](Documentation/UnitTests.md) +* [tips and common errors](Documentation/Tips.md) +* [debugging](Documentation/GettingStarted.md#debugging) +* [the math behind Rx](Documentation/MathBehindRx.md) +* [what are hot and cold observable sequences?](Documentation/HotAndColdObservables.md) +* [what does the the public API look like?](Documentation/API.md) + + +###### ... install + +* Integrate RxSwift/RxCocoa with my app. [Installation Guide](#installation) + +###### ... hack around + +* with the example app. [Running Example App](Documentation/ExampleApp.md) +* with operators in playgrounds. [Playgrounds](Documentation/Playgrounds.md) + +###### ... interact + +* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences.
[![Slack channel](http://rxswift-slack.herokuapp.com/badge.svg)](http://slack.rxswift.org) [Join Slack Channel](http://rxswift-slack.herokuapp.com) +* Report a problem using the library. [Open an Issue With Bug Template](ISSUE_TEMPLATE.md) +* Request a new feature. [Open an Issue With Feature Request Template](Documentation/NewFeatureRequestTemplate.md) + + +###### ... compare + +* [with other libraries](Documentation/ComparisonWithOtherLibraries.md). + + +###### ... find compatible + +* libraries from [RxSwiftCommunity](https://github.com/RxSwiftCommunity). +* [Pods using RxSwift](https://cocoapods.org/?q=uses%3Arxswift). + +###### ... see the broader vision + +* Does this exist for Android? [RxJava](https://github.com/ReactiveX/RxJava) +* Where is all of this going, what is the future, what about reactive architectures, how do you design entire apps this way? [Cycle.js](https://github.com/cyclejs/cycle-core) - this is javascript, but [RxJS](https://github.com/Reactive-Extensions/RxJS) is javascript version of Rx. + +## Usage + + + + + + + + + + + + + + + + + + + +
Here's an exampleIn Action
Define search for GitHub repositories ...
+let searchResults = searchBar.rx.text
+    .throttle(0.3, scheduler: MainScheduler.instance)
+    .distinctUntilChanged()
+    .flatMapLatest { query -> Observable<[Repository]> in
+        if query.isEmpty {
+            return .just([])
+        }
+
+        return searchGitHub(query)
+            .catchErrorJustReturn([])
+    }
+    .observeOn(MainScheduler.instance)
... then bind the results to your tableview
+searchResults
+    .bindTo(tableView.rx.items(cellIdentifier: "Cell")) {
+        (index, repository: Repository, cell) in
+        cell.textLabel?.text = repository.name
+        cell.detailTextLabel?.text = repository.url
+    }
+    .addDisposableTo(disposeBag)
+ + +## Requirements + +* Xcode 8.0 +* Swift 3.0 + +## Installation + +Rx doesn't contain any external dependencies. + +These are currently the supported options: + +### Manual + +Open Rx.xcworkspace, choose `RxExample` and hit run. This method will build everything and run the sample app + +### [CocoaPods](https://guides.cocoapods.org/using/using-cocoapods.html) + +``` +# Podfile +use_frameworks! + +target 'YOUR_TARGET_NAME' do + pod 'RxSwift', '~> 3.0.0-beta.2' + pod 'RxCocoa', '~> 3.0.0-beta.2' +end + +# RxTests and RxBlocking make the most sense in the context of unit/integration tests +target 'YOUR_TESTING_TARGET' do + pod 'RxBlocking', '~> 3.0.0-beta.2' + pod 'RxTests', '~> 3.0.0-beta.2' +end +``` + +Replace `YOUR_TARGET_NAME` and then, in the `Podfile` directory, type: + +**:warning: If you want to use CocoaPods with Xcode 8.0 beta and Swift 3.0, you might need to add the following +lines to your podfile: :warning:** + +``` +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['SWIFT_VERSION'] = '3.0' + config.build_settings['MACOSX_DEPLOYMENT_TARGET'] = '10.10' + end + end +end +``` + +``` +$ pod install +``` + +### [Carthage](https://github.com/Carthage/Carthage) + +Add this to `Cartfile` + +``` +github "ReactiveX/RxSwift" "3.0.0-beta.2" +``` + +``` +$ carthage update +``` + +### Manually using git submodules + +* Add RxSwift as a submodule + +``` +$ git submodule add git@github.com:ReactiveX/RxSwift.git +``` + +* Drag `Rx.xcodeproj` into Project Navigator +* Go to `Project > Targets > Build Phases > Link Binary With Libraries`, click `+` and select `RxSwift-[Platform]` and `RxCocoa-[Platform]` targets + + +## References + +* [http://reactivex.io/](http://reactivex.io/) +* [Reactive Extensions GitHub (GitHub)](https://github.com/Reactive-Extensions) +* [Erik Meijer (Wikipedia)](http://en.wikipedia.org/wiki/Erik_Meijer_%28computer_scientist%29) +* [Expert to Expert: Brian Beckman and Erik Meijer - Inside the .NET Reactive Framework (Rx) (video)](https://youtu.be/looJcaeboBY) +* [Reactive Programming Overview (Jafar Husain from Netflix)](https://www.youtube.com/watch?v=dwP1TNXE6fc) +* [Subject/Observer is Dual to Iterator (paper)](http://csl.stanford.edu/~christos/pldi2010.fit/meijer.duality.pdf) +* [Rx standard sequence operators visualized (visualization tool)](http://rxmarbles.com/) +* [Haskell](https://www.haskell.org/) diff --git a/Pods/RxSwift/RxSwift/AnyObserver.swift b/Pods/RxSwift/RxSwift/AnyObserver.swift new file mode 100644 index 0000000..d1e2171 --- /dev/null +++ b/Pods/RxSwift/RxSwift/AnyObserver.swift @@ -0,0 +1,75 @@ +// +// AnyObserver.swift +// Rx +// +// Created by Krunoslav Zaher on 2/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +A type-erased `ObserverType`. + +Forwards operations to an arbitrary underlying observer with the same `Element` type, hiding the specifics of the underlying observer type. +*/ +public struct AnyObserver : ObserverType { + /** + The type of elements in sequence that observer can observe. + */ + public typealias E = Element + + /** + Anonymous event handler type. + */ + public typealias EventHandler = (Event) -> Void + + public let observer: EventHandler + + /** + Construct an instance whose `on(event)` calls `eventHandler(event)` + + - parameter eventHandler: Event handler that observes sequences events. + */ + public init(eventHandler: @escaping EventHandler) { + self.observer = eventHandler + } + + /** + Construct an instance whose `on(event)` calls `observer.on(event)` + + - parameter observer: Observer that receives sequence events. + */ + public init(_ observer: O) where O.E == Element { + self.observer = observer.on + } + + /** + Send `event` to this observer. + + - parameter event: Event instance. + */ + public func on(_ event: Event) { + return self.observer(event) + } + + /** + Erases type of observer and returns canonical observer. + + - returns: type erased observer. + */ + public func asObserver() -> AnyObserver { + return self + } +} + +extension ObserverType { + /** + Erases type of observer and returns canonical observer. + + - returns: type erased observer. + */ + public func asObserver() -> AnyObserver { + return AnyObserver(self) + } +} diff --git a/Pods/RxSwift/RxSwift/Cancelable.swift b/Pods/RxSwift/RxSwift/Cancelable.swift new file mode 100644 index 0000000..209379c --- /dev/null +++ b/Pods/RxSwift/RxSwift/Cancelable.swift @@ -0,0 +1,28 @@ +// +// Cancelable.swift +// Rx +// +// Created by Krunoslav Zaher on 3/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents disposable resource with state tracking. +*/ +public protocol Cancelable : Disposable { + /** + - returns: Was resource disposed. + */ + var isDisposed: Bool { get } +} + +public extension Cancelable { + + @available(*, deprecated, renamed: "isDisposed") + var disposed: Bool { + return isDisposed + } + +} diff --git a/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift b/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift new file mode 100644 index 0000000..c534678 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift @@ -0,0 +1,104 @@ +// +// AsyncLock.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +In case nobody holds this lock, the work will be queued and executed immediately +on thread that is requesting lock. + +In case there is somebody currently holding that lock, action will be enqueued. +When owned of the lock finishes with it's processing, it will also execute +and pending work. + +That means that enqueued work could possibly be executed later on a different thread. +*/ +class AsyncLock + : Disposable + , Lock + , SynchronizedDisposeType { + typealias Action = () -> Void + + var _lock = SpinLock() + + private var _queue: Queue = Queue(capacity: 0) + + private var _isExecuting: Bool = false + private var _hasFaulted: Bool = false + + // lock { + func lock() { + _lock.lock() + } + + func unlock() { + _lock.unlock() + } + // } + + private func enqueue(_ action: I) -> I? { + _lock.lock(); defer { _lock.unlock() } // { + if _hasFaulted { + return nil + } + + if _isExecuting { + _queue.enqueue(action) + return nil + } + + _isExecuting = true + + return action + // } + } + + private func dequeue() -> I? { + _lock.lock(); defer { _lock.unlock() } // { + if _queue.count > 0 { + return _queue.dequeue() + } + else { + _isExecuting = false + return nil + } + // } + } + + func invoke(_ action: I) { + let firstEnqueuedAction = enqueue(action) + + if let firstEnqueuedAction = firstEnqueuedAction { + firstEnqueuedAction.invoke() + } + else { + // action is enqueued, it's somebody else's concern now + return + } + + while true { + let nextAction = dequeue() + + if let nextAction = nextAction { + nextAction.invoke() + } + else { + return + } + } + } + + func dispose() { + synchronizedDispose() + } + + func _synchronized_dispose() { + _queue = Queue(capacity: 0) + _hasFaulted = true + } +} diff --git a/Pods/RxSwift/RxSwift/Concurrency/Lock.swift b/Pods/RxSwift/RxSwift/Concurrency/Lock.swift new file mode 100644 index 0000000..5c9a2ae --- /dev/null +++ b/Pods/RxSwift/RxSwift/Concurrency/Lock.swift @@ -0,0 +1,107 @@ +// +// Lock.swift +// Rx +// +// Created by Krunoslav Zaher on 3/31/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol Lock { + func lock() + func unlock() +} + +#if os(Linux) + import Glibc + + /** + Simple wrapper for spin lock. + */ + class SpinLock { + private var _lock: pthread_spinlock_t = 0 + + init() { + if (pthread_spin_init(&_lock, 0) != 0) { + fatalError("Spin lock initialization failed") + } + } + + func lock() { + pthread_spin_lock(&_lock) + } + + func unlock() { + pthread_spin_unlock(&_lock) + } + + func performLocked(@noescape action: () -> Void) { + lock(); defer { unlock() } + action() + } + + func calculateLocked(@noescape action: () -> T) -> T { + lock(); defer { unlock() } + return action() + } + + func calculateLockedOrFail(@noescape action: () throws -> T) throws -> T { + lock(); defer { unlock() } + let result = try action() + return result + } + + deinit { + pthread_spin_destroy(&_lock) + } + } +#else + + // https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html + typealias SpinLock = NSRecursiveLock +#endif + +extension NSRecursiveLock : Lock { + func performLocked(_ action: () -> Void) { + lock(); defer { unlock() } + action() + } + + func calculateLocked(_ action: () -> T) -> T { + lock(); defer { unlock() } + return action() + } + + func calculateLockedOrFail(_ action: () throws -> T) throws -> T { + lock(); defer { unlock() } + let result = try action() + return result + } +} + +/* +let RECURSIVE_MUTEX = _initializeRecursiveMutex() + +func _initializeRecursiveMutex() -> pthread_mutex_t { + var mutex: pthread_mutex_t = pthread_mutex_t() + var mta: pthread_mutexattr_t = pthread_mutexattr_t() + + pthread_mutex_init(&mutex, nil) + pthread_mutexattr_init(&mta) + pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE) + pthread_mutex_init(&mutex, &mta) + + return mutex +} + +extension pthread_mutex_t { + mutating func lock() { + pthread_mutex_lock(&self) + } + + mutating func unlock() { + pthread_mutex_unlock(&self) + } +} +*/ diff --git a/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift b/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift new file mode 100644 index 0000000..fe61d72 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift @@ -0,0 +1,23 @@ +// +// LockOwnerType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol LockOwnerType : class, Lock { + var _lock: NSRecursiveLock { get } +} + +extension LockOwnerType { + func lock() { + _lock.lock() + } + + func unlock() { + _lock.unlock() + } +} diff --git a/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift b/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift new file mode 100644 index 0000000..5764575 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift @@ -0,0 +1,20 @@ +// +// SynchronizedDisposeType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol SynchronizedDisposeType : class, Disposable, Lock { + func _synchronized_dispose() +} + +extension SynchronizedDisposeType { + func synchronizedDispose() { + lock(); defer { unlock() } + _synchronized_dispose() + } +} \ No newline at end of file diff --git a/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift b/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift new file mode 100644 index 0000000..366253e --- /dev/null +++ b/Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift @@ -0,0 +1,20 @@ +// +// SynchronizedOnType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol SynchronizedOnType : class, ObserverType, Lock { + func _synchronized_on(_ event: Event) +} + +extension SynchronizedOnType { + func synchronizedOn(_ event: Event) { + lock(); defer { unlock() } + _synchronized_on(event) + } +} diff --git a/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift b/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift new file mode 100644 index 0000000..04fbdad --- /dev/null +++ b/Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift @@ -0,0 +1,20 @@ +// +// SynchronizedSubscribeType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol SynchronizedSubscribeType : class, ObservableType, Lock { + func _synchronized_subscribe(_ observer: O) -> Disposable where O.E == E +} + +extension SynchronizedSubscribeType { + func synchronizedSubscribe(_ observer: O) -> Disposable where O.E == E { + lock(); defer { unlock() } + return _synchronized_subscribe(observer) + } +} diff --git a/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift b/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift new file mode 100644 index 0000000..ce5deda --- /dev/null +++ b/Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift @@ -0,0 +1,15 @@ +// +// SynchronizedUnsubscribeType.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol SynchronizedUnsubscribeType : class { + associatedtype DisposeKey + + func synchronizedUnsubscribe(_ disposeKey: DisposeKey) +} diff --git a/Pods/RxSwift/RxSwift/ConnectableObservableType.swift b/Pods/RxSwift/RxSwift/ConnectableObservableType.swift new file mode 100644 index 0000000..6722a4c --- /dev/null +++ b/Pods/RxSwift/RxSwift/ConnectableObservableType.swift @@ -0,0 +1,21 @@ +// +// ConnectableObservableType.swift +// Rx +// +// Created by Krunoslav Zaher on 3/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents an observable sequence wrapper that can be connected and disconnected from its underlying observable sequence. +*/ +public protocol ConnectableObservableType : ObservableType { + /** + 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. + + - returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence. + */ + func connect() -> Disposable +} \ No newline at end of file diff --git a/Pods/RxSwift/RxSwift/DataStructures/Bag.swift b/Pods/RxSwift/RxSwift/DataStructures/Bag.swift new file mode 100644 index 0000000..d09078e --- /dev/null +++ b/Pods/RxSwift/RxSwift/DataStructures/Bag.swift @@ -0,0 +1,336 @@ +// +// Bag.swift +// Rx +// +// Created by Krunoslav Zaher on 2/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +import Swift + +let arrayDictionaryMaxSize = 30 + +/** +Class that enables using memory allocations as a means to uniquely identify objects. +*/ +class Identity { + // weird things have known to happen with Swift + var _forceAllocation: Int32 = 0 +} + +func hash(_ _x: Int) -> Int { + var x = _x + x = ((x >> 16) ^ x) &* 0x45d9f3b + x = ((x >> 16) ^ x) &* 0x45d9f3b + x = ((x >> 16) ^ x) + return x; +} + +/** +Unique identifier for object added to `Bag`. +*/ +public struct BagKey : Hashable { + let uniqueIdentity: Identity? + let key: Int + + public var hashValue: Int { + if let uniqueIdentity = uniqueIdentity { + return hash(key) ^ (ObjectIdentifier(uniqueIdentity).hashValue) + } + else { + return hash(key) + } + } +} + +/** +Compares two `BagKey`s. +*/ +public func == (lhs: BagKey, rhs: BagKey) -> Bool { + return lhs.key == rhs.key && lhs.uniqueIdentity === rhs.uniqueIdentity +} + +/** +Data structure that represents a bag of elements typed `T`. + +Single element can be stored multiple times. + +Time and space complexity of insertion an deletion is O(n). + +It is suitable for storing small number of elements. +*/ +public struct Bag : CustomDebugStringConvertible { + /** + Type of identifier for inserted elements. + */ + public typealias KeyType = BagKey + + fileprivate typealias ScopeUniqueTokenType = Int + + typealias Entry = (key: BagKey, value: T) + + fileprivate var _uniqueIdentity: Identity? + fileprivate var _nextKey: ScopeUniqueTokenType = 0 + + // data + + // first fill inline variables + fileprivate var _key0: BagKey? = nil + fileprivate var _value0: T? = nil + + fileprivate var _key1: BagKey? = nil + fileprivate var _value1: T? = nil + + // then fill "array dictionary" + fileprivate var _pairs = ContiguousArray() + + // last is sparse dictionary + fileprivate var _dictionary: [BagKey : T]? = nil + + fileprivate var _onlyFastPath = true + + /** + Creates new empty `Bag`. + */ + public init() { + } + + /** + Inserts `value` into bag. + + - parameter element: Element to insert. + - returns: Key that can be used to remove element from bag. + */ + public mutating func insert(_ element: T) -> BagKey { + _nextKey = _nextKey &+ 1 + +#if DEBUG + _nextKey = _nextKey % 20 +#endif + + if _nextKey == 0 { + _uniqueIdentity = Identity() + } + + let key = BagKey(uniqueIdentity: _uniqueIdentity, key: _nextKey) + + if _key0 == nil { + _key0 = key + _value0 = element + return key + } + + _onlyFastPath = false + + if _key1 == nil { + _key1 = key + _value1 = element + return key + } + + if _dictionary != nil { + _dictionary![key] = element + return key + } + + if _pairs.count < arrayDictionaryMaxSize { + _pairs.append(key: key, value: element) + return key + } + + if _dictionary == nil { + _dictionary = [:] + } + + _dictionary![key] = element + + return key + } + + /** + - returns: Number of elements in bag. + */ + public var count: Int { + let dictionaryCount: Int = _dictionary?.count ?? 0 + return _pairs.count + (_value0 != nil ? 1 : 0) + (_value1 != nil ? 1 : 0) + dictionaryCount + } + + /** + Removes all elements from bag and clears capacity. + */ + public mutating func removeAll() { + _key0 = nil + _value0 = nil + _key1 = nil + _value1 = nil + + _pairs.removeAll(keepingCapacity: false) + _dictionary?.removeAll(keepingCapacity: false) + } + + /** + Removes element with a specific `key` from bag. + + - parameter key: Key that identifies element to remove from bag. + - returns: Element that bag contained, or nil in case element was already removed. + */ + public mutating func removeKey(_ key: BagKey) -> T? { + if _key0 == key { + _key0 = nil + let value = _value0! + _value0 = nil + return value + } + + if _key1 == key { + _key1 = nil + let value = _value1! + _value1 = nil + return value + } + + if let existingObject = _dictionary?.removeValue(forKey: key) { + return existingObject + } + + for i in 0 ..< _pairs.count { + if _pairs[i].key == key { + let value = _pairs[i].value + _pairs.remove(at: i) + return value + } + } + + return nil + } +} + +extension Bag { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription : String { + return "\(self.count) elements in Bag" + } +} + + +// MARK: forEach + +extension Bag { + /** + Enumerates elements inside the bag. + + - parameter action: Enumeration closure. + */ + public func forEach(_ action: (T) -> Void) { + if _onlyFastPath { + if let value0 = _value0 { + action(value0) + } + return + } + + let pairs = _pairs + let value0 = _value0 + let value1 = _value1 + let dictionary = _dictionary + + if let value0 = value0 { + action(value0) + } + + if let value1 = value1 { + action(value1) + } + + for i in 0 ..< pairs.count { + action(pairs[i].value) + } + + if dictionary?.count ?? 0 > 0 { + for element in dictionary!.values { + action(element) + } + } + } +} + +extension Bag where T: ObserverType { + /** + Dispatches `event` to app observers contained inside bag. + + - parameter action: Enumeration closure. + */ + public func on(_ event: Event) { + if _onlyFastPath { + _value0?.on(event) + return + } + + let pairs = _pairs + let value0 = _value0 + let value1 = _value1 + let dictionary = _dictionary + + if let value0 = value0 { + value0.on(event) + } + + if let value1 = value1 { + value1.on(event) + } + + for i in 0 ..< pairs.count { + pairs[i].value.on(event) + } + + if dictionary?.count ?? 0 > 0 { + for element in dictionary!.values { + element.on(event) + } + } + } +} + +/** +Dispatches `dispose` to all disposables contained inside bag. +*/ +@available(*, deprecated, renamed: "disposeAll(in:)") +public func disposeAllIn(_ bag: Bag) { + disposeAll(in: bag) +} + +/** + Dispatches `dispose` to all disposables contained inside bag. + */ +public func disposeAll(in bag: Bag) { + if bag._onlyFastPath { + bag._value0?.dispose() + return + } + + let pairs = bag._pairs + let value0 = bag._value0 + let value1 = bag._value1 + let dictionary = bag._dictionary + + if let value0 = value0 { + value0.dispose() + } + + if let value1 = value1 { + value1.dispose() + } + + for i in 0 ..< pairs.count { + pairs[i].value.dispose() + } + + if dictionary?.count ?? 0 > 0 { + for element in dictionary!.values { + element.dispose() + } + } +} diff --git a/Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift b/Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift new file mode 100644 index 0000000..a1cce01 --- /dev/null +++ b/Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift @@ -0,0 +1,30 @@ +// +// InfiniteSequence.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Sequence that repeats `repeatedValue` infinite number of times. +*/ +struct InfiniteSequence : Sequence { + typealias Element = E + typealias Iterator = AnyIterator + + private let _repeatedValue: E + + init(repeatedValue: E) { + _repeatedValue = repeatedValue + } + + func makeIterator() -> Iterator { + let repeatedValue = _repeatedValue + return AnyIterator { + return repeatedValue + } + } +} diff --git a/Pods/RxSwift/RxSwift/DataStructures/PriorityQueue.swift b/Pods/RxSwift/RxSwift/DataStructures/PriorityQueue.swift new file mode 100644 index 0000000..d37a063 --- /dev/null +++ b/Pods/RxSwift/RxSwift/DataStructures/PriorityQueue.swift @@ -0,0 +1,120 @@ +// +// PriorityQueue.swift +// Rx +// +// Created by Krunoslav Zaher on 12/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct PriorityQueue { + private let _hasHigherPriority: (Element, Element) -> Bool + fileprivate var _elements = [Element]() + + init(hasHigherPriority: @escaping (Element, Element) -> Bool) { + _hasHigherPriority = hasHigherPriority + } + + mutating func enqueue(_ element: Element) { + _elements.append(element) + bubbleToHigherPriority(_elements.count - 1) + } + + func peek() -> Element? { + return _elements.first + } + + var isEmpty: Bool { + return _elements.count == 0 + } + + mutating func dequeue() -> Element? { + guard let front = peek() else { + return nil + } + + removeAt(0) + + return front + } + + mutating func remove(_ element: Element) { + for i in 0 ..< _elements.count { + if _elements[i] === element { + removeAt(i) + return + } + } + } + + private mutating func removeAt(_ index: Int) { + let removingLast = index == _elements.count - 1 + if !removingLast { + swap(&_elements[index], &_elements[_elements.count - 1]) + } + + _ = _elements.popLast() + + if !removingLast { + bubbleToHigherPriority(index) + bubbleToLowerPriority(index) + } + } + + private mutating func bubbleToHigherPriority(_ initialUnbalancedIndex: Int) { + precondition(initialUnbalancedIndex >= 0) + precondition(initialUnbalancedIndex < _elements.count) + + var unbalancedIndex = initialUnbalancedIndex + + while unbalancedIndex > 0 { + let parentIndex = (unbalancedIndex - 1) / 2 + + if _hasHigherPriority(_elements[unbalancedIndex], _elements[parentIndex]) { + swap(&_elements[unbalancedIndex], &_elements[parentIndex]) + + unbalancedIndex = parentIndex + } + else { + break + } + } + } + + private mutating func bubbleToLowerPriority(_ initialUnbalancedIndex: Int) { + precondition(initialUnbalancedIndex >= 0) + precondition(initialUnbalancedIndex < _elements.count) + + var unbalancedIndex = initialUnbalancedIndex + repeat { + let leftChildIndex = unbalancedIndex * 2 + 1 + let rightChildIndex = unbalancedIndex * 2 + 2 + + var highestPriorityIndex = unbalancedIndex + + if leftChildIndex < _elements.count && _hasHigherPriority(_elements[leftChildIndex], _elements[highestPriorityIndex]) { + highestPriorityIndex = leftChildIndex + } + + if rightChildIndex < _elements.count && _hasHigherPriority(_elements[rightChildIndex], _elements[highestPriorityIndex]) { + highestPriorityIndex = rightChildIndex + } + + if highestPriorityIndex != unbalancedIndex { + swap(&_elements[highestPriorityIndex], &_elements[unbalancedIndex]) + + unbalancedIndex = highestPriorityIndex + } + else { + break + } + } while true + } +} + +extension PriorityQueue : CustomDebugStringConvertible { + var debugDescription: String { + return _elements.debugDescription + } +} diff --git a/Pods/RxSwift/RxSwift/DataStructures/Queue.swift b/Pods/RxSwift/RxSwift/DataStructures/Queue.swift new file mode 100644 index 0000000..a82a6ab --- /dev/null +++ b/Pods/RxSwift/RxSwift/DataStructures/Queue.swift @@ -0,0 +1,168 @@ +// +// Queue.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Data structure that represents queue. + +Complexity of `enqueue`, `dequeue` is O(1) when number of operations is +averaged over N operations. + +Complexity of `peek` is O(1). +*/ +public struct Queue: Sequence { + /** + Type of generator. + */ + public typealias Generator = AnyIterator + + private let _resizeFactor = 2 + + private var _storage: ContiguousArray + private var _count = 0 + private var _pushNextIndex = 0 + private var _initialCapacity: Int + + /** + Creates new queue. + + - parameter capacity: Capacity of newly created queue. + */ + public init(capacity: Int) { + _initialCapacity = capacity + + _storage = ContiguousArray(repeating: nil, count: capacity) + } + + private var dequeueIndex: Int { + let index = _pushNextIndex - count + return index < 0 ? index + _storage.count : index + } + + /** + - returns: Is queue empty. + */ + public var isEmpty: Bool { + return count == 0 + } + + /** + - returns: Number of elements inside queue. + */ + public var count: Int { + return _count + } + + /** + - returns: Element in front of a list of elements to `dequeue`. + */ + public func peek() -> T { + precondition(count > 0) + + return _storage[dequeueIndex]! + } + + mutating private func resizeTo(_ size: Int) { + var newStorage = ContiguousArray(repeating: nil, count: size) + + let count = _count + + let dequeueIndex = self.dequeueIndex + let spaceToEndOfQueue = _storage.count - dequeueIndex + + // first batch is from dequeue index to end of array + let countElementsInFirstBatch = Swift.min(count, spaceToEndOfQueue) + // second batch is wrapped from start of array to end of queue + let numberOfElementsInSecondBatch = count - countElementsInFirstBatch + + newStorage[0 ..< countElementsInFirstBatch] = _storage[dequeueIndex ..< (dequeueIndex + countElementsInFirstBatch)] + newStorage[countElementsInFirstBatch ..< (countElementsInFirstBatch + numberOfElementsInSecondBatch)] = _storage[0 ..< numberOfElementsInSecondBatch] + + _count = count + _pushNextIndex = count + _storage = newStorage + } + + /** + Enqueues `element`. + + - parameter element: Element to enqueue. + */ + public mutating func enqueue(_ element: T) { + if count == _storage.count { + resizeTo(Swift.max(_storage.count, 1) * _resizeFactor) + } + + _storage[_pushNextIndex] = element + _pushNextIndex += 1 + _count += 1 + + if _pushNextIndex >= _storage.count { + _pushNextIndex -= _storage.count + } + } + + private mutating func dequeueElementOnly() -> T { + precondition(count > 0) + + let index = dequeueIndex + + defer { + _storage[index] = nil + _count -= 1 + } + + return _storage[index]! + } + + /** + Dequeues element or throws an exception in case queue is empty. + + - returns: Dequeued element. + */ + public mutating func dequeue() -> T? { + if self.count == 0 { + return nil + } + + defer { + let downsizeLimit = _storage.count / (_resizeFactor * _resizeFactor) + if _count < downsizeLimit && downsizeLimit >= _initialCapacity { + resizeTo(_storage.count / _resizeFactor) + } + } + + return dequeueElementOnly() + } + + /** + - returns: Generator of contained elements. + */ + public func makeIterator() -> AnyIterator { + var i = dequeueIndex + var count = _count + + return AnyIterator { + if count == 0 { + return nil + } + + defer { + count -= 1 + i += 1 + } + + if i >= self._storage.count { + i -= self._storage.count + } + + return self._storage[i] + } + } +} diff --git a/Pods/RxSwift/RxSwift/Disposable.swift b/Pods/RxSwift/RxSwift/Disposable.swift new file mode 100644 index 0000000..da760ff --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposable.swift @@ -0,0 +1,15 @@ +// +// Disposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/// Respresents a disposable resource. +public protocol Disposable { + /// Dispose resource. + func dispose() +} \ No newline at end of file diff --git a/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift new file mode 100644 index 0000000..d60b5b1 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift @@ -0,0 +1,74 @@ +// +// AnonymousDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents an Action-based disposable. + +When dispose method is called, disposal action will be dereferenced. +*/ +public final class AnonymousDisposable : DisposeBase, Cancelable { + public typealias DisposeAction = () -> Void + + private var _isDisposed: AtomicInt = 0 + private var _disposeAction: DisposeAction? + + /** + - returns: Was resource disposed. + */ + public var isDisposed: Bool { + return _isDisposed == 1 + } + + /** + Constructs a new disposable with the given action used for disposal. + + - parameter disposeAction: Disposal action which will be run upon calling `dispose`. + */ + @available(*, deprecated, renamed: "Disposables.create") + public init(_ disposeAction: @escaping DisposeAction) { + _disposeAction = disposeAction + super.init() + } + + // Non-deprecated version of the constructor, used by `Disposables.create(with:)` + fileprivate init(disposeAction: @escaping DisposeAction) { + _disposeAction = disposeAction + super.init() + } + + /** + Calls the disposal action if and only if the current instance hasn't been disposed yet. + + After invoking disposal action, disposal action will be dereferenced. + */ + public func dispose() { + if AtomicCompareAndSwap(0, 1, &_isDisposed) { + assert(_isDisposed == 1) + + if let action = _disposeAction { + _disposeAction = nil + action() + } + } + } +} + +public extension Disposables { + + /** + Constructs a new disposable with the given action used for disposal. + + - parameter dispose: Disposal action which will be run upon calling `dispose`. + */ + static func create(with dispose: @escaping () -> ()) -> Cancelable { + return AnonymousDisposable(disposeAction: dispose) + } + +} diff --git a/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift new file mode 100644 index 0000000..1c597f4 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift @@ -0,0 +1,65 @@ +// +// BinaryDisposable.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents two disposable resources that are disposed together. +*/ +private final class BinaryDisposable : DisposeBase, Cancelable { + + private var _isDisposed: AtomicInt = 0 + + // state + private var _disposable1: Disposable? + private var _disposable2: Disposable? + + /** + - returns: Was resource disposed. + */ + var isDisposed: Bool { + return _isDisposed > 0 + } + + /** + Constructs new binary disposable from two disposables. + + - parameter disposable1: First disposable + - parameter disposable2: Second disposable + */ + init(_ disposable1: Disposable, _ disposable2: Disposable) { + _disposable1 = disposable1 + _disposable2 = disposable2 + super.init() + } + + /** + Calls the disposal action if and only if the current instance hasn't been disposed yet. + + After invoking disposal action, disposal action will be dereferenced. + */ + func dispose() { + if AtomicCompareAndSwap(0, 1, &_isDisposed) { + _disposable1?.dispose() + _disposable2?.dispose() + _disposable1 = nil + _disposable2 = nil + } + } +} + +public extension Disposables { + + /** + Creates a disposable with the given disposables. + */ + static func create(_ disposable1: Disposable, _ disposable2: Disposable) -> Cancelable { + return BinaryDisposable(disposable1, disposable2) + } + +} diff --git a/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift new file mode 100644 index 0000000..2464a89 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift @@ -0,0 +1,45 @@ +// +// BooleanDisposable.swift +// Rx +// +// Created by Junior B. on 10/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a disposable resource that can be checked for disposal status. +*/ +public final class BooleanDisposable : Disposable, Cancelable { + + internal static let BooleanDisposableTrue = BooleanDisposable(isDisposed: true) + private var _isDisposed = false + + /** + Initializes a new instance of the `BooleanDisposable` class + */ + public init() { + } + + /** + Initializes a new instance of the `BooleanDisposable` class with given value + */ + public init(isDisposed: Bool) { + self._isDisposed = isDisposed + } + + /** + - returns: Was resource disposed. + */ + public var isDisposed: Bool { + return _isDisposed + } + + /** + Sets the status to disposed, which can be observer through the `isDisposed` property. + */ + public func dispose() { + _isDisposed = true + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift new file mode 100644 index 0000000..a7e4b5b --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/CompositeDisposable.swift @@ -0,0 +1,157 @@ +// +// CompositeDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/20/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a group of disposable resources that are disposed together. +*/ +public final class CompositeDisposable : DisposeBase, Disposable, Cancelable { + public typealias DisposeKey = Bag.KeyType + + private var _lock = SpinLock() + + // state + private var _disposables: Bag? = Bag() + + public var isDisposed: Bool { + _lock.lock(); defer { _lock.unlock() } + return _disposables == nil + } + + public override init() { + } + + /** + Initializes a new instance of composite disposable with the specified number of disposables. + */ + public init(_ disposable1: Disposable, _ disposable2: Disposable) { + // This overload is here to make sure we are using optimized version up to 4 arguments. + let _ = _disposables!.insert(disposable1) + let _ = _disposables!.insert(disposable2) + } + + /** + Initializes a new instance of composite disposable with the specified number of disposables. + */ + public init(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable) { + // This overload is here to make sure we are using optimized version up to 4 arguments. + let _ = _disposables!.insert(disposable1) + let _ = _disposables!.insert(disposable2) + let _ = _disposables!.insert(disposable3) + } + + /** + Initializes a new instance of composite disposable with the specified number of disposables. + */ + public init(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable, _ disposable4: Disposable, _ disposables: Disposable...) { + // This overload is here to make sure we are using optimized version up to 4 arguments. + let _ = _disposables!.insert(disposable1) + let _ = _disposables!.insert(disposable2) + let _ = _disposables!.insert(disposable3) + let _ = _disposables!.insert(disposable4) + + for disposable in disposables { + let _ = _disposables!.insert(disposable) + } + } + + /** + Initializes a new instance of composite disposable with the specified number of disposables. + */ + public init(disposables: [Disposable]) { + for disposable in disposables { + let _ = _disposables!.insert(disposable) + } + } + + /** + Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. + + - parameter disposable: Disposable to add. + - returns: Key that can be used to remove disposable from composite disposable. In case dispose bag was already + disposed `nil` will be returned. + */ + @available(*, deprecated, renamed: "insert(_:)") + public func addDisposable(_ disposable: Disposable) -> DisposeKey? { + return insert(disposable) + } + + /** + Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed. + + - parameter disposable: Disposable to add. + - returns: Key that can be used to remove disposable from composite disposable. In case dispose bag was already + disposed `nil` will be returned. + */ + public func insert(_ disposable: Disposable) -> DisposeKey? { + let key = _insert(disposable) + + if key == nil { + disposable.dispose() + } + + return key + } + + private func _insert(_ disposable: Disposable) -> DisposeKey? { + _lock.lock(); defer { _lock.unlock() } + + return _disposables?.insert(disposable) + } + + /** + - returns: Gets the number of disposables contained in the `CompositeDisposable`. + */ + public var count: Int { + _lock.lock(); defer { _lock.unlock() } + return _disposables?.count ?? 0 + } + + /** + Removes and disposes the disposable identified by `disposeKey` from the CompositeDisposable. + + - parameter disposeKey: Key used to identify disposable to be removed. + */ + @available(*, deprecated, renamed: "remove(for:)") + public func removeDisposable(_ disposeKey: DisposeKey) { + remove(for: disposeKey) + } + + /** + Removes and disposes the disposable identified by `disposeKey` from the CompositeDisposable. + + - parameter disposeKey: Key used to identify disposable to be removed. + */ + public func remove(for disposeKey: DisposeKey) { + _remove(for: disposeKey)?.dispose() + } + + private func _remove(for disposeKey: DisposeKey) -> Disposable? { + _lock.lock(); defer { _lock.unlock() } + return _disposables?.removeKey(disposeKey) + } + + /** + Disposes all disposables in the group and removes them from the group. + */ + public func dispose() { + if let disposables = _dispose() { + disposeAll(in: disposables) + } + } + + private func _dispose() -> Bag? { + _lock.lock(); defer { _lock.unlock() } + + let disposeBag = _disposables + _disposables = nil + + return disposeBag + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/Disposables.swift b/Pods/RxSwift/RxSwift/Disposables/Disposables.swift new file mode 100644 index 0000000..694b1e5 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/Disposables.swift @@ -0,0 +1,61 @@ +// +// Disposables.swift +// Rx +// +// Created by Mohsen Ramezanpoor on 01/08/2016. +// Copyright © 2016 Mohsen Ramezanpoor. All rights reserved. +// + +import Foundation + +/** + A collection of utility methods for common disposable operations. + */ +public struct Disposables { + + private init() {} + +} + +public extension Disposables { + + private static let noOp: Disposable = NopDisposable() + + /** + Creates a disposable that does nothing on disposal. + */ + static func create() -> Disposable { + return noOp + } + + /** + Creates a disposable with the given disposables. + */ + static func create(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable) -> Cancelable { + return CompositeDisposable(disposable1, disposable2, disposable3) + } + + /** + Creates a disposable with the given disposables. + */ + static func create(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable, _ disposables: Disposable ...) -> Cancelable { + var disposables = disposables + disposables.append(disposable1) + disposables.append(disposable2) + disposables.append(disposable3) + return CompositeDisposable(disposables: disposables) + } + + /** + Creates a disposable with the given disposables. + */ + static func create(_ disposables: [Disposable]) -> Cancelable { + switch disposables.count { + case 2: + return Disposables.create(disposables[0], disposables[1]) + default: + return CompositeDisposable(disposables: disposables) + } + } + +} diff --git a/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift b/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift new file mode 100644 index 0000000..34a3b0c --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift @@ -0,0 +1,104 @@ +// +// DisposeBag.swift +// Rx +// +// Created by Krunoslav Zaher on 3/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension Disposable { + /** + Adds `self` to `bag`. + + - parameter bag: `DisposeBag` to add `self` to. + */ + public func addDisposableTo(_ bag: DisposeBag) { + bag.insert(self) + } +} + +/** +Thread safe bag that disposes added disposables on `deinit`. + +This returns ARC (RAII) like resource management to `RxSwift`. + +In case contained disposables need to be disposed, just put a different dispose bag +or create a new one in its place. + + self.existingDisposeBag = DisposeBag() + +In case explicit disposal is necessary, there is also `CompositeDisposable`. +*/ +public final class DisposeBag: DisposeBase { + + private var _lock = SpinLock() + + // state + private var _disposables = [Disposable]() + private var _isDisposed = false + + /** + Constructs new empty dispose bag. + */ + public override init() { + super.init() + } + + /** + Adds `disposable` to be disposed when dispose bag is being deinited. + + - parameter disposable: Disposable to add. + */ + @available(*, deprecated, renamed: "insert(_:)") + public func addDisposable(_ disposable: Disposable) { + insert(disposable) + } + + /** + Adds `disposable` to be disposed when dispose bag is being deinited. + + - parameter disposable: Disposable to add. + */ + public func insert(_ disposable: Disposable) { + _insert(disposable)?.dispose() + } + + private func _insert(_ disposable: Disposable) -> Disposable? { + _lock.lock(); defer { _lock.unlock() } + if _isDisposed { + return disposable + } + + _disposables.append(disposable) + + return nil + } + + /** + This is internal on purpose, take a look at `CompositeDisposable` instead. + */ + private func dispose() { + let oldDisposables = _dispose() + + for disposable in oldDisposables { + disposable.dispose() + } + } + + private func _dispose() -> [Disposable] { + _lock.lock(); defer { _lock.unlock() } + + let disposables = _disposables + + _disposables.removeAll(keepingCapacity: false) + _isDisposed = true + + return disposables + } + + deinit { + dispose() + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift b/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift new file mode 100644 index 0000000..16da27c --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift @@ -0,0 +1,26 @@ +// +// DisposeBase.swift +// Rx +// +// Created by Krunoslav Zaher on 4/4/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Base class for all disposables. +*/ +public class DisposeBase { + init() { +#if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) +#endif + } + + deinit { +#if TRACE_RESOURCES + let _ = AtomicDecrement(&resourceCount) +#endif + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift new file mode 100644 index 0000000..0203f22 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift @@ -0,0 +1,33 @@ +// +// NopDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a disposable that does nothing on disposal. + +Nop = No Operation +*/ +public struct NopDisposable : Disposable { + + /** + Singleton instance of `NopDisposable`. + */ + @available(*, deprecated, renamed: "Disposables.create()") + public static let instance: Disposable = NopDisposable() + + init() { + + } + + /** + Does nothing. + */ + public func dispose() { + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift new file mode 100644 index 0000000..775b086 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/RefCountDisposable.swift @@ -0,0 +1,127 @@ +// +// RefCountDisposable.swift +// Rx +// +// Created by Junior B. on 10/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** + Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed. + */ +public final class RefCountDisposable : DisposeBase, Cancelable { + private var _lock = SpinLock() + private var _disposable = nil as Disposable? + private var _primaryDisposed = false + private var _count = 0 + + /** + - returns: Was resource disposed. + */ + public var isDisposed: Bool { + _lock.lock(); defer { _lock.unlock() } + return _disposable == nil + } + + /** + Initializes a new instance of the `RefCountDisposable`. + */ + public init(disposable: Disposable) { + _disposable = disposable + super.init() + } + + /** + Holds a dependent disposable that when disposed decreases the refcount on the underlying disposable. + + When getter is called, a dependent disposable contributing to the reference count that manages the underlying disposable's lifetime is returned. + */ + public func retain() -> Disposable { + return _lock.calculateLocked { + if let _ = _disposable { + + do { + let _ = try incrementChecked(&_count) + } catch (_) { + rxFatalError("RefCountDisposable increment failed") + } + + return RefCountInnerDisposable(self) + } else { + return Disposables.create() + } + } + } + + /** + Disposes the underlying disposable only when all dependent disposables have been disposed. + */ + public func dispose() { + let oldDisposable: Disposable? = _lock.calculateLocked { + if let oldDisposable = _disposable, !_primaryDisposed + { + _primaryDisposed = true + + if (_count == 0) + { + _disposable = nil + return oldDisposable + } + } + + return nil + } + + if let disposable = oldDisposable { + disposable.dispose() + } + } + + fileprivate func release() { + let oldDisposable: Disposable? = _lock.calculateLocked { + if let oldDisposable = _disposable { + do { + let _ = try decrementChecked(&_count) + } catch (_) { + rxFatalError("RefCountDisposable decrement on release failed") + } + + guard _count >= 0 else { + rxFatalError("RefCountDisposable counter is lower than 0") + } + + if _primaryDisposed && _count == 0 { + _disposable = nil + return oldDisposable + } + } + + return nil + } + + if let disposable = oldDisposable { + disposable.dispose() + } + } +} + +internal final class RefCountInnerDisposable: DisposeBase, Disposable +{ + private let _parent: RefCountDisposable + private var _isDisposed: AtomicInt = 0 + + init(_ parent: RefCountDisposable) + { + _parent = parent + super.init() + } + + internal func dispose() + { + if AtomicCompareAndSwap(0, 1, &_isDisposed) { + _parent.release() + } + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift new file mode 100644 index 0000000..d2f80a0 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift @@ -0,0 +1,58 @@ +// +// ScheduledDisposable.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +private let disposeScheduledDisposable: (ScheduledDisposable) -> Disposable = { sd in + sd.disposeInner() + return Disposables.create() +} + +/** +Represents a disposable resource whose disposal invocation will be scheduled on the specified scheduler. +*/ +public final class ScheduledDisposable : Cancelable { + public let scheduler: ImmediateSchedulerType + + private var _isDisposed: AtomicInt = 0 + + // state + private var _disposable: Disposable? + + /** + - returns: Was resource disposed. + */ + public var isDisposed: Bool { + return _isDisposed == 1 + } + + /** + Initializes a new instance of the `ScheduledDisposable` that uses a `scheduler` on which to dispose the `disposable`. + + - parameter scheduler: Scheduler where the disposable resource will be disposed on. + - parameter disposable: Disposable resource to dispose on the given scheduler. + */ + public init(scheduler: ImmediateSchedulerType, disposable: Disposable) { + self.scheduler = scheduler + _disposable = disposable + } + + /** + Disposes the wrapped disposable on the provided scheduler. + */ + public func dispose() { + let _ = scheduler.schedule(self, action: disposeScheduledDisposable) + } + + func disposeInner() { + if AtomicCompareAndSwap(0, 1, &_isDisposed) { + _disposable!.dispose() + _disposable = nil + } + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift new file mode 100644 index 0000000..8aa355c --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift @@ -0,0 +1,85 @@ +// +// SerialDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 3/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource. +*/ +public final class SerialDisposable : DisposeBase, Cancelable { + private var _lock = SpinLock() + + // state + private var _current = nil as Disposable? + private var _isDisposed = false + + /** + - returns: Was resource disposed. + */ + public var isDisposed: Bool { + return _isDisposed + } + + /** + Initializes a new instance of the `SerialDisposable`. + */ + override public init() { + super.init() + } + + /** + Gets or sets the underlying disposable. + + Assigning this property disposes the previous disposable object. + + If the `SerialDisposable` has already been disposed, assignment to this property causes immediate disposal of the given disposable object. + */ + public var disposable: Disposable { + get { + return _lock.calculateLocked { + return self.disposable + } + } + set (newDisposable) { + let disposable: Disposable? = _lock.calculateLocked { + if _isDisposed { + return newDisposable + } + else { + let toDispose = _current + _current = newDisposable + return toDispose + } + } + + if let disposable = disposable { + disposable.dispose() + } + } + } + + /** + Disposes the underlying disposable as well as all future replacements. + */ + public func dispose() { + _dispose()?.dispose() + } + + private func _dispose() -> Disposable? { + _lock.lock(); defer { _lock.unlock() } + if _isDisposed { + return nil + } + else { + _isDisposed = true + let current = _current + _current = nil + return current + } + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift new file mode 100644 index 0000000..a794cc0 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift @@ -0,0 +1,86 @@ +// +// SingleAssignmentDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation +import Darwin.C.stdatomic + +/** +Represents a disposable resource which only allows a single assignment of its underlying disposable resource. + +If an underlying disposable resource has already been set, future attempts to set the underlying disposable resource will throw an exception. +*/ +public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable { + fileprivate enum DisposeState: UInt32 { + case disposed = 1 + case disposableSet = 2 + } + + // Jeej, swift API consistency rules + fileprivate enum DisposeStateInt32: Int32 { + case disposed = 1 + case disposableSet = 2 + } + + // state + private var _state: UInt32 = 0 + private var _disposable = nil as Disposable? + + /** + - returns: A value that indicates whether the object is disposed. + */ + public var isDisposed: Bool { + return (_state & DisposeState.disposed.rawValue) != 0 + } + + /** + Initializes a new instance of the `SingleAssignmentDisposable`. + */ + public override init() { + super.init() + } + + /** + Gets or sets the underlying disposable. After disposal, the result of getting this property is undefined. + + **Throws exception if the `SingleAssignmentDisposable` has already been assigned to.** + */ + public func setDisposable(_ disposable: Disposable) { + _disposable = disposable + + let previousState = OSAtomicOr32OrigBarrier(DisposeState.disposableSet.rawValue, &_state) + + if (previousState & DisposeStateInt32.disposableSet.rawValue) != 0 { + rxFatalError("oldState.disposable != nil") + } + + if (previousState & DisposeStateInt32.disposed.rawValue) != 0 { + disposable.dispose() + _disposable = nil + } + } + + /** + Disposes the underlying disposable. + */ + public func dispose() { + let previousState = OSAtomicOr32OrigBarrier(DisposeState.disposed.rawValue, &_state) + + if (previousState & DisposeStateInt32.disposed.rawValue) != 0 { + return + } + + if (previousState & DisposeStateInt32.disposableSet.rawValue) != 0 { + guard let disposable = _disposable else { + rxFatalError("Disposable not set") + } + disposable.dispose() + _disposable = nil + } + } + +} diff --git a/Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift new file mode 100644 index 0000000..ad10eac --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift @@ -0,0 +1,16 @@ +// +// StableCompositeDisposable.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +public final class StableCompositeDisposable { + @available(*, deprecated, renamed: "Disposables.create") + public static func create(_ disposable1: Disposable, _ disposable2: Disposable) -> Disposable { + return Disposables.create(disposable1, disposable2) + } +} diff --git a/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift b/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift new file mode 100644 index 0000000..64610d2 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift @@ -0,0 +1,23 @@ +// +// SubscriptionDisposable.swift +// Rx +// +// Created by Krunoslav Zaher on 10/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct SubscriptionDisposable : Disposable { + private let _key: T.DisposeKey + private weak var _owner: T? + + init(owner: T, key: T.DisposeKey) { + _owner = owner + _key = key + } + + func dispose() { + _owner?.synchronizedUnsubscribe(_key) + } +} diff --git a/Pods/RxSwift/RxSwift/Errors.swift b/Pods/RxSwift/RxSwift/Errors.swift new file mode 100644 index 0000000..8074e16 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Errors.swift @@ -0,0 +1,72 @@ +// +// Errors.swift +// Rx +// +// Created by Krunoslav Zaher on 3/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +let RxErrorDomain = "RxErrorDomain" +let RxCompositeFailures = "RxCompositeFailures" + +/** +Generic Rx error codes. +*/ +public enum RxError + : Swift.Error + , CustomDebugStringConvertible { + /** + Unknown error occured. + */ + case unknown + /** + Performing an action on disposed object. + */ + case disposed(object: AnyObject) + /** + Aritmetic overflow error. + */ + case overflow + /** + Argument out of range error. + */ + case argumentOutOfRange + /** + Sequence doesn't contain any elements. + */ + case noElements + /** + Sequence contains more than one element. + */ + case moreThanOneElement + /** + Timeout error. + */ + case timeout +} + +public extension RxError { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription: String { + switch self { + case .unknown: + return "Unknown error occured." + case .disposed(let object): + return "Object `\(object)` was already disposed." + case .overflow: + return "Arithmetic overflow occured." + case .argumentOutOfRange: + return "Argument out of range." + case .noElements: + return "Sequence doesn't contain any elements." + case .moreThanOneElement: + return "Sequence contains more than one element." + case .timeout: + return "Sequence timeout." + } + } +} diff --git a/Pods/RxSwift/RxSwift/Event.swift b/Pods/RxSwift/RxSwift/Event.swift new file mode 100644 index 0000000..5fcf8f2 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Event.swift @@ -0,0 +1,66 @@ +// +// Event.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a sequence event. + +Sequence grammar: +next\* (error | completed) +*/ +public enum Event { + /// Next element is produced. + case next(Element) + + /// Sequence terminated with an error. + case error(Swift.Error) + + /// Sequence completed successfully. + case completed +} + +extension Event : CustomDebugStringConvertible { + /// - returns: Description of event. + public var debugDescription: String { + switch self { + case .next(let value): + return "next(\(value))" + case .error(let error): + return "error(\(error))" + case .completed: + return "completed" + } + } +} + +extension Event { + /// - returns: Is `Completed` or `Error` event. + public var isStopEvent: Bool { + switch self { + case .next: return false + case .error, .completed: return true + } + } + + /// - returns: If `Next` event, returns element value. + public var element: Element? { + if case .next(let value) = self { + return value + } + return nil + } + + /// - returns: If `Error` event, returns error. + public var error: Swift.Error? { + if case .error(let error) = self { + return error + } + return nil + } +} diff --git a/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift b/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift new file mode 100644 index 0000000..b794766 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Extensions/String+Rx.swift @@ -0,0 +1,26 @@ +// +// String+Rx.swift +// Rx +// +// Created by Krunoslav Zaher on 12/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension String { + /** + This is needed because on Linux Swift doesn't have `rangeOfString(..., options: .BackwardsSearch)` + */ + func lastIndexOf(_ character: Character) -> Index? { + var index = endIndex + while index > startIndex { + index = self.index(before: index) + if self[index] == character { + return index + } + } + + return nil + } +} diff --git a/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift b/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift new file mode 100644 index 0000000..c535bd3 --- /dev/null +++ b/Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift @@ -0,0 +1,40 @@ +// +// ImmediateSchedulerType.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/31/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents an object that immediately schedules units of work. +*/ +public protocol ImmediateSchedulerType { + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable +} + +extension ImmediateSchedulerType { + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + - 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. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func scheduleRecursive(_ state: State, action: @escaping (_ state: State, _ recurse: (State) -> ()) -> ()) -> Disposable { + let recursiveScheduler = RecursiveImmediateScheduler(action: action, scheduler: self) + + recursiveScheduler.schedule(state) + + return Disposables.create(with: recursiveScheduler.dispose) + } +} diff --git a/Pods/RxSwift/RxSwift/Observable.swift b/Pods/RxSwift/RxSwift/Observable.swift new file mode 100644 index 0000000..9c0f325 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observable.swift @@ -0,0 +1,52 @@ +// +// Observable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +A type-erased `ObservableType`. + +It represents a push style sequence. +*/ +public class Observable : ObservableType { + /** + Type of elements in sequence. + */ + public typealias E = Element + + init() { +#if TRACE_RESOURCES + OSAtomicIncrement32(&resourceCount) +#endif + } + + public func subscribe(_ observer: O) -> Disposable where O.E == E { + abstractMethod() + } + + public func asObservable() -> Observable { + return self + } + + deinit { +#if TRACE_RESOURCES + let _ = AtomicDecrement(&resourceCount) +#endif + } + + // this is kind of ugly I know :( + // Swift compiler reports "Not supported yet" when trying to override protocol extensions, so ¯\_(ツ)_/¯ + + /** + Optimizations for map operator + */ + internal func composeMap(_ selector: @escaping (Element) throws -> R) -> Observable { + return Map(source: self, selector: selector) + } +} + diff --git a/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift b/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift new file mode 100644 index 0000000..a749a06 --- /dev/null +++ b/Pods/RxSwift/RxSwift/ObservableConvertibleType.swift @@ -0,0 +1,26 @@ +// +// ObservableConvertibleType.swift +// Rx +// +// Created by Krunoslav Zaher on 9/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Type that can be converted to observable sequence (`Observer`). +*/ +public protocol ObservableConvertibleType { + /** + Type of elements in sequence. + */ + associatedtype E + + /** + Converts `self` to `Observable` sequence. + + - returns: Observable sequence that represents `self`. + */ + func asObservable() -> Observable +} diff --git a/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift b/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift new file mode 100644 index 0000000..5cb701f --- /dev/null +++ b/Pods/RxSwift/RxSwift/ObservableType+Extensions.swift @@ -0,0 +1,179 @@ +// +// ObservableType+Extensions.swift +// Rx +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension ObservableType { + /** + Subscribes an event handler to an observable sequence. + + - parameter on: Action to invoke for each event in the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + public func subscribe(_ on: @escaping (Event) -> Void) + -> Disposable { + let observer = AnonymousObserver { e in + on(e) + } + return self.subscribeSafe(observer) + } + + #if DEBUG + /** + Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - parameter onDisposed: Action to invoke upon any type of termination of sequence (if the sequence has + gracefully completed, errored, or if the generation is cancelled by disposing subscription). + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + public func subscribe(file: String = #file, line: UInt = #line, function: String = #function, onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil) + -> Disposable { + + let disposable: Disposable + + if let disposed = onDisposed { + disposable = Disposables.create(with: disposed) + } + else { + disposable = Disposables.create() + } + + let observer = AnonymousObserver { e in + switch e { + case .next(let value): + onNext?(value) + case .error(let e): + if let onError = onError { + onError(e) + } + else { + print("Received unhandled error: \(file):\(line):\(function) -> \(e)") + } + disposable.dispose() + case .completed: + onCompleted?() + disposable.dispose() + } + } + return Disposables.create( + self.subscribeSafe(observer), + disposable + ) + } + #else + /** + Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - parameter onDisposed: Action to invoke upon any type of termination of sequence (if the sequence has + gracefully completed, errored, or if the generation is cancelled by disposing subscription). + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + public func subscribe(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil) + -> Disposable { + + let disposable: Disposable + + if let disposed = onDisposed { + disposable = Disposables.create(with: disposed) + } + else { + disposable = Disposables.create() + } + + let observer = AnonymousObserver { e in + switch e { + case .next(let value): + onNext?(value) + case .error(let e): + onError?(e) + disposable.dispose() + case .completed: + onCompleted?() + disposable.dispose() + } + } + return Disposables.create( + self.subscribeSafe(observer), + disposable + ) + } + #endif + + /** + Subscribes an element handler to an observable sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + @available(*, deprecated, renamed: "subscribe(onNext:)") + public func subscribeNext(_ onNext: @escaping (E) -> Void) + -> Disposable { + let observer = AnonymousObserver { e in + if case .next(let value) = e { + onNext(value) + } + } + return self.subscribeSafe(observer) + } + + /** + Subscribes an error handler to an observable sequence. + + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + @available(*, deprecated, renamed: "subscribe(onError:)") + public func subscribeError(_ onError: @escaping (Swift.Error) -> Void) + -> Disposable { + let observer = AnonymousObserver { e in + if case .error(let error) = e { + onError(error) + } + } + return self.subscribeSafe(observer) + } + + /** + Subscribes a completion handler to an observable sequence. + + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - returns: Subscription object used to unsubscribe from the observable sequence. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + @available(*, deprecated, renamed: "subscribe(onCompleted:)") + public func subscribeCompleted(_ onCompleted: @escaping () -> Void) + -> Disposable { + let observer = AnonymousObserver { e in + if case .completed = e { + onCompleted() + } + } + return self.subscribeSafe(observer) + } +} + +public extension ObservableType { + /** + All internal subscribe calls go through this method. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + func subscribeSafe(_ observer: O) -> Disposable where O.E == E { + return self.asObservable().subscribe(observer) + } +} diff --git a/Pods/RxSwift/RxSwift/ObservableType.swift b/Pods/RxSwift/RxSwift/ObservableType.swift new file mode 100644 index 0000000..6c7be85 --- /dev/null +++ b/Pods/RxSwift/RxSwift/ObservableType.swift @@ -0,0 +1,60 @@ +// +// ObservableType.swift +// RxSwift +// +// Created by Krunoslav Zaher on 8/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents a push style sequence. +*/ +public protocol ObservableType : ObservableConvertibleType { + /** + Type of elements in sequence. + */ + associatedtype E + + /** + Subscribes `observer` to receive events for this sequence. + + ### Grammar + + **Next\* (Error | Completed)?** + + * sequences can produce zero or more elements so zero or more `Next` events can be sent to `observer` + * once an `Error` or `Completed` event is sent, the sequence terminates and can't produce any other elements + + It is possible that events are sent from different threads, but no two events can be sent concurrently to + `observer`. + + ### Resource Management + + When sequence sends `Complete` or `Error` event all internal resources that compute sequence elements + will be freed. + + To cancel production of sequence elements and free resources immediatelly, call `dispose` on returned + subscription. + + - returns: Subscription for `observer` that can be used to cancel production of sequence elements and free resources. + */ + // @warn_unused_result(message: "http://git.io/rxs.ud") + func subscribe(_ observer: O) -> Disposable where O.E == E +} + +extension ObservableType { + + /** + Default implementation of converting `ObservableType` to `Observable`. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func asObservable() -> Observable { + // temporary workaround + //return Observable.create(subscribe: self.subscribe) + return Observable.create { o in + return self.subscribe(o) + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift new file mode 100644 index 0000000..746a94e --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift @@ -0,0 +1,47 @@ +// +// AddRef.swift +// Rx +// +// Created by Junior B. on 30/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class AddRefSink : Sink, ObserverType { + typealias Element = O.E + + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(_): + forwardOn(event) + case .completed, .error(_): + forwardOn(event) + dispose() + } + } +} + +class AddRef : Producer { + typealias EventHandler = (Event) throws -> Void + + private let _source: Observable + private let _refCount: RefCountDisposable + + init(source: Observable, refCount: RefCountDisposable) { + _source = source + _refCount = refCount + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let releaseDisposable = _refCount.retain() + let sink = AddRefSink(observer: observer, cancel: cancel) + let subscription = Disposables.create(releaseDisposable, _source.subscribeSafe(sink)) + + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift new file mode 100644 index 0000000..9579228 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Amb.swift @@ -0,0 +1,122 @@ +// +// Amb.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +enum AmbState { + case neither + case left + case right +} + +class AmbObserver : ObserverType where O.E == ElementType { + typealias Element = ElementType + typealias Parent = AmbSink + typealias This = AmbObserver + typealias Sink = (This, Event) -> Void + + fileprivate let _parent: Parent + fileprivate var _sink: Sink + fileprivate var _cancel: Disposable + + init(parent: Parent, cancel: Disposable, sink: @escaping Sink) { +#if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) +#endif + + _parent = parent + _sink = sink + _cancel = cancel + } + + func on(_ event: Event) { + _sink(self, event) + if event.isStopEvent { + _cancel.dispose() + } + } + + deinit { +#if TRACE_RESOURCES + let _ = AtomicDecrement(&resourceCount) +#endif + } +} + +class AmbSink : Sink where O.E == ElementType { + typealias Parent = Amb + typealias AmbObserverType = AmbObserver + + private let _parent: Parent + + private let _lock = NSRecursiveLock() + // state + private var _choice = AmbState.neither + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let disposeAll = Disposables.create(subscription1, subscription2) + + let forwardEvent = { (o: AmbObserverType, event: Event) -> Void in + self.forwardOn(event) + } + + let decide = { (o: AmbObserverType, event: Event, me: AmbState, otherSubscription: Disposable) in + self._lock.performLocked { + if self._choice == .neither { + self._choice = me + o._sink = forwardEvent + o._cancel = disposeAll + otherSubscription.dispose() + } + + if self._choice == me { + self.forwardOn(event) + if event.isStopEvent { + self.dispose() + } + } + } + } + + let sink1 = AmbObserver(parent: self, cancel: subscription1) { o, e in + decide(o, e, .left, subscription2) + } + + let sink2 = AmbObserver(parent: self, cancel: subscription1) { o, e in + decide(o, e, .right, subscription1) + } + + subscription1.setDisposable(_parent._left.subscribe(sink1)) + subscription2.setDisposable(_parent._right.subscribe(sink2)) + + return disposeAll + } +} + +class Amb: Producer { + fileprivate let _left: Observable + fileprivate let _right: Observable + + init(left: Observable, right: Observable) { + _left = left + _right = right + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = AmbSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift new file mode 100644 index 0000000..87cf2c6 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift @@ -0,0 +1,56 @@ +// +// AnonymousObservable.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class AnonymousObservableSink : Sink, ObserverType { + typealias E = O.E + typealias Parent = AnonymousObservable + + // state + private var _isStopped: AtomicInt = 0 + + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next: + if _isStopped == 1 { + return + } + forwardOn(event) + case .error, .completed: + if AtomicCompareAndSwap(0, 1, &_isStopped) { + forwardOn(event) + dispose() + } + } + } + + func run(_ parent: Parent) -> Disposable { + return parent._subscribeHandler(AnyObserver(self)) + } +} + +class AnonymousObservable : Producer { + typealias SubscribeHandler = (AnyObserver) -> Disposable + + let _subscribeHandler: SubscribeHandler + + init(_ subscribeHandler: @escaping SubscribeHandler) { + _subscribeHandler = subscribeHandler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = AnonymousObservableSink(observer: observer, cancel: cancel) + let subscription = sink.run(self) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift new file mode 100644 index 0000000..3bd2583 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Buffer.swift @@ -0,0 +1,121 @@ +// +// Buffer.swift +// Rx +// +// Created by Krunoslav Zaher on 9/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class BufferTimeCount : Producer<[Element]> { + + fileprivate let _timeSpan: RxTimeInterval + fileprivate let _count: Int + fileprivate let _scheduler: SchedulerType + fileprivate let _source: Observable + + init(source: Observable, timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) { + _source = source + _timeSpan = timeSpan + _count = count + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == [Element] { + let sink = BufferTimeCountSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + +class BufferTimeCountSink + : Sink + , LockOwnerType + , ObserverType + , SynchronizedOnType where O.E == [Element] { + typealias Parent = BufferTimeCount + typealias E = Element + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + // state + private let _timerD = SerialDisposable() + private var _buffer = [Element]() + private var _windowID = 0 + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + createTimer(_windowID) + return Disposables.create(_timerD, _parent._source.subscribe(self)) + } + + func startNewWindowAndSendCurrentOne() { + _windowID = _windowID &+ 1 + let windowID = _windowID + + let buffer = _buffer + _buffer = [] + forwardOn(.next(buffer)) + + createTimer(windowID) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let element): + _buffer.append(element) + + if _buffer.count == _parent._count { + startNewWindowAndSendCurrentOne() + } + + case .error(let error): + _buffer = [] + forwardOn(.error(error)) + dispose() + case .completed: + forwardOn(.next(_buffer)) + forwardOn(.completed) + dispose() + } + } + + func createTimer(_ windowID: Int) { + if _timerD.isDisposed { + return + } + + if _windowID != windowID { + return + } + + let nextTimer = SingleAssignmentDisposable() + + _timerD.disposable = nextTimer + + let disposable = _parent._scheduler.scheduleRelative(windowID, dueTime: _parent._timeSpan) { previousWindowID in + self._lock.performLocked { + if previousWindowID != self._windowID { + return + } + + self.startNewWindowAndSendCurrentOne() + } + + return Disposables.create() + } + + nextTimer.setDisposable(disposable) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift new file mode 100644 index 0000000..0f43069 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Catch.swift @@ -0,0 +1,162 @@ +// +// Catch.swift +// RxSwift +// +// Created by Krunoslav Zaher on 4/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// catch with callback + +class CatchSinkProxy : ObserverType { + typealias E = O.E + typealias Parent = CatchSink + + private let _parent: Parent + + init(parent: Parent) { + _parent = parent + } + + func on(_ event: Event) { + _parent.forwardOn(event) + + switch event { + case .next: + break + case .error, .completed: + _parent.dispose() + } + } +} + +class CatchSink : Sink, ObserverType { + typealias E = O.E + typealias Parent = Catch + + private let _parent: Parent + private let _subscription = SerialDisposable() + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let d1 = SingleAssignmentDisposable() + _subscription.disposable = d1 + d1.setDisposable(_parent._source.subscribe(self)) + + return _subscription + } + + func on(_ event: Event) { + switch event { + case .next: + forwardOn(event) + case .completed: + forwardOn(event) + dispose() + case .error(let error): + do { + let catchSequence = try _parent._handler(error) + + let observer = CatchSinkProxy(parent: self) + + _subscription.disposable = catchSequence.subscribe(observer) + } + catch let e { + forwardOn(.error(e)) + dispose() + } + } + } +} + +class Catch : Producer { + typealias Handler = (Swift.Error) throws -> Observable + + fileprivate let _source: Observable + fileprivate let _handler: Handler + + init(source: Observable, handler: @escaping Handler) { + _source = source + _handler = handler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = CatchSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + +// catch enumerable + +class CatchSequenceSink + : TailRecursiveSink + , ObserverType where S.Iterator.Element : ObservableConvertibleType, S.Iterator.Element.E == O.E { + typealias Element = O.E + typealias Parent = CatchSequence + + private var _lastError: Swift.Error? + + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next: + forwardOn(event) + case .error(let error): + _lastError = error + schedule(.moveNext) + case .completed: + forwardOn(event) + dispose() + } + } + + override func subscribeToNext(_ source: Observable) -> Disposable { + return source.subscribe(self) + } + + override func done() { + if let lastError = _lastError { + forwardOn(.error(lastError)) + } + else { + forwardOn(.completed) + } + + self.dispose() + } + + override func extract(_ observable: Observable) -> SequenceGenerator? { + if let onError = observable as? CatchSequence { + return (onError.sources.makeIterator(), nil) + } + else { + return nil + } + } +} + +class CatchSequence : Producer where S.Iterator.Element : ObservableConvertibleType { + typealias Element = S.Iterator.Element.E + + let sources: S + + init(sources: S) { + self.sources = sources + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = CatchSequenceSink(observer: observer, cancel: cancel) + let subscription = sink.run((self.sources.makeIterator(), nil)) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift new file mode 100644 index 0000000..e82a48a --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift @@ -0,0 +1,127 @@ +// +// CombineLatest+Collection.swift +// Rx +// +// Created by Krunoslav Zaher on 8/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class CombineLatestCollectionTypeSink + : Sink where C.Iterator.Element : ObservableConvertibleType, O.E == R { + typealias Parent = CombineLatestCollectionType + typealias SourceElement = C.Iterator.Element.E + + let _parent: Parent + + let _lock = NSRecursiveLock() + + // state + var _numberOfValues = 0 + var _values: [SourceElement?] + var _isDone: [Bool] + var _numberOfDone = 0 + var _subscriptions: [SingleAssignmentDisposable] + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _values = [SourceElement?](repeating: nil, count: parent._count) + _isDone = [Bool](repeating: false, count: parent._count) + _subscriptions = Array() + _subscriptions.reserveCapacity(parent._count) + + for _ in 0 ..< parent._count { + _subscriptions.append(SingleAssignmentDisposable()) + } + + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event, atIndex: Int) { + _lock.lock(); defer { _lock.unlock() } // { + switch event { + case .next(let element): + if _values[atIndex] == nil { + _numberOfValues += 1 + } + + _values[atIndex] = element + + if _numberOfValues < _parent._count { + let numberOfOthersThatAreDone = self._numberOfDone - (_isDone[atIndex] ? 1 : 0) + if numberOfOthersThatAreDone == self._parent._count - 1 { + forwardOn(.completed) + dispose() + } + return + } + + do { + let result = try _parent._resultSelector(_values.map { $0! }) + forwardOn(.next(result)) + } + catch let error { + forwardOn(.error(error)) + dispose() + } + + case .error(let error): + forwardOn(.error(error)) + dispose() + case .completed: + if _isDone[atIndex] { + return + } + + _isDone[atIndex] = true + _numberOfDone += 1 + + if _numberOfDone == self._parent._count { + forwardOn(.completed) + dispose() + } + else { + _subscriptions[atIndex].dispose() + } + } + // } + } + + func run() -> Disposable { + var j = 0 + for i in _parent._sources { + let index = j + let source = i.asObservable() + let disposable = source.subscribe(AnyObserver { event in + self.on(event, atIndex: index) + }) + + _subscriptions[j].setDisposable(disposable) + + j += 1 + } + + return Disposables.create(_subscriptions) + } +} + +class CombineLatestCollectionType : Producer where C.Iterator.Element : ObservableConvertibleType { + typealias ResultSelector = ([C.Iterator.Element.E]) throws -> R + + let _sources: C + let _resultSelector: ResultSelector + let _count: Int + + init(sources: C, resultSelector: @escaping ResultSelector) { + _sources = sources + _resultSelector = resultSelector + _count = Int(self._sources.count.toIntMax()) + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = CombineLatestCollectionTypeSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift new file mode 100644 index 0000000..33eadc0 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest+arity.swift @@ -0,0 +1,726 @@ +// This file is autogenerated. Take a look at `Preprocessor` target in RxSwift project +// +// CombineLatest+arity.swift +// RxSwift +// +// Created by Krunoslav Zaher on 4/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + + +// 2 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, resultSelector: @escaping (O1.E, O2.E) throws -> E) + -> Observable { + return CombineLatest2( + source1: source1.asObservable(), source2: source2.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink2_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest2 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 2, observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + + subscription1.setDisposable(_parent._source1.subscribe(observer1)) + subscription2.setDisposable(_parent._source2.subscribe(observer2)) + + return Disposables.create([ + subscription1, + subscription2 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2) + } +} + +class CombineLatest2 : Producer { + typealias ResultSelector = (E1, E2) throws -> R + + let _source1: Observable + let _source2: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, resultSelector: @escaping ResultSelector) { + _source1 = source1 + _source2 = source2 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = CombineLatestSink2_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 3 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, resultSelector: @escaping (O1.E, O2.E, O3.E) throws -> E) + -> Observable { + return CombineLatest3( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink3_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest3 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 3, observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + + subscription1.setDisposable(_parent._source1.subscribe(observer1)) + subscription2.setDisposable(_parent._source2.subscribe(observer2)) + subscription3.setDisposable(_parent._source3.subscribe(observer3)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3) + } +} + +class CombineLatest3 : Producer { + typealias ResultSelector = (E1, E2, E3) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, resultSelector: @escaping ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = CombineLatestSink3_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 4 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E) throws -> E) + -> Observable { + return CombineLatest4( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink4_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest4 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 4, observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + + subscription1.setDisposable(_parent._source1.subscribe(observer1)) + subscription2.setDisposable(_parent._source2.subscribe(observer2)) + subscription3.setDisposable(_parent._source3.subscribe(observer3)) + subscription4.setDisposable(_parent._source4.subscribe(observer4)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4) + } +} + +class CombineLatest4 : Producer { + typealias ResultSelector = (E1, E2, E3, E4) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, resultSelector: @escaping ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = CombineLatestSink4_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 5 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E) + -> Observable { + return CombineLatest5( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink5_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest5 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + var _latestElement5: E5! = nil + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 5, observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + let observer5 = CombineLatestObserver(lock: _lock, parent: self, index: 4, setLatestValue: { (e: E5) -> Void in self._latestElement5 = e }, this: subscription5) + + subscription1.setDisposable(_parent._source1.subscribe(observer1)) + subscription2.setDisposable(_parent._source2.subscribe(observer2)) + subscription3.setDisposable(_parent._source3.subscribe(observer3)) + subscription4.setDisposable(_parent._source4.subscribe(observer4)) + subscription5.setDisposable(_parent._source5.subscribe(observer5)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4, _latestElement5) + } +} + +class CombineLatest5 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + let _source5: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, resultSelector: @escaping ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + _source5 = source5 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = CombineLatestSink5_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 6 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E) + -> Observable { + return CombineLatest6( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink6_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest6 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + var _latestElement5: E5! = nil + var _latestElement6: E6! = nil + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 6, observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + let observer5 = CombineLatestObserver(lock: _lock, parent: self, index: 4, setLatestValue: { (e: E5) -> Void in self._latestElement5 = e }, this: subscription5) + let observer6 = CombineLatestObserver(lock: _lock, parent: self, index: 5, setLatestValue: { (e: E6) -> Void in self._latestElement6 = e }, this: subscription6) + + subscription1.setDisposable(_parent._source1.subscribe(observer1)) + subscription2.setDisposable(_parent._source2.subscribe(observer2)) + subscription3.setDisposable(_parent._source3.subscribe(observer3)) + subscription4.setDisposable(_parent._source4.subscribe(observer4)) + subscription5.setDisposable(_parent._source5.subscribe(observer5)) + subscription6.setDisposable(_parent._source6.subscribe(observer6)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4, _latestElement5, _latestElement6) + } +} + +class CombineLatest6 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + let _source5: Observable + let _source6: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, resultSelector: @escaping ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + _source5 = source5 + _source6 = source6 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = CombineLatestSink6_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 7 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E) + -> Observable { + return CombineLatest7( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), source7: source7.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink7_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest7 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + var _latestElement5: E5! = nil + var _latestElement6: E6! = nil + var _latestElement7: E7! = nil + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 7, observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + let subscription7 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + let observer5 = CombineLatestObserver(lock: _lock, parent: self, index: 4, setLatestValue: { (e: E5) -> Void in self._latestElement5 = e }, this: subscription5) + let observer6 = CombineLatestObserver(lock: _lock, parent: self, index: 5, setLatestValue: { (e: E6) -> Void in self._latestElement6 = e }, this: subscription6) + let observer7 = CombineLatestObserver(lock: _lock, parent: self, index: 6, setLatestValue: { (e: E7) -> Void in self._latestElement7 = e }, this: subscription7) + + subscription1.setDisposable(_parent._source1.subscribe(observer1)) + subscription2.setDisposable(_parent._source2.subscribe(observer2)) + subscription3.setDisposable(_parent._source3.subscribe(observer3)) + subscription4.setDisposable(_parent._source4.subscribe(observer4)) + subscription5.setDisposable(_parent._source5.subscribe(observer5)) + subscription6.setDisposable(_parent._source6.subscribe(observer6)) + subscription7.setDisposable(_parent._source7.subscribe(observer7)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6, + subscription7 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4, _latestElement5, _latestElement6, _latestElement7) + } +} + +class CombineLatest7 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6, E7) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + let _source5: Observable + let _source6: Observable + let _source7: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, source7: Observable, resultSelector: @escaping ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + _source5 = source5 + _source6 = source6 + _source7 = source7 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = CombineLatestSink7_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 8 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E) + -> Observable { + return CombineLatest8( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), source7: source7.asObservable(), source8: source8.asObservable(), + resultSelector: resultSelector + ) + } +} + +class CombineLatestSink8_ : CombineLatestSink { + typealias R = O.E + typealias Parent = CombineLatest8 + + let _parent: Parent + + var _latestElement1: E1! = nil + var _latestElement2: E2! = nil + var _latestElement3: E3! = nil + var _latestElement4: E4! = nil + var _latestElement5: E5! = nil + var _latestElement6: E6! = nil + var _latestElement7: E7! = nil + var _latestElement8: E8! = nil + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 8, observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + let subscription7 = SingleAssignmentDisposable() + let subscription8 = SingleAssignmentDisposable() + + let observer1 = CombineLatestObserver(lock: _lock, parent: self, index: 0, setLatestValue: { (e: E1) -> Void in self._latestElement1 = e }, this: subscription1) + let observer2 = CombineLatestObserver(lock: _lock, parent: self, index: 1, setLatestValue: { (e: E2) -> Void in self._latestElement2 = e }, this: subscription2) + let observer3 = CombineLatestObserver(lock: _lock, parent: self, index: 2, setLatestValue: { (e: E3) -> Void in self._latestElement3 = e }, this: subscription3) + let observer4 = CombineLatestObserver(lock: _lock, parent: self, index: 3, setLatestValue: { (e: E4) -> Void in self._latestElement4 = e }, this: subscription4) + let observer5 = CombineLatestObserver(lock: _lock, parent: self, index: 4, setLatestValue: { (e: E5) -> Void in self._latestElement5 = e }, this: subscription5) + let observer6 = CombineLatestObserver(lock: _lock, parent: self, index: 5, setLatestValue: { (e: E6) -> Void in self._latestElement6 = e }, this: subscription6) + let observer7 = CombineLatestObserver(lock: _lock, parent: self, index: 6, setLatestValue: { (e: E7) -> Void in self._latestElement7 = e }, this: subscription7) + let observer8 = CombineLatestObserver(lock: _lock, parent: self, index: 7, setLatestValue: { (e: E8) -> Void in self._latestElement8 = e }, this: subscription8) + + subscription1.setDisposable(_parent._source1.subscribe(observer1)) + subscription2.setDisposable(_parent._source2.subscribe(observer2)) + subscription3.setDisposable(_parent._source3.subscribe(observer3)) + subscription4.setDisposable(_parent._source4.subscribe(observer4)) + subscription5.setDisposable(_parent._source5.subscribe(observer5)) + subscription6.setDisposable(_parent._source6.subscribe(observer6)) + subscription7.setDisposable(_parent._source7.subscribe(observer7)) + subscription8.setDisposable(_parent._source8.subscribe(observer8)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6, + subscription7, + subscription8 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_latestElement1, _latestElement2, _latestElement3, _latestElement4, _latestElement5, _latestElement6, _latestElement7, _latestElement8) + } +} + +class CombineLatest8 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6, E7, E8) throws -> R + + let _source1: Observable + let _source2: Observable + let _source3: Observable + let _source4: Observable + let _source5: Observable + let _source6: Observable + let _source7: Observable + let _source8: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, source7: Observable, source8: Observable, resultSelector: @escaping ResultSelector) { + _source1 = source1 + _source2 = source2 + _source3 = source3 + _source4 = source4 + _source5 = source5 + _source6 = source6 + _source7 = source7 + _source8 = source8 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = CombineLatestSink8_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift new file mode 100644 index 0000000..a84eb5b --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/CombineLatest.swift @@ -0,0 +1,134 @@ +// +// CombineLatest.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol CombineLatestProtocol : class { + func next(_ index: Int) + func fail(_ error: Swift.Error) + func done(_ index: Int) +} + +class CombineLatestSink + : Sink + , CombineLatestProtocol { + typealias Element = O.E + + let _lock = NSRecursiveLock() + + private let _arity: Int + private var _numberOfValues = 0 + private var _numberOfDone = 0 + private var _hasValue: [Bool] + private var _isDone: [Bool] + + init(arity: Int, observer: O, cancel: Cancelable) { + _arity = arity + _hasValue = [Bool](repeating: false, count: arity) + _isDone = [Bool](repeating: false, count: arity) + + super.init(observer: observer, cancel: cancel) + } + + func getResult() throws -> Element { + abstractMethod() + } + + func next(_ index: Int) { + if !_hasValue[index] { + _hasValue[index] = true + _numberOfValues += 1 + } + + if _numberOfValues == _arity { + do { + let result = try getResult() + forwardOn(.next(result)) + } + catch let e { + forwardOn(.error(e)) + dispose() + } + } + else { + var allOthersDone = true + + for i in 0 ..< _arity { + if i != index && !_isDone[i] { + allOthersDone = false + break + } + } + + if allOthersDone { + forwardOn(.completed) + dispose() + } + } + } + + func fail(_ error: Swift.Error) { + forwardOn(.error(error)) + dispose() + } + + func done(_ index: Int) { + if _isDone[index] { + return + } + + _isDone[index] = true + _numberOfDone += 1 + + if _numberOfDone == _arity { + forwardOn(.completed) + dispose() + } + } +} + +class CombineLatestObserver + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Element = ElementType + typealias ValueSetter = (Element) -> Void + + private let _parent: CombineLatestProtocol + + let _lock: NSRecursiveLock + private let _index: Int + private let _this: Disposable + private let _setLatestValue: ValueSetter + + init(lock: NSRecursiveLock, parent: CombineLatestProtocol, index: Int, setLatestValue: @escaping ValueSetter, this: Disposable) { + _lock = lock + _parent = parent + _index = index + _this = this + _setLatestValue = setLatestValue + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let value): + _setLatestValue(value) + _parent.next(_index) + case .error(let error): + _this.dispose() + _parent.fail(error) + case .completed: + _this.dispose() + _parent.done(_index) + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift new file mode 100644 index 0000000..6787558 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift @@ -0,0 +1,63 @@ +// +// Concat.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + +class ConcatSink + : TailRecursiveSink + , ObserverType where S.Iterator.Element : ObservableConvertibleType, S.Iterator.Element.E == O.E { + typealias Element = O.E + + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event){ + switch event { + case .next: + forwardOn(event) + case .error: + forwardOn(event) + dispose() + case .completed: + schedule(.moveNext) + } + } + + override func subscribeToNext(_ source: Observable) -> Disposable { + return source.subscribe(self) + } + + override func extract(_ observable: Observable) -> SequenceGenerator? { + if let source = observable as? Concat { + return (source._sources.makeIterator(), source._count) + } + else { + return nil + } + } +} + +class Concat : Producer where S.Iterator.Element : ObservableConvertibleType { + typealias Element = S.Iterator.Element.E + + fileprivate let _sources: S + fileprivate let _count: IntMax? + + init(sources: S, count: IntMax?) { + _sources = sources + _count = count + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = ConcatSink(observer: observer, cancel: cancel) + let subscription = sink.run((_sources.makeIterator(), _count)) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift new file mode 100644 index 0000000..db5611b --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift @@ -0,0 +1,96 @@ +// +// ConnectableObservable.swift +// Rx +// +// Created by Krunoslav Zaher on 3/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** + Represents an observable wrapper that can be connected and disconnected from its underlying observable sequence. +*/ +public class ConnectableObservable + : Observable + , ConnectableObservableType { + + /** + 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. + + - returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence. + */ + public func connect() -> Disposable { + abstractMethod() + } +} + +class Connection : Disposable { + + private var _lock: NSRecursiveLock + // state + private var _parent: ConnectableObservableAdapter? + private var _subscription : Disposable? + + init(parent: ConnectableObservableAdapter, lock: NSRecursiveLock, subscription: Disposable) { + _parent = parent + _subscription = subscription + _lock = lock + } + + func dispose() { + _lock.lock(); defer { _lock.unlock() } // { + guard let parent = _parent else { + return + } + + guard let oldSubscription = _subscription else { + return + } + + _subscription = nil + if parent._connection === self { + parent._connection = nil + } + _parent = nil + + oldSubscription.dispose() + // } + } +} + +class ConnectableObservableAdapter + : ConnectableObservable { + typealias ConnectionType = Connection + + fileprivate let _subject: S + fileprivate let _source: Observable + + fileprivate let _lock = NSRecursiveLock() + + // state + fileprivate var _connection: ConnectionType? + + init(source: Observable, subject: S) { + _source = source + _subject = subject + _connection = nil + } + + override func connect() -> Disposable { + return _lock.calculateLocked { + if let connection = _connection { + return connection + } + + let disposable = _source.subscribe(_subject.asObserver()) + let connection = Connection(parent: self, lock: _lock, subscription: disposable) + _connection = connection + return connection + } + } + + override func subscribe(_ observer: O) -> Disposable where O.E == S.E { + return _subject.subscribe(observer) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift new file mode 100644 index 0000000..1f5d3ea --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift @@ -0,0 +1,81 @@ +// +// Debug.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +let dateFormat = "yyyy-MM-dd HH:mm:ss.SSS" + +func logEvent(_ identifier: String, dateFormat: DateFormatter, content: String) { + print("\(dateFormat.string(from: Date())): \(identifier) -> \(content)") +} + +class DebugSink : Sink, ObserverType where O.E == Source.E { + typealias Element = O.E + typealias Parent = Debug + + private let _parent: Parent + private let _timestampFormatter = DateFormatter() + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _timestampFormatter.dateFormat = dateFormat + + logEvent(_parent._identifier, dateFormat: _timestampFormatter, content: "subscribed") + + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + let maxEventTextLength = 40 + let eventText = "\(event)" + let eventNormalized = eventText.characters.count > maxEventTextLength + ? String(eventText.characters.prefix(maxEventTextLength / 2)) + "..." + String(eventText.characters.suffix(maxEventTextLength / 2)) + : eventText + + logEvent(_parent._identifier, dateFormat: _timestampFormatter, content: "Event \(eventNormalized)") + + forwardOn(event) + if event.isStopEvent { + dispose() + } + } + + override func dispose() { + logEvent(_parent._identifier, dateFormat: _timestampFormatter, content: "isDisposed") + super.dispose() + } +} + +class Debug : Producer { + fileprivate let _identifier: String + + fileprivate let _source: Source + + init(source: Source, identifier: String?, file: String, line: UInt, function: String) { + if let identifier = identifier { + _identifier = identifier + } + else { + let trimmedFile: String + if let lastIndex = file.lastIndexOf("/") { + trimmedFile = file[file.index(after: lastIndex) ..< file.endIndex] + } + else { + trimmedFile = file + } + _identifier = "\(trimmedFile):\(line) (\(function))" + } + _source = source + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Source.E { + let sink = DebugSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Debunce.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Debunce.swift new file mode 100644 index 0000000..3f85d37 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Debunce.swift @@ -0,0 +1,104 @@ +// +// Debunce.swift +// Rx +// +// Created by Krunoslav Zaher on 9/11/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DebounceSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Element = O.E + typealias ParentType = Debounce + + private let _parent: ParentType + + let _lock = NSRecursiveLock() + + // state + private var _id = 0 as UInt64 + private var _value: Element? = nil + + let cancellable = SerialDisposable() + + init(parent: ParentType, observer: O, cancel: Cancelable) { + _parent = parent + + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription = _parent._source.subscribe(self) + + return Disposables.create(subscription, cancellable) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let element): + _id = _id &+ 1 + let currentId = _id + _value = element + + + let scheduler = _parent._scheduler + let dueTime = _parent._dueTime + + let d = SingleAssignmentDisposable() + self.cancellable.disposable = d + d.setDisposable(scheduler.scheduleRelative(currentId, dueTime: dueTime, action: self.propagate)) + case .error: + _value = nil + forwardOn(event) + dispose() + case .completed: + if let value = _value { + _value = nil + forwardOn(.next(value)) + } + forwardOn(.completed) + dispose() + } + } + + func propagate(_ currentId: UInt64) -> Disposable { + _lock.lock(); defer { _lock.unlock() } // { + let originalValue = _value + + if let value = originalValue, _id == currentId { + _value = nil + forwardOn(.next(value)) + } + // } + return Disposables.create() + } +} + +class Debounce : Producer { + + fileprivate let _source: Observable + fileprivate let _dueTime: RxTimeInterval + fileprivate let _scheduler: SchedulerType + + init(source: Observable, dueTime: RxTimeInterval, scheduler: SchedulerType) { + _source = source + _dueTime = dueTime + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = DebounceSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } + +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift new file mode 100644 index 0000000..43182ce --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift @@ -0,0 +1,61 @@ +// +// Deferred.swift +// RxSwift +// +// Created by Krunoslav Zaher on 4/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DeferredSink : Sink, ObserverType where S.E == O.E { + typealias E = O.E + + private let _observableFactory: () throws -> S + + init(observableFactory: @escaping () throws -> S, observer: O, cancel: Cancelable) { + _observableFactory = observableFactory + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + do { + let result = try _observableFactory() + return result.subscribe(self) + } + catch let e { + forwardOn(.error(e)) + dispose() + return Disposables.create() + } + } + + func on(_ event: Event) { + forwardOn(event) + + switch event { + case .next: + break + case .error: + dispose() + case .completed: + dispose() + } + } +} + +class Deferred : Producer { + typealias Factory = () throws -> S + + private let _observableFactory : Factory + + init(observableFactory: @escaping Factory) { + _observableFactory = observableFactory + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { + let sink = DeferredSink(observableFactory: _observableFactory, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift new file mode 100644 index 0000000..1697692 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Delay.swift @@ -0,0 +1,164 @@ +// +// Delay.swift +// RxSwift +// +// Created by tarunon on 2016/02/09. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DelaySink + : Sink + , ObserverType where O.E == ElementType { + typealias E = O.E + typealias Source = Observable + typealias DisposeKey = Bag.KeyType + + private let _lock = NSRecursiveLock() + + private let _dueTime: RxTimeInterval + private let _scheduler: SchedulerType + + private let _sourceSubscription = SingleAssignmentDisposable() + private let _cancelable = SerialDisposable() + + // is scheduled some action + private var _active = false + // is "run loop" on different scheduler running + private var _running = false + private var _errorEvent: Event? = nil + + // state + private var _queue = Queue<(eventTime: RxTime, event: Event)>(capacity: 0) + private var _disposed = false + + init(observer: O, dueTime: RxTimeInterval, scheduler: SchedulerType, cancel: Cancelable) { + _dueTime = dueTime + _scheduler = scheduler + super.init(observer: observer, cancel: cancel) + } + + // All of these complications in this method are caused by the fact that + // error should be propagated immediatelly. Error can bepotentially received on different + // scheduler so this process needs to be synchronized somehow. + // + // Another complication is that scheduler is potentially concurrent so internal queue is used. + func drainQueue(state: (), scheduler: AnyRecursiveScheduler<()>) { + + _lock.lock() // { + let hasFailed = _errorEvent != nil + if !hasFailed { + _running = true + } + _lock.unlock() // } + + if hasFailed { + return + } + + var ranAtLeastOnce = false + + while true { + _lock.lock() // { + let errorEvent = _errorEvent + + let eventToForwardImmediatelly = ranAtLeastOnce ? nil : _queue.dequeue()?.event + let nextEventToScheduleOriginalTime: Date? = ranAtLeastOnce && !_queue.isEmpty ? _queue.peek().eventTime : nil + + if let _ = errorEvent { + } + else { + if let _ = eventToForwardImmediatelly { + } + else if let _ = nextEventToScheduleOriginalTime { + _running = false + } + else { + _running = false + _active = false + } + } + _lock.unlock() // { + + if let errorEvent = errorEvent { + self.forwardOn(errorEvent) + self.dispose() + return + } + else { + if let eventToForwardImmediatelly = eventToForwardImmediatelly { + ranAtLeastOnce = true + self.forwardOn(eventToForwardImmediatelly) + if case .completed = eventToForwardImmediatelly { + self.dispose() + return + } + } + else if let nextEventToScheduleOriginalTime = nextEventToScheduleOriginalTime { + let elapsedTime = _scheduler.now.timeIntervalSince(nextEventToScheduleOriginalTime) + let interval = _dueTime - elapsedTime + let normalizedInterval = interval < 0.0 ? 0.0 : interval + scheduler.schedule((), dueTime: normalizedInterval) + return + } + else { + return + } + } + } + } + + func on(_ event: Event) { + if event.isStopEvent { + _sourceSubscription.dispose() + } + + switch event { + case .error(_): + _lock.lock() // { + let shouldSendImmediatelly = !_running + _queue = Queue(capacity: 0) + _errorEvent = event + _lock.unlock() // } + + if shouldSendImmediatelly { + forwardOn(event) + dispose() + } + default: + _lock.lock() // { + let shouldSchedule = !_active + _active = true + _queue.enqueue((_scheduler.now, event)) + _lock.unlock() // } + + if shouldSchedule { + _cancelable.disposable = _scheduler.scheduleRecursive((), dueTime: _dueTime, action: self.drainQueue) + } + } + } + + func run(source: Source) -> Disposable { + _sourceSubscription.setDisposable(source.subscribeSafe(self)) + return Disposables.create(_sourceSubscription, _cancelable) + } +} + +class Delay: Producer { + private let _source: Observable + private let _dueTime: RxTimeInterval + private let _scheduler: SchedulerType + + init(source: Observable, dueTime: RxTimeInterval, scheduler: SchedulerType) { + _source = source + _dueTime = dueTime + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = DelaySink(observer: observer, dueTime: _dueTime, scheduler: _scheduler, cancel: cancel) + let subscription = sink.run(source: _source) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift new file mode 100644 index 0000000..d7abf20 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift @@ -0,0 +1,52 @@ +// +// DelaySubscription.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DelaySubscriptionSink + : Sink + , ObserverType where O.E == ElementType { + typealias Parent = DelaySubscription + typealias E = O.E + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + forwardOn(event) + if event.isStopEvent { + dispose() + } + } + +} + +class DelaySubscription: Producer { + private let _source: Observable + private let _dueTime: RxTimeInterval + private let _scheduler: SchedulerType + + init(source: Observable, dueTime: RxTimeInterval, scheduler: SchedulerType) { + _source = source + _dueTime = dueTime + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = DelaySubscriptionSink(parent: self, observer: observer, cancel: cancel) + let subscription = _scheduler.scheduleRelative((), dueTime: _dueTime) { _ in + return self._source.subscribe(sink) + } + + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift new file mode 100644 index 0000000..770a531 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift @@ -0,0 +1,70 @@ +// +// DistinctUntilChanged.swift +// Rx +// +// Created by Krunoslav Zaher on 3/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DistinctUntilChangedSink: Sink, ObserverType { + typealias E = O.E + + private let _parent: DistinctUntilChanged + private var _currentKey: Key? = nil + + init(parent: DistinctUntilChanged, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + do { + let key = try _parent._selector(value) + var areEqual = false + if let currentKey = _currentKey { + areEqual = try _parent._comparer(currentKey, key) + } + + if areEqual { + return + } + + _currentKey = key + + forwardOn(event) + } + catch let error { + forwardOn(.error(error)) + dispose() + } + case .error, .completed: + forwardOn(event) + dispose() + } + } +} + +class DistinctUntilChanged: Producer { + typealias KeySelector = (Element) throws -> Key + typealias EqualityComparer = (Key, Key) throws -> Bool + + fileprivate let _source: Observable + fileprivate let _selector: KeySelector + fileprivate let _comparer: EqualityComparer + + init(source: Observable, selector: @escaping KeySelector, comparer: @escaping EqualityComparer) { + _source = source + _selector = selector + _comparer = comparer + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = DistinctUntilChangedSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift new file mode 100644 index 0000000..726a992 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift @@ -0,0 +1,63 @@ +// +// Do.swift +// Rx +// +// Created by Krunoslav Zaher on 2/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class DoSink : Sink, ObserverType { + typealias Element = O.E + typealias Parent = Do + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + do { + try _parent._eventHandler(event) + forwardOn(event) + if event.isStopEvent { + dispose() + } + } + catch let error { + forwardOn(.error(error)) + dispose() + } + } +} + +class Do : Producer { + typealias EventHandler = (Event) throws -> Void + + fileprivate let _source: Observable + fileprivate let _eventHandler: EventHandler + fileprivate let _onSubscribe: (() -> ())? + fileprivate let _onDispose: (() -> ())? + + init(source: Observable, eventHandler: @escaping EventHandler, onSubscribe: (() -> ())?, onDispose: (() -> ())?) { + _source = source + _eventHandler = eventHandler + _onSubscribe = onSubscribe + _onDispose = onDispose + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + _onSubscribe?() + let sink = DoSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + let onDispose = _onDispose + let allSubscriptions = Disposables.create { + subscription.dispose() + onDispose?() + } + return (sink: sink, subscription: allSubscriptions) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift new file mode 100644 index 0000000..6e26141 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift @@ -0,0 +1,79 @@ +// +// ElementAt.swift +// Rx +// +// Created by Junior B. on 21/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + +class ElementAtSink : Sink, ObserverType where O.E == SourceType { + typealias Parent = ElementAt + + let _parent: Parent + var _i: Int + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _i = parent._index + + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(_): + + if (_i == 0) { + forwardOn(event) + forwardOn(.completed) + self.dispose() + } + + do { + let _ = try decrementChecked(&_i) + } catch(let e) { + forwardOn(.error(e)) + dispose() + return + } + + case .error(let e): + forwardOn(.error(e)) + self.dispose() + case .completed: + if (_parent._throwOnEmpty) { + forwardOn(.error(RxError.argumentOutOfRange)) + } else { + forwardOn(.completed) + } + + self.dispose() + } + } +} + +class ElementAt : Producer { + + let _source: Observable + let _throwOnEmpty: Bool + let _index: Int + + init(source: Observable, index: Int, throwOnEmpty: Bool) { + if index < 0 { + rxFatalError("index can't be negative") + } + + self._source = source + self._index = index + self._throwOnEmpty = throwOnEmpty + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == SourceType { + let sink = ElementAtSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribeSafe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift new file mode 100644 index 0000000..f28690f --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift @@ -0,0 +1,16 @@ +// +// Empty.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Empty : Producer { + override func subscribe(_ observer: O) -> Disposable where O.E == Element { + observer.on(.completed) + return Disposables.create() + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift new file mode 100644 index 0000000..49d89d9 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Error.swift @@ -0,0 +1,22 @@ +// +// Error.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Error : Producer { + private let _error: Swift.Error + + init(error: Swift.Error) { + _error = error + } + + override func subscribe(_ observer: O) -> Disposable where O.E == Element { + observer.on(.error(_error)) + return Disposables.create() + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift new file mode 100644 index 0000000..db97fdf --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift @@ -0,0 +1,58 @@ +// +// Filter.swift +// Rx +// +// Created by Krunoslav Zaher on 2/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class FilterSink: Sink, ObserverType { + typealias Predicate = (Element) throws -> Bool + typealias Element = O.E + + private let _predicate: Predicate + + init(predicate: @escaping Predicate, observer: O, cancel: Cancelable) { + _predicate = predicate + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + do { + let satisfies = try _predicate(value) + if satisfies { + forwardOn(.next(value)) + } + } + catch let e { + forwardOn(.error(e)) + dispose() + } + case .completed, .error: + forwardOn(event) + dispose() + } + } +} + +class Filter : Producer { + typealias Predicate = (Element) throws -> Bool + + private let _source: Observable + private let _predicate: Predicate + + init(source: Observable, predicate: @escaping Predicate) { + _source = source + _predicate = predicate + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = FilterSink(predicate: _predicate, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift new file mode 100644 index 0000000..bcd380b --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift @@ -0,0 +1,71 @@ +// +// Generate.swift +// Rx +// +// Created by Krunoslav Zaher on 9/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class GenerateSink : Sink { + typealias Parent = Generate + + private let _parent: Parent + + private var _state: S + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _state = parent._initialState + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRecursive(true) { (isFirst, recurse) -> Void in + do { + if !isFirst { + self._state = try self._parent._iterate(self._state) + } + + if try self._parent._condition(self._state) { + let result = try self._parent._resultSelector(self._state) + self.forwardOn(.next(result)) + + recurse(false) + } + else { + self.forwardOn(.completed) + self.dispose() + } + } + catch let error { + self.forwardOn(.error(error)) + self.dispose() + } + } + } +} + +class Generate : Producer { + fileprivate let _initialState: S + fileprivate let _condition: (S) throws -> Bool + fileprivate let _iterate: (S) throws -> S + fileprivate let _resultSelector: (S) throws -> E + fileprivate let _scheduler: ImmediateSchedulerType + + init(initialState: S, condition: @escaping (S) throws -> Bool, iterate: @escaping (S) throws -> S, resultSelector: @escaping (S) throws -> E, scheduler: ImmediateSchedulerType) { + _initialState = initialState + _condition = condition + _iterate = iterate + _resultSelector = resultSelector + _scheduler = scheduler + super.init() + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { + let sink = GenerateSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift new file mode 100644 index 0000000..eaabfb5 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift @@ -0,0 +1,61 @@ +// +// Just.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class JustScheduledSink : Sink { + typealias Parent = JustScheduled + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let scheduler = _parent._scheduler + return scheduler.schedule(_parent._element) { element in + self.forwardOn(.next(element)) + return scheduler.schedule(()) { _ in + self.forwardOn(.completed) + return Disposables.create() + } + } + } +} + +class JustScheduled : Producer { + fileprivate let _scheduler: ImmediateSchedulerType + fileprivate let _element: Element + + init(element: Element, scheduler: ImmediateSchedulerType) { + _scheduler = scheduler + _element = element + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { + let sink = JustScheduledSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + +class Just : Producer { + private let _element: Element + + init(element: Element) { + _element = element + } + + override func subscribe(_ observer: O) -> Disposable where O.E == Element { + observer.on(.next(_element)) + observer.on(.completed) + return Disposables.create() + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift new file mode 100644 index 0000000..b646c41 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Map.swift @@ -0,0 +1,140 @@ +// +// Map.swift +// Rx +// +// Created by Krunoslav Zaher on 3/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class MapSink : Sink, ObserverType { + typealias Selector = (SourceType) throws -> ResultType + + typealias ResultType = O.E + typealias Element = SourceType + + private let _selector: Selector + + init(selector: @escaping Selector, observer: O, cancel: Cancelable) { + _selector = selector + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let element): + do { + let mappedElement = try _selector(element) + forwardOn(.next(mappedElement)) + } + catch let e { + forwardOn(.error(e)) + dispose() + } + case .error(let error): + forwardOn(.error(error)) + dispose() + case .completed: + forwardOn(.completed) + dispose() + } + } +} + +class MapWithIndexSink : Sink, ObserverType { + typealias Selector = (SourceType, Int) throws -> ResultType + + typealias ResultType = O.E + typealias Element = SourceType + typealias Parent = MapWithIndex + + private let _selector: Selector + + private var _index = 0 + + init(selector: @escaping Selector, observer: O, cancel: Cancelable) { + _selector = selector + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let element): + do { + let mappedElement = try _selector(element, try incrementChecked(&_index)) + forwardOn(.next(mappedElement)) + } + catch let e { + forwardOn(.error(e)) + dispose() + } + case .error(let error): + forwardOn(.error(error)) + dispose() + case .completed: + forwardOn(.completed) + dispose() + } + } +} + +class MapWithIndex : Producer { + typealias Selector = (SourceType, Int) throws -> ResultType + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: @escaping Selector) { + _source = source + _selector = selector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == ResultType { + let sink = MapWithIndexSink(selector: _selector, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} + +#if TRACE_RESOURCES +public var numberOfMapOperators: Int32 = 0 +#endif + +class Map: Producer { + typealias Selector = (SourceType) throws -> ResultType + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: @escaping Selector) { + _source = source + _selector = selector + +#if TRACE_RESOURCES + let _ = AtomicIncrement(&numberOfMapOperators) +#endif + } + + override func composeMap(_ selector: @escaping (ResultType) throws -> R) -> Observable { + let originalSelector = _selector + return Map(source: _source, selector: { (s: SourceType) throws -> R in + let r: ResultType = try originalSelector(s) + return try selector(r) + }) + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == ResultType { + let sink = MapSink(selector: _selector, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } + + #if TRACE_RESOURCES + deinit { + let _ = AtomicDecrement(&numberOfMapOperators) + } + #endif +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift new file mode 100644 index 0000000..9916270 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Merge.swift @@ -0,0 +1,424 @@ +// +// Merge.swift +// Rx +// +// Created by Krunoslav Zaher on 3/28/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: Limited concurrency version + +class MergeLimitedSinkIter + : ObserverType + , LockOwnerType + , SynchronizedOnType where S.E == O.E { + typealias E = O.E + typealias DisposeKey = Bag.KeyType + typealias Parent = MergeLimitedSink + + private let _parent: Parent + private let _disposeKey: DisposeKey + + var _lock: NSRecursiveLock { + return _parent._lock + } + + init(parent: Parent, disposeKey: DisposeKey) { + _parent = parent + _disposeKey = disposeKey + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next: + _parent.forwardOn(event) + case .error: + _parent.forwardOn(event) + _parent.dispose() + case .completed: + _parent._group.remove(for: _disposeKey) + if let next = _parent._queue.dequeue() { + _parent.subscribe(next, group: _parent._group) + } + else { + _parent._activeCount = _parent._activeCount - 1 + + if _parent._stopped && _parent._activeCount == 0 { + _parent.forwardOn(.completed) + _parent.dispose() + } + } + } + } +} + +class MergeLimitedSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType where S.E == O.E { + typealias E = S + typealias QueueType = Queue + + fileprivate let _maxConcurrent: Int + + let _lock = NSRecursiveLock() + + // state + fileprivate var _stopped = false + fileprivate var _activeCount = 0 + fileprivate var _queue = QueueType(capacity: 2) + + fileprivate let _sourceSubscription = SingleAssignmentDisposable() + fileprivate let _group = CompositeDisposable() + + init(maxConcurrent: Int, observer: O, cancel: Cancelable) { + _maxConcurrent = maxConcurrent + + let _ = _group.insert(_sourceSubscription) + super.init(observer: observer, cancel: cancel) + } + + func run(_ source: Observable) -> Disposable { + let _ = _group.insert(_sourceSubscription) + + let disposable = source.subscribe(self) + _sourceSubscription.setDisposable(disposable) + return _group + } + + func subscribe(_ innerSource: E, group: CompositeDisposable) { + let subscription = SingleAssignmentDisposable() + + let key = group.insert(subscription) + + if let key = key { + let observer = MergeLimitedSinkIter(parent: self, disposeKey: key) + + let disposable = innerSource.asObservable().subscribe(observer) + subscription.setDisposable(disposable) + } + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let value): + let subscribe: Bool + if _activeCount < _maxConcurrent { + _activeCount += 1 + subscribe = true + } + else { + _queue.enqueue(value) + subscribe = false + } + + if subscribe { + self.subscribe(value, group: _group) + } + case .error(let error): + forwardOn(.error(error)) + dispose() + case .completed: + if _activeCount == 0 { + forwardOn(.completed) + dispose() + } + else { + _sourceSubscription.dispose() + } + + _stopped = true + } + } +} + +class MergeLimited : Producer { + private let _source: Observable + private let _maxConcurrent: Int + + init(source: Observable, maxConcurrent: Int) { + _source = source + _maxConcurrent = maxConcurrent + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { + let sink = MergeLimitedSink(maxConcurrent: _maxConcurrent, observer: observer, cancel: cancel) + let subscription = sink.run(_source) + return (sink: sink, subscription: subscription) + } +} + +// MARK: Merge + +final class MergeBasicSink : MergeSink where O.E == S.E { + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + override func performMap(_ element: S) throws -> S { + return element + } +} + +// MARK: flatMap + +final class FlatMapSink : MergeSink where O.E == S.E { + typealias Selector = (SourceType) throws -> S + + private let _selector: Selector + + init(selector: @escaping Selector, observer: O, cancel: Cancelable) { + _selector = selector + super.init(observer: observer, cancel: cancel) + } + + override func performMap(_ element: SourceType) throws -> S { + return try _selector(element) + } +} + +final class FlatMapWithIndexSink : MergeSink where O.E == S.E { + typealias Selector = (SourceType, Int) throws -> S + + private var _index = 0 + private let _selector: Selector + + init(selector: @escaping Selector, observer: O, cancel: Cancelable) { + _selector = selector + super.init(observer: observer, cancel: cancel) + } + + override func performMap(_ element: SourceType) throws -> S { + return try _selector(element, try incrementChecked(&_index)) + } +} + +// MARK: FlatMapFirst + +final class FlatMapFirstSink : MergeSink where O.E == S.E { + typealias Selector = (SourceType) throws -> S + + private let _selector: Selector + + override var subscribeNext: Bool { + return _group.count == MergeNoIterators + } + + init(selector: @escaping Selector, observer: O, cancel: Cancelable) { + _selector = selector + super.init(observer: observer, cancel: cancel) + } + + override func performMap(_ element: SourceType) throws -> S { + return try _selector(element) + } +} + +// It's value is one because initial source subscription is always in CompositeDisposable +private let MergeNoIterators = 1 + +class MergeSinkIter : ObserverType where O.E == S.E { + typealias Parent = MergeSink + typealias DisposeKey = CompositeDisposable.DisposeKey + typealias E = O.E + + private let _parent: Parent + private let _disposeKey: DisposeKey + + init(parent: Parent, disposeKey: DisposeKey) { + _parent = parent + _disposeKey = disposeKey + } + + func on(_ event: Event) { + switch event { + case .next(let value): + _parent._lock.lock(); defer { _parent._lock.unlock() } // lock { + _parent.forwardOn(.next(value)) + // } + case .error(let error): + _parent._lock.lock(); defer { _parent._lock.unlock() } // lock { + _parent.forwardOn(.error(error)) + _parent.dispose() + // } + case .completed: + _parent._group.remove(for: _disposeKey) + // If this has returned true that means that `Completed` should be sent. + // In case there is a race who will sent first completed, + // lock will sort it out. When first Completed message is sent + // it will set observer to nil, and thus prevent further complete messages + // to be sent, and thus preserving the sequence grammar. + if _parent._stopped && _parent._group.count == MergeNoIterators { + _parent._lock.lock(); defer { _parent._lock.unlock() } // lock { + _parent.forwardOn(.completed) + _parent.dispose() + // } + } + } + } +} + + +class MergeSink + : Sink + , ObserverType where O.E == S.E { + typealias ResultType = O.E + typealias Element = SourceType + + fileprivate let _lock = NSRecursiveLock() + + fileprivate var subscribeNext: Bool { + return true + } + + // state + fileprivate let _group = CompositeDisposable() + fileprivate let _sourceSubscription = SingleAssignmentDisposable() + + fileprivate var _stopped = false + + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + func performMap(_ element: SourceType) throws -> S { + abstractMethod() + } + + func on(_ event: Event) { + switch event { + case .next(let element): + if !subscribeNext { + return + } + do { + let value = try performMap(element) + subscribeInner(value.asObservable()) + } + catch let e { + forwardOn(.error(e)) + dispose() + } + case .error(let error): + _lock.lock(); defer { _lock.unlock() } // lock { + forwardOn(.error(error)) + dispose() + // } + case .completed: + _lock.lock(); defer { _lock.unlock() } // lock { + _stopped = true + if _group.count == MergeNoIterators { + forwardOn(.completed) + dispose() + } + else { + _sourceSubscription.dispose() + } + //} + } + } + + func subscribeInner(_ source: Observable) { + let iterDisposable = SingleAssignmentDisposable() + if let disposeKey = _group.insert(iterDisposable) { + let iter = MergeSinkIter(parent: self, disposeKey: disposeKey) + let subscription = source.subscribe(iter) + iterDisposable.setDisposable(subscription) + } + } + + func run(_ source: Observable) -> Disposable { + let _ = _group.insert(_sourceSubscription) + + let subscription = source.subscribe(self) + _sourceSubscription.setDisposable(subscription) + + return _group + } +} + +// MARK: Producers + +final class FlatMap: Producer { + typealias Selector = (SourceType) throws -> S + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: @escaping Selector) { + _source = source + _selector = selector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { + let sink = FlatMapSink(selector: _selector, observer: observer, cancel: cancel) + let subscription = sink.run(_source) + return (sink: sink, subscription: subscription) + } +} + +final class FlatMapWithIndex: Producer { + typealias Selector = (SourceType, Int) throws -> S + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: @escaping Selector) { + _source = source + _selector = selector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { + let sink = FlatMapWithIndexSink(selector: _selector, observer: observer, cancel: cancel) + let subscription = sink.run(_source) + return (sink: sink, subscription: subscription) + } + +} + +final class FlatMapFirst: Producer { + typealias Selector = (SourceType) throws -> S + + private let _source: Observable + + private let _selector: Selector + + init(source: Observable, selector: @escaping Selector) { + _source = source + _selector = selector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { + let sink = FlatMapFirstSink(selector: _selector, observer: observer, cancel: cancel) + let subscription = sink.run(_source) + return (sink: sink, subscription: subscription) + } +} + +final class Merge : Producer { + private let _source: Observable + + init(source: Observable) { + _source = source + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { + let sink = MergeBasicSink(observer: observer, cancel: cancel) + let subscription = sink.run(_source) + return (sink: sink, subscription: subscription) + } +} + diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift new file mode 100644 index 0000000..e9ec4d1 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift @@ -0,0 +1,71 @@ +// +// Multicast.swift +// Rx +// +// Created by Krunoslav Zaher on 2/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class MulticastSink: Sink, ObserverType { + typealias Element = O.E + typealias ResultType = Element + typealias MutlicastType = Multicast + + private let _parent: MutlicastType + + init(parent: MutlicastType, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + do { + let subject = try _parent._subjectSelector() + let connectable = ConnectableObservableAdapter(source: _parent._source, subject: subject) + + let observable = try _parent._selector(connectable) + + let subscription = observable.subscribe(self) + let connection = connectable.connect() + + return Disposables.create(subscription, connection) + } + catch let e { + forwardOn(.error(e)) + dispose() + return Disposables.create() + } + } + + func on(_ event: Event) { + forwardOn(event) + switch event { + case .next: break + case .error, .completed: + dispose() + } + } +} + +class Multicast: Producer { + typealias SubjectSelectorType = () throws -> S + typealias SelectorType = (Observable) throws -> Observable + + fileprivate let _source: Observable + fileprivate let _subjectSelector: SubjectSelectorType + fileprivate let _selector: SelectorType + + init(source: Observable, subjectSelector: @escaping SubjectSelectorType, selector: @escaping SelectorType) { + _source = source + _subjectSelector = subjectSelector + _selector = selector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = MulticastSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift new file mode 100644 index 0000000..82d28ec --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift @@ -0,0 +1,15 @@ +// +// Never.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Never : Producer { + override func subscribe(_ observer: O) -> Disposable where O.E == Element { + return Disposables.create() + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift new file mode 100644 index 0000000..901062a --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOn.swift @@ -0,0 +1,129 @@ +// +// ObserveOn.swift +// RxSwift +// +// Created by Krunoslav Zaher on 7/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ObserveOn : Producer { + let scheduler: ImmediateSchedulerType + let source: Observable + + init(source: Observable, scheduler: ImmediateSchedulerType) { + self.scheduler = scheduler + self.source = source + +#if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) +#endif + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { + let sink = ObserveOnSink(scheduler: scheduler, observer: observer, cancel: cancel) + let subscription = source.subscribe(sink) + return (sink: sink, subscription: subscription) + } + +#if TRACE_RESOURCES + deinit { + let _ = AtomicDecrement(&resourceCount) + } +#endif +} + +enum ObserveOnState : Int32 { + // pump is not running + case stopped = 0 + // pump is running + case running = 1 +} + +class ObserveOnSink : ObserverBase { + typealias E = O.E + + let _scheduler: ImmediateSchedulerType + + var _lock = SpinLock() + let _observer: O? + + // state + var _state = ObserveOnState.stopped + var _queue = Queue>(capacity: 10) + + let _scheduleDisposable = SerialDisposable() + let _cancel: Cancelable + + init(scheduler: ImmediateSchedulerType, observer: O, cancel: Cancelable) { + _scheduler = scheduler + _observer = observer + _cancel = cancel + } + + override func onCore(_ event: Event) { + let shouldStart = _lock.calculateLocked { () -> Bool in + self._queue.enqueue(event) + + switch self._state { + case .stopped: + self._state = .running + return true + case .running: + return false + } + } + + if shouldStart { + _scheduleDisposable.disposable = self._scheduler.scheduleRecursive((), action: self.run) + } + } + + func run(_ state: Void, recurse: (Void) -> Void) { + let (nextEvent, observer) = self._lock.calculateLocked { () -> (Event?, O?) in + if self._queue.count > 0 { + return (self._queue.dequeue(), self._observer) + } + else { + self._state = .stopped + return (nil, self._observer) + } + } + + if let nextEvent = nextEvent, !_cancel.isDisposed { + observer?.on(nextEvent) + if nextEvent.isStopEvent { + dispose() + } + } + else { + return + } + + let shouldContinue = _shouldContinue_synchronized() + + if shouldContinue { + recurse() + } + } + + func _shouldContinue_synchronized() -> Bool { + _lock.lock(); defer { _lock.unlock() } // { + if self._queue.count > 0 { + return true + } + else { + self._state = .stopped + return false + } + // } + } + + override func dispose() { + super.dispose() + + _cancel.dispose() + _scheduleDisposable.dispose() + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift new file mode 100644 index 0000000..fdc444d --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift @@ -0,0 +1,82 @@ +// +// ObserveOnSerialDispatchQueue.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/31/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if TRACE_RESOURCES +/** +Counts number of `SerialDispatchQueueObservables`. + +Purposed for unit tests. +*/ +public var numberOfSerialDispatchQueueObservables: AtomicInt = 0 +#endif + +class ObserveOnSerialDispatchQueueSink : ObserverBase { + let scheduler: SerialDispatchQueueScheduler + let observer: O + + let cancel: Cancelable + + var cachedScheduleLambda: ((ObserveOnSerialDispatchQueueSink, Event) -> Disposable)! + + init(scheduler: SerialDispatchQueueScheduler, observer: O, cancel: Cancelable) { + self.scheduler = scheduler + self.observer = observer + self.cancel = cancel + super.init() + + cachedScheduleLambda = { sink, event in + sink.observer.on(event) + + if event.isStopEvent { + sink.dispose() + } + + return Disposables.create() + } + } + + override func onCore(_ event: Event) { + let _ = self.scheduler.schedule((self, event), action: cachedScheduleLambda) + } + + override func dispose() { + super.dispose() + + cancel.dispose() + } +} + +class ObserveOnSerialDispatchQueue : Producer { + let scheduler: SerialDispatchQueueScheduler + let source: Observable + + init(source: Observable, scheduler: SerialDispatchQueueScheduler) { + self.scheduler = scheduler + self.source = source + +#if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) + let _ = AtomicIncrement(&numberOfSerialDispatchQueueObservables) +#endif + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { + let sink = ObserveOnSerialDispatchQueueSink(scheduler: scheduler, observer: observer, cancel: cancel) + let subscription = source.subscribe(sink) + return (sink: sink, subscription: subscription) + } + +#if TRACE_RESOURCES + deinit { + let _ = AtomicDecrement(&resourceCount) + let _ = AtomicDecrement(&numberOfSerialDispatchQueueObservables) + } +#endif +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift new file mode 100644 index 0000000..3dd7e6c --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift @@ -0,0 +1,99 @@ +// +// Producer.swift +// Rx +// +// Created by Krunoslav Zaher on 2/20/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Producer : Observable { + override init() { + super.init() + } + + override func subscribe(_ observer: O) -> Disposable where O.E == Element { + if !CurrentThreadScheduler.isScheduleRequired { + // The returned disposable needs to release all references once it was disposed. + let disposer = SinkDisposer() + let sinkAndSubscription = run(observer, cancel: disposer) + disposer.setSinkAndSubscription(sink: sinkAndSubscription.sink, subscription: sinkAndSubscription.subscription) + + return disposer + } + else { + return CurrentThreadScheduler.instance.schedule(()) { _ in + let disposer = SinkDisposer() + let sinkAndSubscription = self.run(observer, cancel: disposer) + disposer.setSinkAndSubscription(sink: sinkAndSubscription.sink, subscription: sinkAndSubscription.subscription) + + return disposer + } + } + } + + func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + abstractMethod() + } +} + +fileprivate class SinkDisposer: Cancelable { + fileprivate enum DisposeState: UInt32 { + case disposed = 1 + case sinkAndSubscriptionSet = 2 + } + + // Jeej, swift API consistency rules + fileprivate enum DisposeStateInt32: Int32 { + case disposed = 1 + case sinkAndSubscriptionSet = 2 + } + + private var _state: UInt32 = 0 + private var _sink: Disposable? = nil + private var _subscription: Disposable? = nil + + var isDisposed: Bool { + return (_state & DisposeState.disposed.rawValue) != 0 + } + + func setSinkAndSubscription(sink: Disposable, subscription: Disposable) { + _sink = sink + _subscription = subscription + + let previousState = OSAtomicOr32OrigBarrier(DisposeState.sinkAndSubscriptionSet.rawValue, &_state) + if (previousState & DisposeStateInt32.sinkAndSubscriptionSet.rawValue) != 0 { + rxFatalError("Sink and subscription were already set") + } + + if (previousState & DisposeStateInt32.disposed.rawValue) != 0 { + sink.dispose() + subscription.dispose() + _sink = nil + _subscription = nil + } + } + + func dispose() { + let previousState = OSAtomicOr32OrigBarrier(DisposeState.disposed.rawValue, &_state) + if (previousState & DisposeStateInt32.disposed.rawValue) != 0 { + return + } + + if (previousState & DisposeStateInt32.sinkAndSubscriptionSet.rawValue) != 0 { + guard let sink = _sink else { + rxFatalError("Sink not set") + } + guard let subscription = _subscription else { + rxFatalError("Subscription not set") + } + + sink.dispose() + subscription.dispose() + + _sink = nil + _subscription = nil + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift new file mode 100644 index 0000000..dbdb50e --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift @@ -0,0 +1,59 @@ +// +// Range.swift +// Rx +// +// Created by Krunoslav Zaher on 9/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class RangeProducer : Producer { + fileprivate let _start: E + fileprivate let _count: E + fileprivate let _scheduler: ImmediateSchedulerType + + init(start: E, count: E, scheduler: ImmediateSchedulerType) { + if count < 0 { + rxFatalError("count can't be negative") + } + + if start &+ (count - 1) < start { + rxFatalError("overflow of count") + } + + _start = start + _count = count + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { + let sink = RangeSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + +class RangeSink : Sink where O.E: SignedInteger { + typealias Parent = RangeProducer + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRecursive(0 as O.E) { i, recurse in + if i < self._parent._count { + self.forwardOn(.next(self._parent._start + i)) + recurse(i + 1) + } + else { + self.forwardOn(.completed) + self.dispose() + } + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift new file mode 100644 index 0000000..2b098d9 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift @@ -0,0 +1,74 @@ +// +// Reduce.swift +// Rx +// +// Created by Krunoslav Zaher on 4/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ReduceSink : Sink, ObserverType { + typealias ResultType = O.E + typealias Parent = Reduce + + private let _parent: Parent + private var _accumulation: AccumulateType + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _accumulation = parent._seed + + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + do { + _accumulation = try _parent._accumulator(_accumulation, value) + } + catch let e { + forwardOn(.error(e)) + dispose() + } + case .error(let e): + forwardOn(.error(e)) + dispose() + case .completed: + do { + let result = try _parent._mapResult(_accumulation) + forwardOn(.next(result)) + forwardOn(.completed) + dispose() + } + catch let e { + forwardOn(.error(e)) + dispose() + } + } + } +} + +class Reduce : Producer { + typealias AccumulatorType = (AccumulateType, SourceType) throws -> AccumulateType + typealias ResultSelectorType = (AccumulateType) throws -> ResultType + + fileprivate let _source: Observable + fileprivate let _seed: AccumulateType + fileprivate let _accumulator: AccumulatorType + fileprivate let _mapResult: ResultSelectorType + + init(source: Observable, seed: AccumulateType, accumulator: @escaping AccumulatorType, mapResult: @escaping ResultSelectorType) { + _source = source + _seed = seed + _accumulator = accumulator + _mapResult = mapResult + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == ResultType { + let sink = ReduceSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift new file mode 100644 index 0000000..64fcb7a --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift @@ -0,0 +1,84 @@ +// +// RefCount.swift +// Rx +// +// Created by Krunoslav Zaher on 3/5/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class RefCountSink + : Sink + , ObserverType where CO.E == O.E { + typealias Element = O.E + typealias Parent = RefCount + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription = _parent._source.subscribeSafe(self) + + _parent._lock.lock(); defer { _parent._lock.unlock() } // { + if _parent._count == 0 { + _parent._count = 1 + _parent._connectableSubscription = _parent._source.connect() + } + else { + _parent._count = _parent._count + 1 + } + // } + + return Disposables.create { + subscription.dispose() + self._parent._lock.lock(); defer { self._parent._lock.unlock() } // { + if self._parent._count == 1 { + self._parent._connectableSubscription!.dispose() + self._parent._count = 0 + self._parent._connectableSubscription = nil + } + else if self._parent._count > 1 { + self._parent._count = self._parent._count - 1 + } + else { + rxFatalError("Something went wrong with RefCount disposing mechanism") + } + // } + } + } + + func on(_ event: Event) { + switch event { + case .next: + forwardOn(event) + case .error, .completed: + forwardOn(event) + dispose() + } + } +} + +class RefCount: Producer { + fileprivate let _lock = NSRecursiveLock() + + // state + fileprivate var _count = 0 + fileprivate var _connectableSubscription = nil as Disposable? + + fileprivate let _source: CO + + init(source: CO) { + _source = source + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == CO.E { + let sink = RefCountSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift new file mode 100644 index 0000000..a5d29d8 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift @@ -0,0 +1,44 @@ +// +// Repeat.swift +// RxExample +// +// Created by Krunoslav Zaher on 9/13/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class RepeatElement : Producer { + fileprivate let _element: Element + fileprivate let _scheduler: ImmediateSchedulerType + + init(element: Element, scheduler: ImmediateSchedulerType) { + _element = element + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = RepeatElementSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + + return (sink: sink, subscription: subscription) + } +} + +class RepeatElementSink : Sink { + typealias Parent = RepeatElement + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRecursive(_parent._element) { e, recurse in + self.forwardOn(.next(e)) + recurse(e) + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift new file mode 100644 index 0000000..dec9f50 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/RetryWhen.swift @@ -0,0 +1,150 @@ +// +// RetryWhen.swift +// Rx +// +// Created by Junior B. on 06/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class RetryTriggerSink + : ObserverType where S.Iterator.Element : ObservableType, S.Iterator.Element.E == O.E { + typealias E = TriggerObservable.E + + typealias Parent = RetryWhenSequenceSinkIter + + fileprivate let _parent: Parent + + init(parent: Parent) { + _parent = parent + } + + func on(_ event: Event) { + switch event { + case .next: + _parent._parent._lastError = nil + _parent._parent.schedule(.moveNext) + case .error(let e): + _parent._parent.forwardOn(.error(e)) + _parent._parent.dispose() + case .completed: + _parent._parent.forwardOn(.completed) + _parent._parent.dispose() + } + } +} + +class RetryWhenSequenceSinkIter + : SingleAssignmentDisposable + , ObserverType where S.Iterator.Element : ObservableType, S.Iterator.Element.E == O.E { + typealias E = O.E + typealias Parent = RetryWhenSequenceSink + + fileprivate let _parent: Parent + fileprivate let _errorHandlerSubscription = SingleAssignmentDisposable() + + init(parent: Parent) { + _parent = parent + } + + func on(_ event: Event) { + switch event { + case .next: + _parent.forwardOn(event) + case .error(let error): + _parent._lastError = error + + if let failedWith = error as? Error { + // dispose current subscription + super.dispose() + + let errorHandlerSubscription = _parent._notifier.subscribe(RetryTriggerSink(parent: self)) + _errorHandlerSubscription.setDisposable(errorHandlerSubscription) + _parent._errorSubject.on(.next(failedWith)) + } + else { + _parent.forwardOn(.error(error)) + _parent.dispose() + } + case .completed: + _parent.forwardOn(event) + _parent.dispose() + } + } + + override func dispose() { + super.dispose() + _errorHandlerSubscription.dispose() + } +} + +class RetryWhenSequenceSink + : TailRecursiveSink where S.Iterator.Element : ObservableType, S.Iterator.Element.E == O.E { + typealias Element = O.E + typealias Parent = RetryWhenSequence + + let _lock = NSRecursiveLock() + + fileprivate let _parent: Parent + + fileprivate var _lastError: Swift.Error? + fileprivate let _errorSubject = PublishSubject() + fileprivate let _handler: Observable + fileprivate let _notifier = PublishSubject() + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _handler = parent._notificationHandler(_errorSubject).asObservable() + super.init(observer: observer, cancel: cancel) + } + + override func done() { + if let lastError = _lastError { + forwardOn(.error(lastError)) + _lastError = nil + } + else { + forwardOn(.completed) + } + + dispose() + } + + override func extract(_ observable: Observable) -> SequenceGenerator? { + // It is important to always return `nil` here because there are sideffects in the `run` method + // that are dependant on particular `retryWhen` operator so single operator stack can't be reused in this + // case. + return nil + } + + override func subscribeToNext(_ source: Observable) -> Disposable { + let iter = RetryWhenSequenceSinkIter(parent: self) + iter.setDisposable(source.subscribe(iter)) + return iter + } + + override func run(_ sources: SequenceGenerator) -> Disposable { + let triggerSubscription = _handler.subscribe(_notifier.asObserver()) + let superSubscription = super.run(sources) + return Disposables.create(superSubscription, triggerSubscription) + } +} + +class RetryWhenSequence : Producer where S.Iterator.Element : ObservableType { + typealias Element = S.Iterator.Element.E + + fileprivate let _sources: S + fileprivate let _notificationHandler: (Observable) -> TriggerObservable + + init(sources: S, notificationHandler: @escaping (Observable) -> TriggerObservable) { + _sources = sources + _notificationHandler = notificationHandler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = RetryWhenSequenceSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run((self._sources.makeIterator(), nil)) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift new file mode 100644 index 0000000..7190bfb --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Sample.swift @@ -0,0 +1,129 @@ +// +// Sample.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SamplerSink + : ObserverType + , LockOwnerType + , SynchronizedOnType where O.E == ElementType { + typealias E = SampleType + + typealias Parent = SampleSequenceSink + + fileprivate let _parent: Parent + + var _lock: NSRecursiveLock { + return _parent._lock + } + + init(parent: Parent) { + _parent = parent + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next: + if let element = _parent._element { + if _parent._parent._onlyNew { + _parent._element = nil + } + + _parent.forwardOn(.next(element)) + } + + if _parent._atEnd { + _parent.forwardOn(.completed) + _parent.dispose() + } + case .error(let e): + _parent.forwardOn(.error(e)) + _parent.dispose() + case .completed: + if let element = _parent._element { + _parent._element = nil + _parent.forwardOn(.next(element)) + } + if _parent._atEnd { + _parent.forwardOn(.completed) + _parent.dispose() + } + } + } +} + +class SampleSequenceSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Element = O.E + typealias Parent = Sample + + fileprivate let _parent: Parent + + let _lock = NSRecursiveLock() + + // state + fileprivate var _element = nil as Element? + fileprivate var _atEnd = false + + fileprivate let _sourceSubscription = SingleAssignmentDisposable() + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + _sourceSubscription.setDisposable(_parent._source.subscribe(self)) + let samplerSubscription = _parent._sampler.subscribe(SamplerSink(parent: self)) + + return Disposables.create(_sourceSubscription, samplerSubscription) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let element): + _element = element + case .error: + forwardOn(event) + dispose() + case .completed: + _atEnd = true + _sourceSubscription.dispose() + } + } + +} + +class Sample : Producer { + fileprivate let _source: Observable + fileprivate let _sampler: Observable + fileprivate let _onlyNew: Bool + + init(source: Observable, sampler: Observable, onlyNew: Bool) { + _source = source + _sampler = sampler + _onlyNew = onlyNew + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = SampleSequenceSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift new file mode 100644 index 0000000..dbb9173 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift @@ -0,0 +1,64 @@ +// +// Scan.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ScanSink : Sink, ObserverType where O.E == Accumulate { + typealias Parent = Scan + typealias E = ElementType + + fileprivate let _parent: Parent + fileprivate var _accumulate: Accumulate + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _accumulate = parent._seed + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let element): + do { + _accumulate = try _parent._accumulator(_accumulate, element) + forwardOn(.next(_accumulate)) + } + catch let error { + forwardOn(.error(error)) + dispose() + } + case .error(let error): + forwardOn(.error(error)) + dispose() + case .completed: + forwardOn(.completed) + dispose() + } + } + +} + +class Scan: Producer { + typealias Accumulator = (Accumulate, Element) throws -> Accumulate + + fileprivate let _source: Observable + fileprivate let _seed: Accumulate + fileprivate let _accumulator: Accumulator + + init(source: Observable, seed: Accumulate, accumulator: @escaping Accumulator) { + _source = source + _seed = seed + _accumulator = accumulator + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Accumulate { + let sink = ScanSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift new file mode 100644 index 0000000..78cbc29 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift @@ -0,0 +1,49 @@ +// +// Sequence.swift +// Rx +// +// Created by Krunoslav Zaher on 11/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ObservableSequenceSink : Sink where S.Iterator.Element == O.E { + typealias Parent = ObservableSequence + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRecursive((_parent._elements.makeIterator(), _parent._elements)) { (iterator, recurse) in + var mutableIterator = iterator + if let next = mutableIterator.0.next() { + self.forwardOn(.next(next)) + recurse(mutableIterator) + } + else { + self.forwardOn(.completed) + } + } + } +} + +class ObservableSequence : Producer { + fileprivate let _elements: S + fileprivate let _scheduler: ImmediateSchedulerType + + init(elements: S, scheduler: ImmediateSchedulerType) { + _elements = elements + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { + let sink = ObservableSequenceSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift new file mode 100644 index 0000000..2f78cce --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift @@ -0,0 +1,101 @@ +// +// ShareReplay1.swift +// Rx +// +// Created by Krunoslav Zaher on 10/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// optimized version of share replay for most common case +final class ShareReplay1 + : Observable + , ObserverType + , SynchronizedUnsubscribeType { + + typealias DisposeKey = Bag>.KeyType + + private let _source: Observable + + private var _lock = NSRecursiveLock() + + private var _connection: SingleAssignmentDisposable? + private var _element: Element? + private var _stopped = false + private var _stopEvent = nil as Event? + private var _observers = Bag>() + + init(source: Observable) { + self._source = source + } + + override func subscribe(_ observer: O) -> Disposable where O.E == E { + _lock.lock(); defer { _lock.unlock() } + return _synchronized_subscribe(observer) + } + + func _synchronized_subscribe(_ observer: O) -> Disposable where O.E == E { + if let element = self._element { + observer.on(.next(element)) + } + + if let stopEvent = self._stopEvent { + observer.on(stopEvent) + return Disposables.create() + } + + let initialCount = self._observers.count + + let disposeKey = self._observers.insert(AnyObserver(observer)) + + if initialCount == 0 { + let connection = SingleAssignmentDisposable() + _connection = connection + + connection.setDisposable(self._source.subscribe(self)) + } + + return SubscriptionDisposable(owner: self, key: disposeKey) + } + + func synchronizedUnsubscribe(_ disposeKey: DisposeKey) { + _lock.lock(); defer { _lock.unlock() } + _synchronized_unsubscribe(disposeKey) + } + + func _synchronized_unsubscribe(_ disposeKey: DisposeKey) { + // if already unsubscribed, just return + if self._observers.removeKey(disposeKey) == nil { + return + } + + if _observers.count == 0 { + _connection?.dispose() + _connection = nil + } + } + + func on(_ event: Event) { + _lock.lock(); defer { _lock.unlock() } + _synchronized_on(event) + } + + func _synchronized_on(_ event: Event) { + if _stopped { + return + } + + switch event { + case .next(let element): + _element = element + case .error, .completed: + _stopEvent = event + _stopped = true + _connection?.dispose() + _connection = nil + } + + _observers.on(event) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift new file mode 100644 index 0000000..ae4dc43 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift @@ -0,0 +1,92 @@ +// +// ShareReplay1WhileConnected.swift +// Rx +// +// Created by Krunoslav Zaher on 12/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// optimized version of share replay for most common case +final class ShareReplay1WhileConnected + : Observable + , ObserverType + , SynchronizedUnsubscribeType { + + typealias DisposeKey = Bag>.KeyType + + private let _source: Observable + + private var _lock = NSRecursiveLock() + + private var _connection: SingleAssignmentDisposable? + private var _element: Element? + private var _observers = Bag>() + + init(source: Observable) { + self._source = source + } + + override func subscribe(_ observer: O) -> Disposable where O.E == E { + _lock.lock(); defer { _lock.unlock() } + return _synchronized_subscribe(observer) + } + + func _synchronized_subscribe(_ observer: O) -> Disposable where O.E == E { + if let element = self._element { + observer.on(.next(element)) + } + + let initialCount = self._observers.count + + let disposeKey = self._observers.insert(AnyObserver(observer)) + + if initialCount == 0 { + let connection = SingleAssignmentDisposable() + _connection = connection + + connection.setDisposable(self._source.subscribe(self)) + } + + return SubscriptionDisposable(owner: self, key: disposeKey) + } + + func synchronizedUnsubscribe(_ disposeKey: DisposeKey) { + _lock.lock(); defer { _lock.unlock() } + _synchronized_unsubscribe(disposeKey) + } + + func _synchronized_unsubscribe(_ disposeKey: DisposeKey) { + // if already unsubscribed, just return + if self._observers.removeKey(disposeKey) == nil { + return + } + + if _observers.count == 0 { + _connection?.dispose() + _connection = nil + _element = nil + } + } + + func on(_ event: Event) { + _lock.lock(); defer { _lock.unlock() } + _synchronized_on(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let element): + _element = element + _observers.on(event) + case .error, .completed: + _element = nil + _connection?.dispose() + _connection = nil + let observers = _observers + _observers = Bag() + observers.on(event) + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift new file mode 100644 index 0000000..2e36f67 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift @@ -0,0 +1,76 @@ +// +// SingleAsync.swift +// Rx +// +// Created by Junior B. on 09/11/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SingleAsyncSink : Sink, ObserverType where O.E == ElementType { + typealias Parent = SingleAsync + typealias E = ElementType + + private let _parent: Parent + private var _seenValue: Bool = false + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + do { + let forward = try _parent._predicate?(value) ?? true + if !forward { + return + } + } + catch let error { + forwardOn(.error(error as Swift.Error)) + dispose() + return + } + + if _seenValue == false { + _seenValue = true + forwardOn(.next(value)) + } else { + forwardOn(.error(RxError.moreThanOneElement)) + dispose() + } + + case .error: + forwardOn(event) + dispose() + case .completed: + if (!_seenValue) { + forwardOn(.error(RxError.noElements)) + } else { + forwardOn(.completed) + } + dispose() + } + } +} + +class SingleAsync: Producer { + typealias Predicate = (Element) throws -> Bool + + fileprivate let _source: Observable + fileprivate let _predicate: Predicate? + + init(source: Observable, predicate: Predicate? = nil) { + _source = source + _predicate = predicate + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = SingleAsyncSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift new file mode 100644 index 0000000..33824af --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift @@ -0,0 +1,66 @@ +// +// Sink.swift +// Rx +// +// Created by Krunoslav Zaher on 2/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class Sink : Disposable { + fileprivate let _observer: O + fileprivate let _cancel: Cancelable + fileprivate var _disposed: Bool + + init(observer: O, cancel: Cancelable) { +#if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) +#endif + _observer = observer + _cancel = cancel + _disposed = false + } + + final func forwardOn(_ event: Event) { + if _disposed { + return + } + _observer.on(event) + } + + final func forwarder() -> SinkForward { + return SinkForward(forward: self) + } + + func dispose() { + _disposed = true + _cancel.dispose() + } + + deinit { +#if TRACE_RESOURCES + let _ = AtomicDecrement(&resourceCount) +#endif + } +} + +class SinkForward: ObserverType { + typealias E = O.E + + private let _forward: Sink + + init(forward: Sink) { + _forward = forward + } + + func on(_ event: Event) { + switch event { + case .next: + _forward._observer.on(event) + case .error, .completed: + _forward._observer.on(event) + _forward._cancel.dispose() + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift new file mode 100644 index 0000000..95252c4 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Skip.swift @@ -0,0 +1,128 @@ +// +// Skip.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/25/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// count version + +class SkipCountSink : Sink, ObserverType where O.E == ElementType { + typealias Parent = SkipCount + typealias Element = ElementType + + let parent: Parent + + var remaining: Int + + init(parent: Parent, observer: O, cancel: Cancelable) { + self.parent = parent + self.remaining = parent.count + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + + if remaining <= 0 { + forwardOn(.next(value)) + } + else { + remaining -= 1 + } + case .error: + forwardOn(event) + self.dispose() + case .completed: + forwardOn(event) + self.dispose() + } + } + +} + +class SkipCount: Producer { + let source: Observable + let count: Int + + init(source: Observable, count: Int) { + self.source = source + self.count = count + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = SkipCountSink(parent: self, observer: observer, cancel: cancel) + let subscription = source.subscribe(sink) + + return (sink: sink, subscription: subscription) + } +} + +// time version + +class SkipTimeSink : Sink, ObserverType where O.E == ElementType { + typealias Parent = SkipTime + typealias Element = ElementType + + let parent: Parent + + // state + var open = false + + init(parent: Parent, observer: O, cancel: Cancelable) { + self.parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + if open { + forwardOn(.next(value)) + } + case .error: + forwardOn(event) + self.dispose() + case .completed: + forwardOn(event) + self.dispose() + } + } + + func tick() { + open = true + } + + func run() -> Disposable { + let disposeTimer = parent.scheduler.scheduleRelative((), dueTime: self.parent.duration) { + self.tick() + return Disposables.create() + } + + let disposeSubscription = parent.source.subscribe(self) + + return Disposables.create(disposeTimer, disposeSubscription) + } +} + +class SkipTime: Producer { + let source: Observable + let duration: RxTimeInterval + let scheduler: SchedulerType + + init(source: Observable, duration: RxTimeInterval, scheduler: SchedulerType) { + self.source = source + self.scheduler = scheduler + self.duration = duration + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = SkipTimeSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift new file mode 100644 index 0000000..baebf1f --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/SkipUntil.swift @@ -0,0 +1,125 @@ +// +// SkipUntil.swift +// Rx +// +// Created by Yury Korolev on 10/3/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SkipUntilSinkOther + : ObserverType + , LockOwnerType + , SynchronizedOnType where O.E == ElementType { + typealias Parent = SkipUntilSink + typealias E = Other + + fileprivate let _parent: Parent + + var _lock: NSRecursiveLock { + return _parent._lock + } + + let _subscription = SingleAssignmentDisposable() + + init(parent: Parent) { + _parent = parent + #if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) + #endif + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next: + _parent._forwardElements = true + _subscription.dispose() + case .error(let e): + _parent.forwardOn(.error(e)) + _parent.dispose() + case .completed: + _subscription.dispose() + } + } + + #if TRACE_RESOURCES + deinit { + let _ = AtomicDecrement(&resourceCount) + } + #endif + +} + + +class SkipUntilSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType where O.E == ElementType { + typealias E = ElementType + typealias Parent = SkipUntil + + let _lock = NSRecursiveLock() + fileprivate let _parent: Parent + fileprivate var _forwardElements = false + + fileprivate let _sourceSubscription = SingleAssignmentDisposable() + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next: + if _forwardElements { + forwardOn(event) + } + case .error: + forwardOn(event) + dispose() + case .completed: + if _forwardElements { + forwardOn(event) + } + _sourceSubscription.dispose() + } + } + + func run() -> Disposable { + let sourceSubscription = _parent._source.subscribe(self) + let otherObserver = SkipUntilSinkOther(parent: self) + let otherSubscription = _parent._other.subscribe(otherObserver) + _sourceSubscription.setDisposable(sourceSubscription) + otherObserver._subscription.setDisposable(otherSubscription) + + return Disposables.create(_sourceSubscription, otherObserver._subscription) + } +} + +class SkipUntil: Producer { + + fileprivate let _source: Observable + fileprivate let _other: Observable + + init(source: Observable, other: Observable) { + _source = source + _other = other + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = SkipUntilSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift new file mode 100644 index 0000000..28e2fdc --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/SkipWhile.swift @@ -0,0 +1,115 @@ +// +// SkipWhile.swift +// Rx +// +// Created by Yury Korolev on 10/9/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +class SkipWhileSink : Sink, ObserverType where O.E == ElementType { + + typealias Parent = SkipWhile + typealias Element = ElementType + + fileprivate let _parent: Parent + fileprivate var _running = false + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + if !_running { + do { + _running = try !_parent._predicate(value) + } catch let e { + forwardOn(.error(e)) + dispose() + return + } + } + + if _running { + forwardOn(.next(value)) + } + case .error, .completed: + forwardOn(event) + dispose() + } + } +} + +class SkipWhileSinkWithIndex : Sink, ObserverType where O.E == ElementType { + + typealias Parent = SkipWhile + typealias Element = ElementType + + fileprivate let _parent: Parent + fileprivate var _index = 0 + fileprivate var _running = false + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + if !_running { + do { + _running = try !_parent._predicateWithIndex(value, _index) + let _ = try incrementChecked(&_index) + } catch let e { + forwardOn(.error(e)) + dispose() + return + } + } + + if _running { + forwardOn(.next(value)) + } + case .error, .completed: + forwardOn(event) + dispose() + } + } +} + +class SkipWhile: Producer { + typealias Predicate = (Element) throws -> Bool + typealias PredicateWithIndex = (Element, Int) throws -> Bool + + fileprivate let _source: Observable + fileprivate let _predicate: Predicate! + fileprivate let _predicateWithIndex: PredicateWithIndex! + + init(source: Observable, predicate: @escaping Predicate) { + _source = source + _predicate = predicate + _predicateWithIndex = nil + } + + init(source: Observable, predicate: @escaping PredicateWithIndex) { + _source = source + _predicate = nil + _predicateWithIndex = predicate + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + if let _ = _predicate { + let sink = SkipWhileSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } + else { + let sink = SkipWhileSinkWithIndex(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift new file mode 100644 index 0000000..ec0f662 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift @@ -0,0 +1,28 @@ +// +// StartWith.swift +// RxCocoa +// +// Created by Krunoslav Zaher on 4/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class StartWith: Producer { + let elements: [Element] + let source: Observable + + init(source: Observable, elements: [Element]) { + self.source = source + self.elements = elements + super.init() + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + for e in elements { + observer.on(.next(e)) + } + + return (sink: Disposables.create(), subscription: source.subscribe(observer)) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift new file mode 100644 index 0000000..b2f871c --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift @@ -0,0 +1,62 @@ +// +// SubscribeOn.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SubscribeOnSink : Sink, ObserverType where Ob.E == O.E { + typealias Element = O.E + typealias Parent = SubscribeOn + + let parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + self.parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + forwardOn(event) + + if event.isStopEvent { + self.dispose() + } + } + + func run() -> Disposable { + let disposeEverything = SerialDisposable() + let cancelSchedule = SingleAssignmentDisposable() + + disposeEverything.disposable = cancelSchedule + + let disposeSchedule = parent.scheduler.schedule(()) { (_) -> Disposable in + let subscription = self.parent.source.subscribe(self) + disposeEverything.disposable = ScheduledDisposable(scheduler: self.parent.scheduler, disposable: subscription) + return Disposables.create() + } + + cancelSchedule.setDisposable(disposeSchedule) + + return disposeEverything + } +} + +class SubscribeOn : Producer { + let source: Ob + let scheduler: ImmediateSchedulerType + + init(source: Ob, scheduler: ImmediateSchedulerType) { + self.source = source + self.scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Ob.E { + let sink = SubscribeOnSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift new file mode 100644 index 0000000..32f0dae --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Switch.swift @@ -0,0 +1,193 @@ +// +// Switch.swift +// Rx +// +// Created by Krunoslav Zaher on 3/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class SwitchSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType where S.E == O.E { + typealias E = SourceType + + fileprivate let _subscriptions: SingleAssignmentDisposable = SingleAssignmentDisposable() + fileprivate let _innerSubscription: SerialDisposable = SerialDisposable() + + let _lock = NSRecursiveLock() + + // state + fileprivate var _stopped = false + fileprivate var _latest = 0 + fileprivate var _hasLatest = false + + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + func run(_ source: Observable) -> Disposable { + let subscription = source.subscribe(self) + _subscriptions.setDisposable(subscription) + return Disposables.create(_subscriptions, _innerSubscription) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func performMap(_ element: SourceType) throws -> S { + abstractMethod() + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let element): + do { + let observable = try performMap(element).asObservable() + _hasLatest = true + _latest = _latest &+ 1 + let latest = _latest + + let d = SingleAssignmentDisposable() + _innerSubscription.disposable = d + + let observer = SwitchSinkIter(parent: self, id: latest, _self: d) + let disposable = observable.subscribe(observer) + d.setDisposable(disposable) + } + catch let error { + forwardOn(.error(error)) + dispose() + } + case .error(let error): + forwardOn(.error(error)) + dispose() + case .completed: + _stopped = true + + _subscriptions.dispose() + + if !_hasLatest { + forwardOn(.completed) + dispose() + } + } + } +} + +class SwitchSinkIter + : ObserverType + , LockOwnerType + , SynchronizedOnType where S.E == O.E { + typealias E = S.E + typealias Parent = SwitchSink + + fileprivate let _parent: Parent + fileprivate let _id: Int + fileprivate let _self: Disposable + + var _lock: NSRecursiveLock { + return _parent._lock + } + + init(parent: Parent, id: Int, _self: Disposable) { + _parent = parent + _id = id + self._self = _self + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next: break + case .error, .completed: + _self.dispose() + } + + if _parent._latest != _id { + return + } + + switch event { + case .next: + _parent.forwardOn(event) + case .error: + _parent.forwardOn(event) + _parent.dispose() + case .completed: + _parent._hasLatest = false + if _parent._stopped { + _parent.forwardOn(event) + _parent.dispose() + } + } + } +} + +// MARK: Specializations + +final class SwitchIdentitySink : SwitchSink where O.E == S.E { + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + override func performMap(_ element: S) throws -> S { + return element + } +} + +final class MapSwitchSink : SwitchSink where O.E == S.E { + typealias Selector = (SourceType) throws -> S + + fileprivate let _selector: Selector + + init(selector: @escaping Selector, observer: O, cancel: Cancelable) { + _selector = selector + super.init(observer: observer, cancel: cancel) + } + + override func performMap(_ element: SourceType) throws -> S { + return try _selector(element) + } +} + +// MARK: Producers + +final class Switch : Producer { + fileprivate let _source: Observable + + init(source: Observable) { + _source = source + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { + let sink = SwitchIdentitySink(observer: observer, cancel: cancel) + let subscription = sink.run(_source) + return (sink: sink, subscription: subscription) + } +} + +final class FlatMapLatest : Producer { + typealias Selector = (SourceType) throws -> S + + fileprivate let _source: Observable + fileprivate let _selector: Selector + + init(source: Observable, selector: @escaping Selector) { + _source = source + _selector = selector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == S.E { + let sink = MapSwitchSink(selector: _selector, observer: observer, cancel: cancel) + let subscription = sink.run(_source) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift new file mode 100644 index 0000000..d1c1e18 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Take.swift @@ -0,0 +1,144 @@ +// +// Take.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// count version + +class TakeCountSink : Sink, ObserverType where O.E == ElementType { + typealias Parent = TakeCount + typealias E = ElementType + + private let _parent: Parent + + private var _remaining: Int + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _remaining = parent._count + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + + if _remaining > 0 { + _remaining -= 1 + + forwardOn(.next(value)) + + if _remaining == 0 { + forwardOn(.completed) + dispose() + } + } + case .error: + forwardOn(event) + dispose() + case .completed: + forwardOn(event) + dispose() + } + } + +} + +class TakeCount: Producer { + fileprivate let _source: Observable + fileprivate let _count: Int + + init(source: Observable, count: Int) { + if count < 0 { + rxFatalError("count can't be negative") + } + _source = source + _count = count + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = TakeCountSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} + +// time version + +class TakeTimeSink + : Sink + , LockOwnerType + , ObserverType + , SynchronizedOnType where O.E == ElementType { + typealias Parent = TakeTime + typealias E = ElementType + + fileprivate let _parent: Parent + + let _lock = NSRecursiveLock() + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let value): + forwardOn(.next(value)) + case .error: + forwardOn(event) + dispose() + case .completed: + forwardOn(event) + dispose() + } + } + + func tick() { + _lock.lock(); defer { _lock.unlock() } + + forwardOn(.completed) + dispose() + } + + func run() -> Disposable { + let disposeTimer = _parent._scheduler.scheduleRelative((), dueTime: _parent._duration) { + self.tick() + return Disposables.create() + } + + let disposeSubscription = _parent._source.subscribe(self) + + return Disposables.create(disposeTimer, disposeSubscription) + } +} + +class TakeTime : Producer { + typealias TimeInterval = RxTimeInterval + + fileprivate let _source: Observable + fileprivate let _duration: TimeInterval + fileprivate let _scheduler: SchedulerType + + init(source: Observable, duration: TimeInterval, scheduler: SchedulerType) { + _source = source + _scheduler = scheduler + _duration = duration + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = TakeTimeSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift new file mode 100644 index 0000000..76796be --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift @@ -0,0 +1,63 @@ +// +// TakeLast.swift +// Rx +// +// Created by Tomi Koskinen on 25/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + +class TakeLastSink : Sink, ObserverType where O.E == ElementType { + typealias Parent = TakeLast + typealias E = ElementType + + private let _parent: Parent + + private var _elements: Queue + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _elements = Queue(capacity: parent._count + 1) + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + _elements.enqueue(value) + if _elements.count > self._parent._count { + let _ = _elements.dequeue() + } + case .error: + forwardOn(event) + dispose() + case .completed: + for e in _elements { + forwardOn(.next(e)) + } + forwardOn(.completed) + dispose() + } + } +} + +class TakeLast: Producer { + fileprivate let _source: Observable + fileprivate let _count: Int + + init(source: Observable, count: Int) { + if count < 0 { + rxFatalError("count can't be negative") + } + _source = source + _count = count + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = TakeLastSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift new file mode 100644 index 0000000..83452b8 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/TakeUntil.swift @@ -0,0 +1,120 @@ +// +// TakeUntil.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class TakeUntilSinkOther + : ObserverType + , LockOwnerType + , SynchronizedOnType where O.E == ElementType { + typealias Parent = TakeUntilSink + typealias E = Other + + fileprivate let _parent: Parent + + var _lock: NSRecursiveLock { + return _parent._lock + } + + fileprivate let _subscription = SingleAssignmentDisposable() + + init(parent: Parent) { + _parent = parent +#if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) +#endif + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next: + _parent.forwardOn(.completed) + _parent.dispose() + case .error(let e): + _parent.forwardOn(.error(e)) + _parent.dispose() + case .completed: + _parent._open = true + _subscription.dispose() + } + } + +#if TRACE_RESOURCES + deinit { + let _ = AtomicDecrement(&resourceCount) + } +#endif +} + +class TakeUntilSink + : Sink + , LockOwnerType + , ObserverType + , SynchronizedOnType where O.E == ElementType { + typealias E = ElementType + typealias Parent = TakeUntil + + fileprivate let _parent: Parent + + let _lock = NSRecursiveLock() + + // state + fileprivate var _open = false + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next: + forwardOn(event) + case .error: + forwardOn(event) + dispose() + case .completed: + forwardOn(event) + dispose() + } + } + + func run() -> Disposable { + let otherObserver = TakeUntilSinkOther(parent: self) + let otherSubscription = _parent._other.subscribe(otherObserver) + otherObserver._subscription.setDisposable(otherSubscription) + let sourceSubscription = _parent._source.subscribe(self) + + return Disposables.create(sourceSubscription, otherObserver._subscription) + } +} + +class TakeUntil: Producer { + + fileprivate let _source: Observable + fileprivate let _other: Observable + + init(source: Observable, other: Observable) { + _source = source + _other = other + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = TakeUntilSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift new file mode 100644 index 0000000..259bc25 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/TakeWhile.swift @@ -0,0 +1,132 @@ +// +// TakeWhile.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class TakeWhileSink + : Sink + , ObserverType where O.E == ElementType { + typealias Parent = TakeWhile + typealias Element = ElementType + + fileprivate let _parent: Parent + + fileprivate var _running = true + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + if !_running { + return + } + + do { + _running = try _parent._predicate(value) + } catch let e { + forwardOn(.error(e)) + dispose() + return + } + + if _running { + forwardOn(.next(value)) + } else { + forwardOn(.completed) + dispose() + } + case .error, .completed: + forwardOn(event) + dispose() + } + } + +} + +class TakeWhileSinkWithIndex + : Sink + , ObserverType where O.E == ElementType { + typealias Parent = TakeWhile + typealias Element = ElementType + + fileprivate let _parent: Parent + + fileprivate var _running = true + fileprivate var _index = 0 + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + if !_running { + return + } + + do { + _running = try _parent._predicateWithIndex(value, _index) + let _ = try incrementChecked(&_index) + } catch let e { + forwardOn(.error(e)) + dispose() + return + } + + if _running { + forwardOn(.next(value)) + } else { + forwardOn(.completed) + dispose() + } + case .error, .completed: + forwardOn(event) + dispose() + } + } + +} + +class TakeWhile: Producer { + typealias Predicate = (Element) throws -> Bool + typealias PredicateWithIndex = (Element, Int) throws -> Bool + + fileprivate let _source: Observable + fileprivate let _predicate: Predicate! + fileprivate let _predicateWithIndex: PredicateWithIndex! + + init(source: Observable, predicate: @escaping Predicate) { + _source = source + _predicate = predicate + _predicateWithIndex = nil + } + + init(source: Observable, predicate: @escaping PredicateWithIndex) { + _source = source + _predicate = nil + _predicateWithIndex = predicate + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + if let _ = _predicate { + let sink = TakeWhileSink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } else { + let sink = TakeWhileSinkWithIndex(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift new file mode 100644 index 0000000..4332dcb --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift @@ -0,0 +1,143 @@ +// +// Throttle.swift +// Rx +// +// Created by Krunoslav Zaher on 3/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ThrottleSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias Element = O.E + typealias ParentType = Throttle + + private let _parent: ParentType + + let _lock = NSRecursiveLock() + + // state + private var _lastUnsentElement: Element? = nil + private var _lastSentTime: Date? = nil + private var _completed: Bool = false + + let cancellable = SerialDisposable() + + init(parent: ParentType, observer: O, cancel: Cancelable) { + _parent = parent + + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let subscription = _parent._source.subscribe(self) + + return Disposables.create(subscription, cancellable) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case .next(let element): + let now = _parent._scheduler.now + + let timeIntervalSinceLast: RxTimeInterval + + if let lastSendingTime = _lastSentTime { + timeIntervalSinceLast = now.timeIntervalSince(lastSendingTime) + } + else { + timeIntervalSinceLast = _parent._dueTime + } + + let couldSendNow = timeIntervalSinceLast >= _parent._dueTime + + if couldSendNow { + self.sendNow(element: element) + return + } + + if !_parent._latest { + return + } + + let isThereAlreadyInFlightRequest = _lastUnsentElement != nil + + _lastUnsentElement = element + + if isThereAlreadyInFlightRequest { + return + } + + let scheduler = _parent._scheduler + let dueTime = _parent._dueTime + + let d = SingleAssignmentDisposable() + self.cancellable.disposable = d + + d.setDisposable(scheduler.scheduleRelative(0, dueTime: dueTime - timeIntervalSinceLast, action: self.propagate)) + case .error: + _lastUnsentElement = nil + forwardOn(event) + dispose() + case .completed: + if let _ = _lastUnsentElement { + _completed = true + } + else { + forwardOn(.completed) + dispose() + } + } + } + + private func sendNow(element: Element) { + _lastUnsentElement = nil + self.forwardOn(.next(element)) + // in case element processing takes a while, this should give some more room + _lastSentTime = _parent._scheduler.now + } + + func propagate(_: Int) -> Disposable { + _lock.lock(); defer { _lock.unlock() } // { + if let lastUnsentElement = _lastUnsentElement { + sendNow(element: lastUnsentElement) + } + + if _completed { + forwardOn(.completed) + dispose() + } + // } + return Disposables.create() + } +} + +class Throttle : Producer { + + fileprivate let _source: Observable + fileprivate let _dueTime: RxTimeInterval + fileprivate let _latest: Bool + fileprivate let _scheduler: SchedulerType + + init(source: Observable, dueTime: RxTimeInterval, latest: Bool, scheduler: SchedulerType) { + _source = source + _dueTime = dueTime + _latest = latest + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = ThrottleSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } + +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift new file mode 100644 index 0000000..edf2720 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Timeout.swift @@ -0,0 +1,122 @@ +// +// Timeout.swift +// Rx +// +// Created by Tomi Koskinen on 13/11/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class TimeoutSink: Sink, LockOwnerType, ObserverType where O.E == ElementType { + typealias E = ElementType + typealias Parent = Timeout + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + private let _timerD = SerialDisposable() + private let _subscription = SerialDisposable() + + private var _id = 0 + private var _switched = false + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let original = SingleAssignmentDisposable() + _subscription.disposable = original + + _createTimeoutTimer() + + original.setDisposable(_parent._source.subscribeSafe(self)) + + return Disposables.create(_subscription, _timerD) + } + + func on(_ event: Event) { + switch event { + case .next: + var onNextWins = false + + _lock.performLocked() { + onNextWins = !self._switched + if onNextWins { + self._id = self._id &+ 1 + } + } + + if onNextWins { + forwardOn(event) + self._createTimeoutTimer() + } + case .error, .completed: + var onEventWins = false + + _lock.performLocked() { + onEventWins = !self._switched + if onEventWins { + self._id = self._id &+ 1 + } + } + + if onEventWins { + forwardOn(event) + self.dispose() + } + } + } + + private func _createTimeoutTimer() { + if _timerD.isDisposed { + return + } + + let nextTimer = SingleAssignmentDisposable() + _timerD.disposable = nextTimer + + let disposeSchedule = _parent._scheduler.scheduleRelative(_id, dueTime: _parent._dueTime) { state in + + var timerWins = false + + self._lock.performLocked() { + self._switched = (state == self._id) + timerWins = self._switched + } + + if timerWins { + self._subscription.disposable = self._parent._other.subscribeSafe(self.forwarder()) + } + + return Disposables.create() + } + + nextTimer.setDisposable(disposeSchedule) + } +} + + +class Timeout : Producer { + + fileprivate let _source: Observable + fileprivate let _dueTime: RxTimeInterval + fileprivate let _other: Observable + fileprivate let _scheduler: SchedulerType + + init(source: Observable, dueTime: RxTimeInterval, other: Observable, scheduler: SchedulerType) { + _source = source + _dueTime = dueTime + _other = other + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Element { + let sink = TimeoutSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift new file mode 100644 index 0000000..7c2df2c --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift @@ -0,0 +1,72 @@ +// +// Timer.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class TimerSink : Sink where O.E : SignedInteger { + typealias Parent = Timer + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + return _parent._scheduler.schedulePeriodic(0 as O.E, startAfter: _parent._dueTime, period: _parent._period!) { state in + self.forwardOn(.next(state)) + return state &+ 1 + } + } +} + +class TimerOneOffSink : Sink where O.E : SignedInteger { + typealias Parent = Timer + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + return _parent._scheduler.scheduleRelative((), dueTime: _parent._dueTime) { (_) -> Disposable in + self.forwardOn(.next(0)) + self.forwardOn(.completed) + + return Disposables.create() + } + } +} + +class Timer: Producer { + fileprivate let _scheduler: SchedulerType + fileprivate let _dueTime: RxTimeInterval + fileprivate let _period: RxTimeInterval? + + init(dueTime: RxTimeInterval, period: RxTimeInterval?, scheduler: SchedulerType) { + _scheduler = scheduler + _dueTime = dueTime + _period = period + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { + if let _ = _period { + let sink = TimerSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } + else { + let sink = TimerOneOffSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift new file mode 100644 index 0000000..e066ec1 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift @@ -0,0 +1,50 @@ +// +// ToArray.swift +// Rx +// +// Created by Junior B. on 20/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ToArraySink : Sink, ObserverType where O.E == [SourceType] { + typealias Parent = ToArray + + let _parent: Parent + var _list = Array() + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event) { + switch event { + case .next(let value): + self._list.append(value) + case .error(let e): + forwardOn(.error(e)) + self.dispose() + case .completed: + forwardOn(.next(_list)) + forwardOn(.completed) + self.dispose() + } + } +} + +class ToArray : Producer<[SourceType]> { + let _source: Observable + + init(source: Observable) { + _source = source + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == [SourceType] { + let sink = ToArraySink(parent: self, observer: observer, cancel: cancel) + let subscription = _source.subscribe(sink) + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift new file mode 100644 index 0000000..d0c89b6 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift @@ -0,0 +1,78 @@ +// +// Using.swift +// Rx +// +// Created by Yury Korolev on 10/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class UsingSink : Sink, ObserverType where O.E == SourceType { + + typealias Parent = Using + typealias E = O.E + + private let _parent: Parent + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + var disposable = Disposables.create() + + do { + let resource = try _parent._resourceFactory() + disposable = resource + let source = try _parent._observableFactory(resource) + + return Disposables.create( + source.subscribe(self), + disposable + ) + } catch let error { + return Disposables.create( + Observable.error(error).subscribe(self), + disposable + ) + } + } + + func on(_ event: Event) { + switch event { + case let .next(value): + forwardOn(.next(value)) + case let .error(error): + forwardOn(.error(error)) + dispose() + case .completed: + forwardOn(.completed) + dispose() + } + } +} + +class Using: Producer { + + typealias E = SourceType + + typealias ResourceFactory = () throws -> ResourceType + typealias ObservableFactory = (ResourceType) throws -> Observable + + fileprivate let _resourceFactory: ResourceFactory + fileprivate let _observableFactory: ObservableFactory + + + init(resourceFactory: @escaping ResourceFactory, observableFactory: @escaping ObservableFactory) { + _resourceFactory = resourceFactory + _observableFactory = observableFactory + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == E { + let sink = UsingSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift new file mode 100644 index 0000000..25a5a2f --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Window.swift @@ -0,0 +1,154 @@ +// +// Window.swift +// Rx +// +// Created by Junior B. on 29/10/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class WindowTimeCountSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType where O.E == Observable { + typealias Parent = WindowTimeCount + typealias E = Element + + private let _parent: Parent + + let _lock = NSRecursiveLock() + + private var _subject = PublishSubject() + private var _count = 0 + private var _windowId = 0 + + private let _timerD = SerialDisposable() + private let _refCountDisposable: RefCountDisposable + private let _groupDisposable = CompositeDisposable() + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + + let _ = _groupDisposable.insert(_timerD) + + _refCountDisposable = RefCountDisposable(disposable: _groupDisposable) + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + + forwardOn(.next(AddRef(source: _subject, refCount: _refCountDisposable).asObservable())) + createTimer(_windowId) + + let _ = _groupDisposable.insert(_parent._source.subscribeSafe(self)) + return _refCountDisposable + } + + func startNewWindowAndCompleteCurrentOne() { + _subject.on(.completed) + _subject = PublishSubject() + + forwardOn(.next(AddRef(source: _subject, refCount: _refCountDisposable).asObservable())) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + var newWindow = false + var newId = 0 + + switch event { + case .next(let element): + _subject.on(.next(element)) + + do { + let _ = try incrementChecked(&_count) + } catch (let e) { + _subject.on(.error(e as Swift.Error)) + dispose() + } + + if (_count == _parent._count) { + newWindow = true + _count = 0 + _windowId += 1 + newId = _windowId + self.startNewWindowAndCompleteCurrentOne() + } + + case .error(let error): + _subject.on(.error(error)) + forwardOn(.error(error)) + dispose() + case .completed: + _subject.on(.completed) + forwardOn(.completed) + dispose() + } + + if newWindow { + createTimer(newId) + } + } + + func createTimer(_ windowId: Int) { + if _timerD.isDisposed { + return + } + + if _windowId != windowId { + return + } + + let nextTimer = SingleAssignmentDisposable() + + _timerD.disposable = nextTimer + + let scheduledRelative = _parent._scheduler.scheduleRelative(windowId, dueTime: _parent._timeSpan) { previousWindowId in + + var newId = 0 + + self._lock.performLocked { + if previousWindowId != self._windowId { + return + } + + self._count = 0 + self._windowId = self._windowId &+ 1 + newId = self._windowId + self.startNewWindowAndCompleteCurrentOne() + } + + self.createTimer(newId) + + return Disposables.create() + } + + nextTimer.setDisposable(scheduledRelative) + } +} + +class WindowTimeCount : Producer> { + + fileprivate let _timeSpan: RxTimeInterval + fileprivate let _count: Int + fileprivate let _scheduler: SchedulerType + fileprivate let _source: Observable + + init(source: Observable, timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) { + _source = source + _timeSpan = timeSpan + _count = count + _scheduler = scheduler + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == Observable { + let sink = WindowTimeCountSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift new file mode 100644 index 0000000..58f23f2 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/WithLatestFrom.swift @@ -0,0 +1,122 @@ +// +// WithLatestFrom.swift +// RxExample +// +// Created by Yury Korolev on 10/19/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class WithLatestFromSink + : Sink + , ObserverType + , LockOwnerType + , SynchronizedOnType where O.E == ResultType { + + typealias Parent = WithLatestFrom + typealias E = FirstType + + fileprivate let _parent: Parent + + var _lock = NSRecursiveLock() + fileprivate var _latest: SecondType? + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + + super.init(observer: observer, cancel: cancel) + } + + func run() -> Disposable { + let sndSubscription = SingleAssignmentDisposable() + let sndO = WithLatestFromSecond(parent: self, disposable: sndSubscription) + + sndSubscription.setDisposable(_parent._second.subscribe(sndO)) + let fstSubscription = _parent._first.subscribe(self) + + return Disposables.create(fstSubscription, sndSubscription) + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case let .next(value): + guard let latest = _latest else { return } + do { + let res = try _parent._resultSelector(value, latest) + + forwardOn(.next(res)) + } catch let e { + forwardOn(.error(e)) + dispose() + } + case .completed: + forwardOn(.completed) + dispose() + case let .error(error): + forwardOn(.error(error)) + dispose() + } + } +} + +class WithLatestFromSecond + : ObserverType + , LockOwnerType + , SynchronizedOnType where O.E == ResultType { + + typealias Parent = WithLatestFromSink + typealias E = SecondType + + private let _parent: Parent + private let _disposable: Disposable + + var _lock: NSRecursiveLock { + return _parent._lock + } + + init(parent: Parent, disposable: Disposable) { + _parent = parent + _disposable = disposable + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + switch event { + case let .next(value): + _parent._latest = value + case .completed: + _disposable.dispose() + case let .error(error): + _parent.forwardOn(.error(error)) + _parent.dispose() + } + } +} + +class WithLatestFrom: Producer { + typealias ResultSelector = (FirstType, SecondType) throws -> ResultType + + fileprivate let _first: Observable + fileprivate let _second: Observable + fileprivate let _resultSelector: ResultSelector + + init(first: Observable, second: Observable, resultSelector: @escaping ResultSelector) { + _first = first + _second = second + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == ResultType { + let sink = WithLatestFromSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+CollectionType.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+CollectionType.swift new file mode 100644 index 0000000..9da1e62 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+CollectionType.swift @@ -0,0 +1,139 @@ +// +// Zip+Collection.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ZipCollectionTypeSink + : Sink where C.Iterator.Element : ObservableConvertibleType, O.E == R { + typealias Parent = ZipCollectionType + typealias SourceElement = C.Iterator.Element.E + + private let _parent: Parent + + private let _lock = NSRecursiveLock() + + // state + private var _numberOfValues = 0 + private var _values: [Queue] + private var _isDone: [Bool] + private var _numberOfDone = 0 + private var _subscriptions: [SingleAssignmentDisposable] + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + _values = [Queue](repeating: Queue(capacity: 4), count: parent.count) + _isDone = [Bool](repeating: false, count: parent.count) + _subscriptions = Array() + _subscriptions.reserveCapacity(parent.count) + + for _ in 0 ..< parent.count { + _subscriptions.append(SingleAssignmentDisposable()) + } + + super.init(observer: observer, cancel: cancel) + } + + func on(_ event: Event, atIndex: Int) { + _lock.lock(); defer { _lock.unlock() } // { + switch event { + case .next(let element): + _values[atIndex].enqueue(element) + + if _values[atIndex].count == 1 { + _numberOfValues += 1 + } + + if _numberOfValues < _parent.count { + let numberOfOthersThatAreDone = _numberOfDone - (_isDone[atIndex] ? 1 : 0) + if numberOfOthersThatAreDone == _parent.count - 1 { + self.forwardOn(.completed) + self.dispose() + } + return + } + + do { + var arguments = [SourceElement]() + arguments.reserveCapacity(_parent.count) + + // recalculate number of values + _numberOfValues = 0 + + for i in 0 ..< _values.count { + arguments.append(_values[i].dequeue()!) + if _values[i].count > 0 { + _numberOfValues += 1 + } + } + + let result = try _parent.resultSelector(arguments) + self.forwardOn(.next(result)) + } + catch let error { + self.forwardOn(.error(error)) + self.dispose() + } + + case .error(let error): + self.forwardOn(.error(error)) + self.dispose() + case .completed: + if _isDone[atIndex] { + return + } + + _isDone[atIndex] = true + _numberOfDone += 1 + + if _numberOfDone == _parent.count { + self.forwardOn(.completed) + self.dispose() + } + else { + _subscriptions[atIndex].dispose() + } + } + // } + } + + func run() -> Disposable { + var j = 0 + for i in _parent.sources { + let index = j + let source = i.asObservable() + + let disposable = source.subscribe(AnyObserver { event in + self.on(event, atIndex: index) + }) + _subscriptions[j].setDisposable(disposable) + j += 1 + } + + return Disposables.create(_subscriptions) + } +} + +class ZipCollectionType : Producer where C.Iterator.Element : ObservableConvertibleType { + typealias ResultSelector = ([C.Iterator.Element.E]) throws -> R + + let sources: C + let resultSelector: ResultSelector + let count: Int + + init(sources: C, resultSelector: @escaping ResultSelector) { + self.sources = sources + self.resultSelector = resultSelector + self.count = Int(self.sources.count.toIntMax()) + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = ZipCollectionTypeSink(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift new file mode 100644 index 0000000..6c3612a --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Zip+arity.swift @@ -0,0 +1,831 @@ +// This file is autogenerated. Take a look at `Preprocessor` target in RxSwift project +// +// Zip+arity.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/23/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + + + +// 2 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, resultSelector: @escaping (O1.E, O2.E) throws -> E) + -> Observable { + return Zip2( + source1: source1.asObservable(), source2: source2.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink2_ : ZipSink { + typealias R = O.E + typealias Parent = Zip2 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 2, observer: observer, cancel: cancel) + } + + override func hasElements(_ index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + + subscription1.setDisposable(_parent.source1.subscribe(observer1)) + subscription2.setDisposable(_parent.source2.subscribe(observer2)) + + return Disposables.create([ + subscription1, + subscription2 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!) + } +} + +class Zip2 : Producer { + typealias ResultSelector = (E1, E2) throws -> R + + let source1: Observable + let source2: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, resultSelector: @escaping ResultSelector) { + self.source1 = source1 + self.source2 = source2 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = ZipSink2_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 3 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, resultSelector: @escaping (O1.E, O2.E, O3.E) throws -> E) + -> Observable { + return Zip3( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink3_ : ZipSink { + typealias R = O.E + typealias Parent = Zip3 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 3, observer: observer, cancel: cancel) + } + + override func hasElements(_ index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + + subscription1.setDisposable(_parent.source1.subscribe(observer1)) + subscription2.setDisposable(_parent.source2.subscribe(observer2)) + subscription3.setDisposable(_parent.source3.subscribe(observer3)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!) + } +} + +class Zip3 : Producer { + typealias ResultSelector = (E1, E2, E3) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, resultSelector: @escaping ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = ZipSink3_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 4 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E) throws -> E) + -> Observable { + return Zip4( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink4_ : ZipSink { + typealias R = O.E + typealias Parent = Zip4 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 4, observer: observer, cancel: cancel) + } + + override func hasElements(_ index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + + subscription1.setDisposable(_parent.source1.subscribe(observer1)) + subscription2.setDisposable(_parent.source2.subscribe(observer2)) + subscription3.setDisposable(_parent.source3.subscribe(observer3)) + subscription4.setDisposable(_parent.source4.subscribe(observer4)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!) + } +} + +class Zip4 : Producer { + typealias ResultSelector = (E1, E2, E3, E4) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, resultSelector: @escaping ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = ZipSink4_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 5 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E) throws -> E) + -> Observable { + return Zip5( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink5_ : ZipSink { + typealias R = O.E + typealias Parent = Zip5 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + var _values5: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 5, observer: observer, cancel: cancel) + } + + override func hasElements(_ index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + case 4: return _values5.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + let observer5 = ZipObserver(lock: _lock, parent: self, index: 4, setNextValue: { self._values5.enqueue($0) }, this: subscription5) + + subscription1.setDisposable(_parent.source1.subscribe(observer1)) + subscription2.setDisposable(_parent.source2.subscribe(observer2)) + subscription3.setDisposable(_parent.source3.subscribe(observer3)) + subscription4.setDisposable(_parent.source4.subscribe(observer4)) + subscription5.setDisposable(_parent.source5.subscribe(observer5)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!, _values5.dequeue()!) + } +} + +class Zip5 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + let source5: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, resultSelector: @escaping ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + self.source5 = source5 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = ZipSink5_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 6 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E) throws -> E) + -> Observable { + return Zip6( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink6_ : ZipSink { + typealias R = O.E + typealias Parent = Zip6 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + var _values5: Queue = Queue(capacity: 2) + var _values6: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 6, observer: observer, cancel: cancel) + } + + override func hasElements(_ index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + case 4: return _values5.count > 0 + case 5: return _values6.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + let observer5 = ZipObserver(lock: _lock, parent: self, index: 4, setNextValue: { self._values5.enqueue($0) }, this: subscription5) + let observer6 = ZipObserver(lock: _lock, parent: self, index: 5, setNextValue: { self._values6.enqueue($0) }, this: subscription6) + + subscription1.setDisposable(_parent.source1.subscribe(observer1)) + subscription2.setDisposable(_parent.source2.subscribe(observer2)) + subscription3.setDisposable(_parent.source3.subscribe(observer3)) + subscription4.setDisposable(_parent.source4.subscribe(observer4)) + subscription5.setDisposable(_parent.source5.subscribe(observer5)) + subscription6.setDisposable(_parent.source6.subscribe(observer6)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!, _values5.dequeue()!, _values6.dequeue()!) + } +} + +class Zip6 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + let source5: Observable + let source6: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, resultSelector: @escaping ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + self.source5 = source5 + self.source6 = source6 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = ZipSink6_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 7 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E) throws -> E) + -> Observable { + return Zip7( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), source7: source7.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink7_ : ZipSink { + typealias R = O.E + typealias Parent = Zip7 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + var _values5: Queue = Queue(capacity: 2) + var _values6: Queue = Queue(capacity: 2) + var _values7: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 7, observer: observer, cancel: cancel) + } + + override func hasElements(_ index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + case 4: return _values5.count > 0 + case 5: return _values6.count > 0 + case 6: return _values7.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + let subscription7 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + let observer5 = ZipObserver(lock: _lock, parent: self, index: 4, setNextValue: { self._values5.enqueue($0) }, this: subscription5) + let observer6 = ZipObserver(lock: _lock, parent: self, index: 5, setNextValue: { self._values6.enqueue($0) }, this: subscription6) + let observer7 = ZipObserver(lock: _lock, parent: self, index: 6, setNextValue: { self._values7.enqueue($0) }, this: subscription7) + + subscription1.setDisposable(_parent.source1.subscribe(observer1)) + subscription2.setDisposable(_parent.source2.subscribe(observer2)) + subscription3.setDisposable(_parent.source3.subscribe(observer3)) + subscription4.setDisposable(_parent.source4.subscribe(observer4)) + subscription5.setDisposable(_parent.source5.subscribe(observer5)) + subscription6.setDisposable(_parent.source6.subscribe(observer6)) + subscription7.setDisposable(_parent.source7.subscribe(observer7)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6, + subscription7 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!, _values5.dequeue()!, _values6.dequeue()!, _values7.dequeue()!) + } +} + +class Zip7 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6, E7) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + let source5: Observable + let source6: Observable + let source7: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, source7: Observable, resultSelector: @escaping ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + self.source5 = source5 + self.source6 = source6 + self.source7 = source7 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = ZipSink7_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + + +// 8 + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip + (_ source1: O1, _ source2: O2, _ source3: O3, _ source4: O4, _ source5: O5, _ source6: O6, _ source7: O7, _ source8: O8, resultSelector: @escaping (O1.E, O2.E, O3.E, O4.E, O5.E, O6.E, O7.E, O8.E) throws -> E) + -> Observable { + return Zip8( + source1: source1.asObservable(), source2: source2.asObservable(), source3: source3.asObservable(), source4: source4.asObservable(), source5: source5.asObservable(), source6: source6.asObservable(), source7: source7.asObservable(), source8: source8.asObservable(), + resultSelector: resultSelector + ) + } +} + +class ZipSink8_ : ZipSink { + typealias R = O.E + typealias Parent = Zip8 + + let _parent: Parent + + var _values1: Queue = Queue(capacity: 2) + var _values2: Queue = Queue(capacity: 2) + var _values3: Queue = Queue(capacity: 2) + var _values4: Queue = Queue(capacity: 2) + var _values5: Queue = Queue(capacity: 2) + var _values6: Queue = Queue(capacity: 2) + var _values7: Queue = Queue(capacity: 2) + var _values8: Queue = Queue(capacity: 2) + + init(parent: Parent, observer: O, cancel: Cancelable) { + _parent = parent + super.init(arity: 8, observer: observer, cancel: cancel) + } + + override func hasElements(_ index: Int) -> Bool { + switch (index) { + case 0: return _values1.count > 0 + case 1: return _values2.count > 0 + case 2: return _values3.count > 0 + case 3: return _values4.count > 0 + case 4: return _values5.count > 0 + case 5: return _values6.count > 0 + case 6: return _values7.count > 0 + case 7: return _values8.count > 0 + + default: + rxFatalError("Unhandled case (Function)") + } + + return false + } + + func run() -> Disposable { + let subscription1 = SingleAssignmentDisposable() + let subscription2 = SingleAssignmentDisposable() + let subscription3 = SingleAssignmentDisposable() + let subscription4 = SingleAssignmentDisposable() + let subscription5 = SingleAssignmentDisposable() + let subscription6 = SingleAssignmentDisposable() + let subscription7 = SingleAssignmentDisposable() + let subscription8 = SingleAssignmentDisposable() + + let observer1 = ZipObserver(lock: _lock, parent: self, index: 0, setNextValue: { self._values1.enqueue($0) }, this: subscription1) + let observer2 = ZipObserver(lock: _lock, parent: self, index: 1, setNextValue: { self._values2.enqueue($0) }, this: subscription2) + let observer3 = ZipObserver(lock: _lock, parent: self, index: 2, setNextValue: { self._values3.enqueue($0) }, this: subscription3) + let observer4 = ZipObserver(lock: _lock, parent: self, index: 3, setNextValue: { self._values4.enqueue($0) }, this: subscription4) + let observer5 = ZipObserver(lock: _lock, parent: self, index: 4, setNextValue: { self._values5.enqueue($0) }, this: subscription5) + let observer6 = ZipObserver(lock: _lock, parent: self, index: 5, setNextValue: { self._values6.enqueue($0) }, this: subscription6) + let observer7 = ZipObserver(lock: _lock, parent: self, index: 6, setNextValue: { self._values7.enqueue($0) }, this: subscription7) + let observer8 = ZipObserver(lock: _lock, parent: self, index: 7, setNextValue: { self._values8.enqueue($0) }, this: subscription8) + + subscription1.setDisposable(_parent.source1.subscribe(observer1)) + subscription2.setDisposable(_parent.source2.subscribe(observer2)) + subscription3.setDisposable(_parent.source3.subscribe(observer3)) + subscription4.setDisposable(_parent.source4.subscribe(observer4)) + subscription5.setDisposable(_parent.source5.subscribe(observer5)) + subscription6.setDisposable(_parent.source6.subscribe(observer6)) + subscription7.setDisposable(_parent.source7.subscribe(observer7)) + subscription8.setDisposable(_parent.source8.subscribe(observer8)) + + return Disposables.create([ + subscription1, + subscription2, + subscription3, + subscription4, + subscription5, + subscription6, + subscription7, + subscription8 + ]) + } + + override func getResult() throws -> R { + return try _parent._resultSelector(_values1.dequeue()!, _values2.dequeue()!, _values3.dequeue()!, _values4.dequeue()!, _values5.dequeue()!, _values6.dequeue()!, _values7.dequeue()!, _values8.dequeue()!) + } +} + +class Zip8 : Producer { + typealias ResultSelector = (E1, E2, E3, E4, E5, E6, E7, E8) throws -> R + + let source1: Observable + let source2: Observable + let source3: Observable + let source4: Observable + let source5: Observable + let source6: Observable + let source7: Observable + let source8: Observable + + let _resultSelector: ResultSelector + + init(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, source6: Observable, source7: Observable, source8: Observable, resultSelector: @escaping ResultSelector) { + self.source1 = source1 + self.source2 = source2 + self.source3 = source3 + self.source4 = source4 + self.source5 = source5 + self.source6 = source6 + self.source7 = source7 + self.source8 = source8 + + _resultSelector = resultSelector + } + + override func run(_ observer: O, cancel: Cancelable) -> (sink: Disposable, subscription: Disposable) where O.E == R { + let sink = ZipSink8_(parent: self, observer: observer, cancel: cancel) + let subscription = sink.run() + return (sink: sink, subscription: subscription) + } +} + + diff --git a/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift b/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift new file mode 100644 index 0000000..0cd273c --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Implementations/Zip.swift @@ -0,0 +1,157 @@ +// +// Zip.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/23/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol ZipSinkProtocol : class +{ + func next(_ index: Int) + func fail(_ error: Swift.Error) + func done(_ index: Int) +} + +class ZipSink : Sink, ZipSinkProtocol { + typealias Element = O.E + + let _arity: Int + + let _lock = NSRecursiveLock() + + // state + private var _isDone: [Bool] + + init(arity: Int, observer: O, cancel: Cancelable) { + _isDone = [Bool](repeating: false, count: arity) + _arity = arity + + super.init(observer: observer, cancel: cancel) + } + + func getResult() throws -> Element { + abstractMethod() + } + + func hasElements(_ index: Int) -> Bool { + abstractMethod() + } + + func next(_ index: Int) { + var hasValueAll = true + + for i in 0 ..< _arity { + if !hasElements(i) { + hasValueAll = false + break + } + } + + if hasValueAll { + do { + let result = try getResult() + self.forwardOn(.next(result)) + } + catch let e { + self.forwardOn(.error(e)) + dispose() + } + } + else { + var allOthersDone = true + + let arity = _isDone.count + for i in 0 ..< arity { + if i != index && !_isDone[i] { + allOthersDone = false + break + } + } + + if allOthersDone { + forwardOn(.completed) + self.dispose() + } + } + } + + func fail(_ error: Swift.Error) { + forwardOn(.error(error)) + dispose() + } + + func done(_ index: Int) { + _isDone[index] = true + + var allDone = true + + for done in _isDone { + if !done { + allDone = false + break + } + } + + if allDone { + forwardOn(.completed) + dispose() + } + } +} + +class ZipObserver + : ObserverType + , LockOwnerType + , SynchronizedOnType { + typealias E = ElementType + typealias ValueSetter = (ElementType) -> () + + private var _parent: ZipSinkProtocol? + + let _lock: NSRecursiveLock + + // state + private let _index: Int + private let _this: Disposable + private let _setNextValue: ValueSetter + + init(lock: NSRecursiveLock, parent: ZipSinkProtocol, index: Int, setNextValue: @escaping ValueSetter, this: Disposable) { + _lock = lock + _parent = parent + _index = index + _this = this + _setNextValue = setNextValue + } + + func on(_ event: Event) { + synchronizedOn(event) + } + + func _synchronized_on(_ event: Event) { + if let _ = _parent { + switch event { + case .next(_): + break + case .error(_): + _this.dispose() + case .completed: + _this.dispose() + } + } + + if let parent = _parent { + switch event { + case .next(let value): + _setNextValue(value) + parent.next(_index) + case .error(let error): + parent.fail(error) + case .completed: + parent.done(_index) + } + } + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift b/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift new file mode 100644 index 0000000..b56be33 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift @@ -0,0 +1,64 @@ +// +// Observable+Aggregate.swift +// Rx +// +// Created by Krunoslav Zaher on 3/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: reduce + +extension ObservableType { + + /** + Applies an `accumulator` function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified `seed` value is used as the initial accumulator value. + + For aggregation behavior with incremental intermediate results, see `scan`. + + - seealso: [reduce operator on reactivex.io](http://reactivex.io/documentation/operators/reduce.html) + + - parameter seed: The initial accumulator value. + - parameter accumulator: A accumulator function to be invoked on each element. + - parameter mapResult: A function to transform the final accumulator value into the result value. + - returns: An observable sequence containing a single element with the final accumulator value. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func reduce(_ seed: A, accumulator: @escaping (A, E) throws -> A, mapResult: @escaping (A) throws -> R) + -> Observable { + return Reduce(source: self.asObservable(), seed: seed, accumulator: accumulator, mapResult: mapResult) + } + + /** + Applies an `accumulator` function over an observable sequence, returning the result of the aggregation as a single element in the result sequence. The specified `seed` value is used as the initial accumulator value. + + For aggregation behavior with incremental intermediate results, see `scan`. + + - seealso: [reduce operator on reactivex.io](http://reactivex.io/documentation/operators/reduce.html) + + - parameter seed: The initial accumulator value. + - parameter accumulator: A accumulator function to be invoked on each element. + - returns: An observable sequence containing a single element with the final accumulator value. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func reduce
(_ seed: A, accumulator: @escaping (A, E) throws -> A) + -> Observable { + return Reduce(source: self.asObservable(), seed: seed, accumulator: accumulator, mapResult: { $0 }) + } + + /** + Converts an Observable into another Observable that emits the whole sequence as a single array and then terminates. + + For aggregation behavior see `reduce`. + + - seealso: [toArray operator on reactivex.io](http://reactivex.io/documentation/operators/to.html) + + - returns: An observable sequence containing all the emitted elements as array. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func toArray() + -> Observable<[E]> { + return ToArray(source: self.asObservable()) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift b/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift new file mode 100644 index 0000000..95f6e53 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+Binding.swift @@ -0,0 +1,190 @@ +// +// Observable+Binding.swift +// Rx +// +// Created by Krunoslav Zaher on 3/1/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: multicast + +extension ObservableType { + + /** + Multicasts the source sequence notifications through the specified subject to the resulting connectable observable. + + Upon connection of the connectable observable, the subject is subscribed to the source exactly one, and messages are forwarded to the observers registered with the connectable observable. + + For specializations with fixed subject types, see `publish` and `replay`. + + - seealso: [multicast operator on reactivex.io](http://reactivex.io/documentation/operators/publish.html) + + - parameter subject: Subject to push source elements into. + - returns: A connectable observable sequence that upon connection causes the source sequence to push results into the specified subject. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func multicast(_ subject: S) + -> ConnectableObservable where S.SubjectObserverType.E == E { + return ConnectableObservableAdapter(source: self.asObservable(), subject: subject) + } + + /** + Multicasts the source sequence notifications through an instantiated subject into all uses of the sequence within a selector function. + + Each subscription to the resulting sequence causes a separate multicast invocation, exposing the sequence resulting from the selector function's invocation. + + For specializations with fixed subject types, see `publish` and `replay`. + + - seealso: [multicast operator on reactivex.io](http://reactivex.io/documentation/operators/publish.html) + + - parameter subjectSelector: Factory function to create an intermediate subject through which the source sequence's elements will be multicast to the selector function. + - parameter selector: Selector function which can use the multicasted source sequence subject to the policies enforced by the created subject. + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence within a selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func multicast(_ subjectSelector: @escaping () throws -> S, selector: @escaping (Observable) throws -> Observable) + -> Observable where S.SubjectObserverType.E == E { + return Multicast( + source: self.asObservable(), + subjectSelector: subjectSelector, + selector: selector + ) + } +} + +// MARK: publish + +extension ObservableType { + + /** + Returns a connectable observable sequence that shares a single subscription to the underlying sequence. + + This operator is a specialization of `multicast` using a `PublishSubject`. + + - seealso: [publish operator on reactivex.io](http://reactivex.io/documentation/operators/publish.html) + + - returns: A connectable observable sequence that shares a single subscription to the underlying sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func publish() -> ConnectableObservable { + return self.multicast(PublishSubject()) + } +} + +// MARK: replay + +extension ObservableType { + + /** + Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying bufferSize elements. + + This operator is a specialization of `multicast` using a `ReplaySubject`. + + - seealso: [replay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - parameter bufferSize: Maximum element count of the replay buffer. + - returns: A connectable observable sequence that shares a single subscription to the underlying sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func replay(_ bufferSize: Int) + -> ConnectableObservable { + return self.multicast(ReplaySubject.create(bufferSize: bufferSize)) + } + + /** + Returns a connectable observable sequence that shares a single subscription to the underlying sequence replaying all elements. + + This operator is a specialization of `multicast` using a `ReplaySubject`. + + - seealso: [replay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - returns: A connectable observable sequence that shares a single subscription to the underlying sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func replayAll() + -> ConnectableObservable { + return self.multicast(ReplaySubject.createUnbounded()) + } +} + +// MARK: refcount + +extension ConnectableObservableType { + + /** + Returns an observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence. + + - seealso: [refCount operator on reactivex.io](http://reactivex.io/documentation/operators/refCount.html) + + - returns: An observable sequence that stays connected to the source as long as there is at least one subscription to the observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func refCount() -> Observable { + return RefCount(source: self) + } +} + +// MARK: share + +extension ObservableType { + + /** + Returns an observable sequence that shares a single subscription to the underlying sequence. + + This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + + - seealso: [share operator on reactivex.io](http://reactivex.io/documentation/operators/refcount.html) + + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func share() -> Observable { + return self.publish().refCount() + } +} + +// MARK: shareReplay + +extension ObservableType { + + /** + Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays maximum number of elements in buffer. + + This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + + - seealso: [shareReplay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - parameter bufferSize: Maximum element count of the replay buffer. + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func shareReplay(_ bufferSize: Int) + -> Observable { + if bufferSize == 1 { + return ShareReplay1(source: self.asObservable()) + } + else { + return self.replay(bufferSize).refCount() + } + } + + /** + Returns an observable sequence that shares a single subscription to the underlying sequence, and immediately upon subscription replays latest element in buffer. + + This operator is a specialization of replay which creates a subscription when the number of observers goes from zero to one, then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed. + + Unlike `shareReplay(bufferSize: Int)`, this operator will clear latest element from replay buffer in case number of subscribers drops from one to zero. In case sequence + completes or errors out replay buffer is also cleared. + + - seealso: [shareReplay operator on reactivex.io](http://reactivex.io/documentation/operators/replay.html) + + - returns: An observable sequence that contains the elements of a sequence produced by multicasting the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func shareReplayLatestWhileConnected() + -> Observable { + return ShareReplay1WhileConnected(source: self.asObservable()) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift b/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift new file mode 100644 index 0000000..1ece7d8 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift @@ -0,0 +1,62 @@ +// +// Observable+Concurrency.swift +// Rx +// +// Created by Krunoslav Zaher on 3/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: observeOn + +extension ObservableType { + + /** + Wraps the source sequence in order to run its observer callbacks on the specified scheduler. + + This only invokes observer callbacks on a `scheduler`. In case the subscription and/or unsubscription + actions have side-effects that require to be run on a scheduler, use `subscribeOn`. + + - seealso: [observeOn operator on reactivex.io](http://reactivex.io/documentation/operators/observeon.html) + + - parameter scheduler: Scheduler to notify observers on. + - returns: The source sequence whose observations happen on the specified scheduler. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func observeOn(_ scheduler: ImmediateSchedulerType) + -> Observable { + if let scheduler = scheduler as? SerialDispatchQueueScheduler { + return ObserveOnSerialDispatchQueue(source: self.asObservable(), scheduler: scheduler) + } + else { + return ObserveOn(source: self.asObservable(), scheduler: scheduler) + } + } +} + +// MARK: subscribeOn + +extension ObservableType { + + /** + Wraps the source sequence in order to run its subscription and unsubscription logic on the specified + scheduler. + + This operation is not commonly used. + + This only performs the side-effects of subscription and unsubscription on the specified scheduler. + + In order to invoke observer callbacks on a `scheduler`, use `observeOn`. + + - seealso: [subscribeOn operator on reactivex.io](http://reactivex.io/documentation/operators/subscribeon.html) + + - parameter scheduler: Scheduler to perform subscription and unsubscription actions on. + - returns: The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func subscribeOn(_ scheduler: ImmediateSchedulerType) + -> Observable { + return SubscribeOn(source: self, scheduler: scheduler) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift b/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift new file mode 100644 index 0000000..c42b019 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+Creation.swift @@ -0,0 +1,237 @@ +// +// Observable+Creation.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +extension Observable { + // MARK: create + + /** + Creates an observable sequence from a specified subscribe method implementation. + + - seealso: [create operator on reactivex.io](http://reactivex.io/documentation/operators/create.html) + + - parameter subscribe: Implementation of the resulting observable sequence's `subscribe` method. + - returns: The observable sequence with the specified implementation for the `subscribe` method. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func create(_ subscribe: @escaping (AnyObserver) -> Disposable) -> Observable { + return AnonymousObservable(subscribe) + } + + // MARK: empty + + /** + Returns an empty observable sequence, using the specified scheduler to send out the single `Completed` message. + + - seealso: [empty operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) + + - returns: An observable sequence with no elements. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func empty() -> Observable { + return Empty() + } + + // MARK: never + + /** + Returns a non-terminating observable sequence, which can be used to denote an infinite duration. + + - seealso: [never operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) + + - returns: An observable sequence whose observers will never get called. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func never() -> Observable { + return Never() + } + + // MARK: just + + /** + Returns an observable sequence that contains a single element. + + - seealso: [just operator on reactivex.io](http://reactivex.io/documentation/operators/just.html) + + - parameter element: Single element in the resulting observable sequence. + - parameter: Scheduler to send the single element on. + - returns: An observable sequence containing the single specified element. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func just(_ element: E, scheduler: ImmediateSchedulerType? = nil) -> Observable { + if let scheduler = scheduler { + return JustScheduled(element: element, scheduler: scheduler) + } + else { + return Just(element: element) + } + } + + // MARK: fail + + /** + Returns an observable sequence that terminates with an `error`. + + - seealso: [throw operator on reactivex.io](http://reactivex.io/documentation/operators/empty-never-throw.html) + + - returns: The observable sequence that terminates with specified error. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func error(_ error: Swift.Error) -> Observable { + return Error(error: error) + } + + // MARK: of + + /** + This method creates a new Observable instance with a variable number of elements. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - parameter elements: Elements to generate. + - parameter scheduler: Scheduler to send elements on. If `nil`, elements are sent immediatelly on subscription. + - returns: The observable sequence whose elements are pulled from the given arguments. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func of(_ elements: E ..., scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { + return ObservableSequence(elements: elements, scheduler: scheduler) + } + + // MARK: defer + + /** + Returns an observable sequence that invokes the specified factory function whenever a new observer subscribes. + + - seealso: [defer operator on reactivex.io](http://reactivex.io/documentation/operators/defer.html) + + - parameter observableFactory: Observable factory function to invoke for each observer that subscribes to the resulting sequence. + - returns: An observable sequence whose observers trigger an invocation of the given observable factory function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func deferred(_ observableFactory: @escaping () throws -> Observable) + -> Observable { + return Deferred(observableFactory: observableFactory) + } + + /** + Generates an observable sequence by running a state-driven loop producing the sequence's elements, using the specified scheduler + to run the loop send out observer messages. + + - seealso: [create operator on reactivex.io](http://reactivex.io/documentation/operators/create.html) + + - parameter initialState: Initial state. + - parameter condition: Condition to terminate generation (upon returning `false`). + - parameter iterate: Iteration step function. + - parameter scheduler: Scheduler on which to run the generator loop. + - returns: The generated sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func generate(initialState: E, condition: @escaping (E) throws -> Bool, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance, iterate: @escaping (E) throws -> E) -> Observable { + return Generate(initialState: initialState, condition: condition, iterate: iterate, resultSelector: { $0 }, scheduler: scheduler) + } + + /** + Generates an observable sequence that repeats the given element infinitely, using the specified scheduler to send out observer messages. + + - seealso: [repeat operator on reactivex.io](http://reactivex.io/documentation/operators/repeat.html) + + - parameter element: Element to repeat. + - parameter scheduler: Scheduler to run the producer loop on. + - returns: An observable sequence that repeats the given element infinitely. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func repeatElement(_ element: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { + return RepeatElement(element: element, scheduler: scheduler) + } + + /** + Constructs an observable sequence that depends on a resource object, whose lifetime is tied to the resulting observable sequence's lifetime. + + - seealso: [using operator on reactivex.io](http://reactivex.io/documentation/operators/using.html) + + - parameter resourceFactory: Factory function to obtain a resource object. + - parameter observableFactory: Factory function to obtain an observable sequence that depends on the obtained resource. + - returns: An observable sequence whose lifetime controls the lifetime of the dependent resource object. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func using(_ resourceFactory: @escaping () throws -> R, observableFactory: @escaping (R) throws -> Observable) -> Observable { + return Using(resourceFactory: resourceFactory, observableFactory: observableFactory) + } +} + +extension Observable where Element : SignedInteger { + /** + Generates an observable sequence of integral numbers within a specified range, using the specified scheduler to generate and send out observer messages. + + - seealso: [range operator on reactivex.io](http://reactivex.io/documentation/operators/range.html) + + - parameter start: The value of the first integer in the sequence. + - parameter count: The number of sequential integers to generate. + - parameter scheduler: Scheduler to run the generator loop on. + - returns: An observable sequence that contains a range of sequential integral numbers. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func range(start: E, count: E, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { + return RangeProducer(start: start, count: count, scheduler: scheduler) + } +} + +extension Sequence { + /** + Converts a sequence to an observable sequence. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - returns: The observable sequence whose elements are pulled from the given enumerable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "Observable.from()") + public func toObservable(_ scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { + return ObservableSequence(elements: Array(self), scheduler: scheduler) + } +} + +extension Array { + /** + Converts a sequence to an observable sequence. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - returns: The observable sequence whose elements are pulled from the given enumerable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "Observable.from()") + public func toObservable(_ scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { + return ObservableSequence(elements: self, scheduler: scheduler) + } +} + +extension Observable { + /** + Converts an array to an observable sequence. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - returns: The observable sequence whose elements are pulled from the given enumerable sequence. + */ + public static func from(_ array: [E], scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable { + return ObservableSequence(elements: array, scheduler: scheduler) + } + + /** + Converts a sequence to an observable sequence. + + - seealso: [from operator on reactivex.io](http://reactivex.io/documentation/operators/from.html) + + - returns: The observable sequence whose elements are pulled from the given enumerable sequence. + */ + public static func from(_ sequence: S, scheduler: ImmediateSchedulerType = CurrentThreadScheduler.instance) -> Observable where S.Iterator.Element == E { + return ObservableSequence(elements: sequence, scheduler: scheduler) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift b/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift new file mode 100644 index 0000000..c5799e0 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift @@ -0,0 +1,28 @@ +// +// Observable+Debug.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: debug + +extension ObservableType { + + /** + Prints received events for all observers on standard output. + + - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) + + - parameter identifier: Identifier that is printed together with event description to standard output. + - returns: An observable sequence whose events are printed to standard output. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func debug(_ identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) + -> Observable { + return Debug(source: self, identifier: identifier, file: file, line: line, function: function) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift b/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift new file mode 100644 index 0000000..e88d819 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+Multiple.swift @@ -0,0 +1,440 @@ +// +// Observable+Multiple.swift +// Rx +// +// Created by Krunoslav Zaher on 3/12/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: combineLatest + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combinelatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func combineLatest(_ collection: C, _ resultSelector: @escaping ([C.Iterator.Element.E]) throws -> Element) -> Observable + where C.Iterator.Element: ObservableType { + return CombineLatestCollectionType(sources: collection, resultSelector: resultSelector) + } +} + +extension Collection where Iterator.Element : ObservableType { + + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever any of the observable sequences produces an element. + + - seealso: [combinelatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter resultSelector: Function to invoke whenever any of the sources produces an element. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "Observable.combineLatest()") + public func combineLatest(_ resultSelector: @escaping ([Generator.Element.E]) throws -> R) -> Observable { + return CombineLatestCollectionType(sources: self, resultSelector: resultSelector) + } +} + +// MARK: zip + +extension Observable { + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func zip(_ collection: C, _ resultSelector: @escaping ([C.Iterator.Element.E]) throws -> Element) -> Observable + where C.Iterator.Element: ObservableType { + return ZipCollectionType(sources: collection, resultSelector: resultSelector) + } +} + +extension Collection where Iterator.Element : ObservableType { + + /** + Merges the specified observable sequences into one observable sequence by using the selector function whenever all of the observable sequences have produced an element at a corresponding index. + + - seealso: [zip operator on reactivex.io](http://reactivex.io/documentation/operators/zip.html) + + - parameter resultSelector: Function to invoke for each series of elements at corresponding indexes in the sources. + - returns: An observable sequence containing the result of combining elements of the sources using the specified result selector function. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "Observable.zip()") + public func zip(_ resultSelector: @escaping ([Generator.Element.E]) throws -> R) -> Observable { + return ZipCollectionType(sources: self, resultSelector: resultSelector) + } +} + +// MARK: switch + +extension ObservableType where E : ObservableConvertibleType { + + /** + Transforms an observable sequence of observable sequences into an observable sequence + producing values only from the most recent observable sequence. + + Each time a new inner observable sequence is received, unsubscribe from the + previous inner observable sequence. + + - seealso: [switch operator on reactivex.io](http://reactivex.io/documentation/operators/switch.html) + + - returns: The observable sequence that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func switchLatest() -> Observable { + return Switch(source: asObservable()) + } +} + +// MARK: concat + +extension ObservableType { + + /** + Concatenates the second observable sequence to `self` upon successful termination of `self`. + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - parameter second: Second observable sequence. + - returns: An observable sequence that contains the elements of `self`, followed by those of the second sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func concat(_ second: O) -> Observable where O.E == E { + return Observable.concat([self.asObservable(), second.asObservable()]) + } +} + +extension Observable { + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + This operator has tail recursive optimizations that will prevent stack overflow. + + Optimizations will be performed in cases equivalent to following: + + [1, [2, [3, .....].concat()].concat].concat() + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func concat(_ sequence: S) -> Observable + where S.Iterator.Element == Observable { + return Concat(sources: sequence, count: nil) + } + + /** + Concatenates all observable sequences in the given collection, as long as the previous observable sequence terminated successfully. + + This operator has tail recursive optimizations that will prevent stack overflow. + + Optimizations will be performed in cases equivalent to following: + + [1, [2, [3, .....].concat()].concat].concat() + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func concat(_ collection: S) -> Observable + where S.Iterator.Element == Observable { + return Concat(sources: collection, count: collection.count.toIntMax()) + } +} + +extension Sequence where Iterator.Element : ObservableType { + + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + This operator has tail recursive optimizations that will prevent stack overflow. + + Optimizations will be performed in cases equivalent to following: + + [1, [2, [3, .....].concat()].concat].concat() + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "Observable.concat()") + public func concat() + -> Observable { + return Concat(sources: self, count: nil) + } +} + +extension Collection where Iterator.Element : ObservableType { + + /** + Concatenates all observable sequences in the given sequence, as long as the previous observable sequence terminated successfully. + + This operator has tail recursive optimizations that will prevent stack overflow and enable generating + infinite observable sequences while using limited amount of memory during generation. + + Optimizations will be performed in cases equivalent to following: + + [1, [2, [3, .....].concat()].concat].concat() + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - returns: An observable sequence that contains the elements of each given sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "Observable.concat()") + public func concat() + -> Observable { + return Concat(sources: self, count: self.count.toIntMax()) + } +} + +extension ObservableType where E : ObservableConvertibleType { + + /** + Concatenates all inner observable sequences, as long as the previous observable sequence terminated successfully. + + - seealso: [concat operator on reactivex.io](http://reactivex.io/documentation/operators/concat.html) + + - returns: An observable sequence that contains the elements of each observed inner sequence, in sequential order. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func concat() -> Observable { + return merge(maxConcurrent: 1) + } +} + +// MARK: merge + +extension ObservableType where E : ObservableConvertibleType { + + /** + Merges elements from all observable sequences in the given enumerable sequence into a single observable sequence. + + - seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html) + + - returns: The observable sequence that merges the elements of the observable sequences. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func merge() -> Observable { + return Merge(source: asObservable()) + } + + /** + Merges elements from all inner observable sequences into a single observable sequence, limiting the number of concurrent subscriptions to inner sequences. + + - seealso: [merge operator on reactivex.io](http://reactivex.io/documentation/operators/merge.html) + + - parameter maxConcurrent: Maximum number of inner observable sequences being subscribed to concurrently. + - returns: The observable sequence that merges the elements of the inner sequences. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func merge(maxConcurrent: Int) + -> Observable { + return MergeLimited(source: asObservable(), maxConcurrent: maxConcurrent) + } +} + +// MARK: catch + +extension ObservableType { + + /** + Continues an observable sequence that is terminated by an error with the observable sequence produced by the handler. + + - seealso: [catch operator on reactivex.io](http://reactivex.io/documentation/operators/catch.html) + + - parameter handler: Error handler function, producing another observable sequence. + - returns: An observable sequence containing the source sequence's elements, followed by the elements produced by the handler's resulting observable sequence in case an error occurred. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func catchError(_ handler: @escaping (Swift.Error) throws -> Observable) + -> Observable { + return Catch(source: asObservable(), handler: handler) + } + + /** + Continues an observable sequence that is terminated by an error with a single element. + + - seealso: [catch operator on reactivex.io](http://reactivex.io/documentation/operators/catch.html) + + - parameter element: Last element in an observable sequence in case error occurs. + - returns: An observable sequence containing the source sequence's elements, followed by the `element` in case an error occurred. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func catchErrorJustReturn(_ element: E) + -> Observable { + return Catch(source: asObservable(), handler: { _ in Observable.just(element) }) + } + +} + +extension Observable { + /** + Continues an observable sequence that is terminated by an error with the next observable sequence. + + - seealso: [catch operator on reactivex.io](http://reactivex.io/documentation/operators/catch.html) + + - returns: An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func catchError(_ sequence: S) -> Observable + where S.Iterator.Element == Observable { + return CatchSequence(sources: sequence) + } +} + +extension Sequence where Iterator.Element : ObservableType { + /** + Continues an observable sequence that is terminated by an error with the next observable sequence. + + - seealso: [catch operator on reactivex.io](http://reactivex.io/documentation/operators/catch.html) + + - returns: An observable sequence containing elements from consecutive source sequences until a source sequence terminates successfully. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "Observable.catchError()") + public func catchError() + -> Observable { + return CatchSequence(sources: self) + } +} + +// MARK: takeUntil + +extension ObservableType { + + /** + Returns the elements from the source observable sequence until the other observable sequence produces an element. + + - seealso: [takeUntil operator on reactivex.io](http://reactivex.io/documentation/operators/takeuntil.html) + + - parameter other: Observable sequence that terminates propagation of elements of the source sequence. + - returns: An observable sequence containing the elements of the source sequence up to the point the other sequence interrupted further propagation. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func takeUntil(_ other: O) + -> Observable { + return TakeUntil(source: asObservable(), other: other.asObservable()) + } +} + +// MARK: skipUntil + +extension ObservableType { + + /** + Returns the elements from the source observable sequence that are emitted after the other observable sequence produces an element. + + - seealso: [skipUntil operator on reactivex.io](http://reactivex.io/documentation/operators/skipuntil.html) + + - parameter other: Observable sequence that starts propagation of elements of the source sequence. + - returns: An observable sequence containing the elements of the source sequence that are emitted after the other sequence emits an item. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func skipUntil(_ other: O) + -> Observable { + return SkipUntil(source: asObservable(), other: other.asObservable()) + } +} + +// MARK: amb + +extension ObservableType { + + /** + Propagates the observable sequence that reacts first. + + - seealso: [amb operator on reactivex.io](http://reactivex.io/documentation/operators/amb.html) + + - parameter right: Second observable sequence. + - returns: An observable sequence that surfaces either of the given sequences, whichever reacted first. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func amb + (_ right: O2) + -> Observable where O2.E == E { + return Amb(left: asObservable(), right: right.asObservable()) + } +} + +extension Observable { + /** + Propagates the observable sequence that reacts first. + + - seealso: [amb operator on reactivex.io](http://reactivex.io/documentation/operators/amb.html) + + - returns: An observable sequence that surfaces any of the given sequences, whichever reacted first. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func amb(_ sequence: S) -> Observable + where S.Iterator.Element == Observable { + return sequence.reduce(Observable.never()) { a, o in + return a.amb(o.asObservable()) + } + } +} + +extension Sequence where Iterator.Element : ObservableType { + + /** + Propagates the observable sequence that reacts first. + + - seealso: [amb operator on reactivex.io](http://reactivex.io/documentation/operators/amb.html) + + - returns: An observable sequence that surfaces any of the given sequences, whichever reacted first. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "Observable.amb()") + public func amb() + -> Observable { + return self.reduce(Observable.never()) { a, o in + return a.amb(o.asObservable()) + } + } +} + +// withLatestFrom + +extension ObservableType { + + /** + Merges two observable sequences into one observable sequence by combining each element from self with the latest element from the second source, if any. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter second: Second observable source. + - parameter resultSelector: Function to invoke for each element from the self combined with the latest element from the second source, if any. + - returns: An observable sequence containing the result of combining each element of the self with the latest element from the second source, if any, using the specified result selector function. + */ + public func withLatestFrom(_ second: SecondO, resultSelector: @escaping (E, SecondO.E) throws -> ResultType) -> Observable { + return WithLatestFrom(first: asObservable(), second: second.asObservable(), resultSelector: resultSelector) + } + + /** + Merges two observable sequences into one observable sequence by using latest element from the second sequence every time when `self` emitts an element. + + - seealso: [combineLatest operator on reactivex.io](http://reactivex.io/documentation/operators/combinelatest.html) + + - parameter second: Second observable source. + - returns: An observable sequence containing the result of combining each element of the self with the latest element from the second source, if any, using the specified result selector function. + */ + public func withLatestFrom(_ second: SecondO) -> Observable { + return WithLatestFrom(first: asObservable(), second: second.asObservable(), resultSelector: { $1 }) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift b/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift new file mode 100644 index 0000000..17aa334 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+Single.swift @@ -0,0 +1,294 @@ +// +// Observable+Single.swift +// Rx +// +// Created by Krunoslav Zaher on 2/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: distinct until changed + +extension ObservableType where E: Equatable { + + /** + Returns an observable sequence that contains only distinct contiguous elements according to equality operator. + + - seealso: [distinct operator on reactivex.io](http://reactivex.io/documentation/operators/distinct.html) + + - returns: An observable sequence only containing the distinct contiguous elements, based on equality operator, from the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func distinctUntilChanged() + -> Observable { + return self.distinctUntilChanged({ $0 }, comparer: { ($0 == $1) }) + } +} + +extension ObservableType { + /** + Returns an observable sequence that contains only distinct contiguous elements according to the `keySelector`. + + - seealso: [distinct operator on reactivex.io](http://reactivex.io/documentation/operators/distinct.html) + + - parameter keySelector: A function to compute the comparison key for each element. + - returns: An observable sequence only containing the distinct contiguous elements, based on a computed key value, from the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func distinctUntilChanged(_ keySelector: @escaping (E) throws -> K) + -> Observable { + return self.distinctUntilChanged(keySelector, comparer: { $0 == $1 }) + } + + /** + Returns an observable sequence that contains only distinct contiguous elements according to the `comparer`. + + - seealso: [distinct operator on reactivex.io](http://reactivex.io/documentation/operators/distinct.html) + + - parameter comparer: Equality comparer for computed key values. + - returns: An observable sequence only containing the distinct contiguous elements, based on `comparer`, from the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func distinctUntilChanged(_ comparer: @escaping (E, E) throws -> Bool) + -> Observable { + return self.distinctUntilChanged({ $0 }, comparer: comparer) + } + + /** + Returns an observable sequence that contains only distinct contiguous elements according to the keySelector and the comparer. + + - seealso: [distinct operator on reactivex.io](http://reactivex.io/documentation/operators/distinct.html) + + - parameter keySelector: A function to compute the comparison key for each element. + - parameter comparer: Equality comparer for computed key values. + - returns: An observable sequence only containing the distinct contiguous elements, based on a computed key value and the comparer, from the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func distinctUntilChanged(_ keySelector: @escaping (E) throws -> K, comparer: @escaping (K, K) throws -> Bool) + -> Observable { + return DistinctUntilChanged(source: self.asObservable(), selector: keySelector, comparer: comparer) + } +} + +// MARK: doOn + +extension ObservableType { + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) + + - parameter eventHandler: Action to invoke for each event in the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") + public func doOn(_ eventHandler: @escaping (Event) throws -> Void) + -> Observable { + return Do(source: self.asObservable(), eventHandler: eventHandler, onSubscribe: nil, onDispose: nil) + } + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - parameter onSubscribe: Action to invoke before subscribing to source observable sequence. + - parameter onDispose: Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") + public func doOn(onNext: ((E) throws -> Void)? = nil, onError: ((Swift.Error) throws -> Void)? = nil, onCompleted: (() throws -> Void)? = nil) + -> Observable { + return Do(source: self.asObservable(), eventHandler: { e in + switch e { + case .next(let element): + try onNext?(element) + case .error(let e): + try onError?(e) + case .completed: + try onCompleted?() + } + }, + onSubscribe: nil, + onDispose: nil) + } + + /** + Invokes an action for each Next event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onNext:)") + public func doOnNext(onNext: @escaping (E) throws -> Void) + -> Observable { + return self.do(onNext: onNext) + } + + /** + Invokes an action for the Error event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onError:)") + public func doOnError(onError: @escaping (Swift.Error) throws -> Void) + -> Observable { + return self.do(onError: onError) + } + + /** + Invokes an action for the Completed event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onCompleted:)") + public func doOnCompleted(onCompleted: @escaping () throws -> Void) + -> Observable { + return self.do(onCompleted: onCompleted) + } + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - parameter onSubscribe: Action to invoke before subscribing to source observable sequence. + - parameter onDispose: Action to invoke after subscription to source observable has been disposed for any reason. It can be either because sequence terminates for some reason or observer subscription being disposed. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func `do`(onNext: ((E) throws -> Void)? = nil, onError: ((Swift.Error) throws -> Void)? = nil, onCompleted: (() throws -> Void)? = nil, onSubscribe: (() -> ())? = nil, onDispose: (() -> ())? = nil) + -> Observable { + return Do(source: self.asObservable(), eventHandler: { e in + switch e { + case .next(let element): + try onNext?(element) + case .error(let e): + try onError?(e) + case .completed: + try onCompleted?() + } + }, onSubscribe: onSubscribe, onDispose: onDispose) + } +} + +// MARK: startWith + +extension ObservableType { + + /** + Prepends a sequence of values to an observable sequence. + + - seealso: [startWith operator on reactivex.io](http://reactivex.io/documentation/operators/startwith.html) + + - parameter elements: Elements to prepend to the specified sequence. + - returns: The source sequence prepended with the specified values. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func startWith(_ elements: E ...) + -> Observable { + return StartWith(source: self.asObservable(), elements: elements) + } +} + +// MARK: retry + +extension ObservableType { + + /** + Repeats the source observable sequence until it successfully terminates. + + **This could potentially create an infinite sequence.** + + - seealso: [retry operator on reactivex.io](http://reactivex.io/documentation/operators/retry.html) + + - returns: Observable sequence to repeat until it successfully terminates. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func retry() -> Observable { + return CatchSequence(sources: InfiniteSequence(repeatedValue: self.asObservable())) + } + + /** + Repeats the source observable sequence the specified number of times in case of an error or until it successfully terminates. + + If you encounter an error and want it to retry once, then you must use `retry(2)` + + - seealso: [retry operator on reactivex.io](http://reactivex.io/documentation/operators/retry.html) + + - parameter maxAttemptCount: Maximum number of times to repeat the sequence. + - returns: An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func retry(_ maxAttemptCount: Int) + -> Observable { + return CatchSequence(sources: repeatElement(self.asObservable(), count: maxAttemptCount)) + } + + /** + Repeats the source observable sequence on error when the notifier emits a next value. + If the source observable errors and the notifier completes, it will complete the source sequence. + + - seealso: [retry operator on reactivex.io](http://reactivex.io/documentation/operators/retry.html) + + - parameter notificationHandler: A handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable. + - returns: An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func retryWhen(_ notificationHandler: @escaping (Observable) -> TriggerObservable) + -> Observable { + return RetryWhenSequence(sources: InfiniteSequence(repeatedValue: self.asObservable()), notificationHandler: notificationHandler) + } + + /** + Repeats the source observable sequence on error when the notifier emits a next value. + If the source observable errors and the notifier completes, it will complete the source sequence. + + - seealso: [retry operator on reactivex.io](http://reactivex.io/documentation/operators/retry.html) + + - parameter notificationHandler: A handler that is passed an observable sequence of errors raised by the source observable and returns and observable that either continues, completes or errors. This behavior is then applied to the source observable. + - returns: An observable sequence producing the elements of the given sequence repeatedly until it terminates successfully or is notified to error or complete. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func retryWhen(_ notificationHandler: @escaping (Observable) -> TriggerObservable) + -> Observable { + return RetryWhenSequence(sources: InfiniteSequence(repeatedValue: self.asObservable()), notificationHandler: notificationHandler) + } +} + +// MARK: scan + +extension ObservableType { + + /** + Applies an accumulator function over an observable sequence and returns each intermediate result. The specified seed value is used as the initial accumulator value. + + For aggregation behavior with no intermediate results, see `reduce`. + + - seealso: [scan operator on reactivex.io](http://reactivex.io/documentation/operators/scan.html) + + - parameter seed: The initial accumulator value. + - parameter accumulator: An accumulator function to be invoked on each element. + - returns: An observable sequence containing the accumulated values. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func scan(_ seed: A, accumulator: @escaping (A, E) throws -> A) + -> Observable { + return Scan(source: self.asObservable(), seed: seed, accumulator: accumulator) + } +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift b/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift new file mode 100644 index 0000000..6c5db5f --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+StandardSequenceOperators.swift @@ -0,0 +1,323 @@ +// +// Observable+StandardSequenceOperators.swift +// Rx +// +// Created by Krunoslav Zaher on 2/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: filter aka where + +extension ObservableType { + + /** + Filters the elements of an observable sequence based on a predicate. + + - seealso: [filter operator on reactivex.io](http://reactivex.io/documentation/operators/filter.html) + + - parameter predicate: A function to test each source element for a condition. + - returns: An observable sequence that contains elements from the input sequence that satisfy the condition. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func filter(_ predicate: @escaping (E) throws -> Bool) + -> Observable { + return Filter(source: asObservable(), predicate: predicate) + } +} + +// MARK: takeWhile + +extension ObservableType { + + /** + Returns elements from an observable sequence as long as a specified condition is true. + + - seealso: [takeWhile operator on reactivex.io](http://reactivex.io/documentation/operators/takewhile.html) + + - parameter predicate: A function to test each element for a condition. + - returns: An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func takeWhile(_ predicate: @escaping (E) throws -> Bool) + -> Observable { + return TakeWhile(source: asObservable(), predicate: predicate) + } + + /** + Returns elements from an observable sequence as long as a specified condition is true. + + The element's index is used in the logic of the predicate function. + + - seealso: [takeWhile operator on reactivex.io](http://reactivex.io/documentation/operators/takewhile.html) + + - parameter predicate: A function to test each element for a condition; the second parameter of the function represents the index of the source element. + - returns: An observable sequence that contains the elements from the input sequence that occur before the element at which the test no longer passes. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func takeWhileWithIndex(_ predicate: @escaping (E, Int) throws -> Bool) + -> Observable { + return TakeWhile(source: asObservable(), predicate: predicate) + } +} + +// MARK: take + +extension ObservableType { + + /** + Returns a specified number of contiguous elements from the start of an observable sequence. + + - seealso: [take operator on reactivex.io](http://reactivex.io/documentation/operators/take.html) + + - parameter count: The number of elements to return. + - returns: An observable sequence that contains the specified number of elements from the start of the input sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func take(_ count: Int) + -> Observable { + if count == 0 { + return Observable.empty() + } + else { + return TakeCount(source: asObservable(), count: count) + } + } +} + +// MARK: takeLast + +extension ObservableType { + + /** + Returns a specified number of contiguous elements from the end of an observable sequence. + + 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. + + - seealso: [takeLast operator on reactivex.io](http://reactivex.io/documentation/operators/takelast.html) + + - parameter count: Number of elements to take from the end of the source sequence. + - returns: An observable sequence containing the specified number of elements from the end of the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func takeLast(_ count: Int) + -> Observable { + return TakeLast(source: asObservable(), count: count) + } +} + + +// MARK: skip + +extension ObservableType { + + /** + Bypasses a specified number of elements in an observable sequence and then returns the remaining elements. + + - seealso: [skip operator on reactivex.io](http://reactivex.io/documentation/operators/skip.html) + + - parameter count: The number of elements to skip before returning the remaining elements. + - returns: An observable sequence that contains the elements that occur after the specified index in the input sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func skip(_ count: Int) + -> Observable { + return SkipCount(source: asObservable(), count: count) + } +} + +// MARK: SkipWhile + +extension ObservableType { + + /** + Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. + + - seealso: [skipWhile operator on reactivex.io](http://reactivex.io/documentation/operators/skipwhile.html) + + - parameter predicate: A function to test each element for a condition. + - 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. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func skipWhile(_ predicate: @escaping (E) throws -> Bool) -> Observable { + return SkipWhile(source: asObservable(), predicate: predicate) + } + + /** + Bypasses elements in an observable sequence as long as a specified condition is true and then returns the remaining elements. + The element's index is used in the logic of the predicate function. + + - seealso: [skipWhile operator on reactivex.io](http://reactivex.io/documentation/operators/skipwhile.html) + + - parameter predicate: A function to test each element for a condition; the second parameter of the function represents the index of the source element. + - returns: An observable sequence that contains the elements from the input sequence starting at the first element in the linear series that does not pass the test specified by predicate. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func skipWhileWithIndex(_ predicate: @escaping (E, Int) throws -> Bool) -> Observable { + return SkipWhile(source: asObservable(), predicate: predicate) + } +} + +// MARK: map aka select + +extension ObservableType { + + /** + Projects each element of an observable sequence into a new form. + + - seealso: [map operator on reactivex.io](http://reactivex.io/documentation/operators/map.html) + + - parameter selector: A transform function to apply to each source element. + - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source. + + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func map(_ selector: @escaping (E) throws -> R) + -> Observable { + return self.asObservable().composeMap(selector) + } + + /** + Projects each element of an observable sequence into a new form by incorporating the element's index. + + - seealso: [map operator on reactivex.io](http://reactivex.io/documentation/operators/map.html) + + - parameter selector: A transform function to apply to each source element; the second parameter of the function represents the index of the source element. + - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func mapWithIndex(_ selector: @escaping (E, Int) throws -> R) + -> Observable { + return MapWithIndex(source: asObservable(), selector: selector) + } +} + +// MARK: flatMap + +extension ObservableType { + + /** + Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + + - seealso: [flatMap operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) + + - parameter selector: A transform function to apply to each element. + - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func flatMap(_ selector: @escaping (E) throws -> O) + -> Observable { + return FlatMap(source: asObservable(), selector: selector) + } + + /** + Projects each element of an observable sequence to an observable sequence by incorporating the element's index and merges the resulting observable sequences into one observable sequence. + + - seealso: [flatMap operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) + + - parameter selector: A transform function to apply to each element; the second parameter of the function represents the index of the source element. + - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func flatMapWithIndex(_ selector: @escaping (E, Int) throws -> O) + -> Observable { + return FlatMapWithIndex(source: asObservable(), selector: selector) + } +} + +// MARK: flatMapFirst + +extension ObservableType { + + /** + Projects each element of an observable sequence to an observable sequence and merges the resulting observable sequences into one observable sequence. + If element is received while there is some projected observable sequence being merged it will simply be ignored. + + - seealso: [flatMapFirst operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) + + - parameter selector: A transform function to apply to element that was observed while no observable is executing in parallel. + - returns: An observable sequence whose elements are the result of invoking the one-to-many transform function on each element of the input sequence that was received while no other sequence was being calculated. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func flatMapFirst(_ selector: @escaping (E) throws -> O) + -> Observable { + return FlatMapFirst(source: asObservable(), selector: selector) + } +} + +// MARK: flatMapLatest + +extension ObservableType { + /** + Projects each element of an observable sequence into a new sequence of observable sequences and then + transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence. + + It is a combination of `map` + `switchLatest` operator + + - seealso: [flatMapLatest operator on reactivex.io](http://reactivex.io/documentation/operators/flatmap.html) + + - parameter selector: A transform function to apply to each element. + - returns: An observable sequence whose elements are the result of invoking the transform function on each element of source producing an + Observable of Observable sequences and that at any point in time produces the elements of the most recent inner observable sequence that has been received. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func flatMapLatest(_ selector: @escaping (E) throws -> O) + -> Observable { + return FlatMapLatest(source: asObservable(), selector: selector) + } +} + +// MARK: elementAt + +extension ObservableType { + + /** + Returns a sequence emitting only item _n_ emitted by an Observable + + - seealso: [elementAt operator on reactivex.io](http://reactivex.io/documentation/operators/elementat.html) + + - parameter index: The index of the required item (starting from 0). + - returns: An observable sequence that emits the desired item as its own sole emission. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func elementAt(_ index: Int) + -> Observable { + return ElementAt(source: asObservable(), index: index, throwOnEmpty: true) + } +} + +// MARK: single + +extension ObservableType { + + /** + The single operator is similar to first, but throws a `RxError.NoElements` or `RxError.MoreThanOneElement` + if the source Observable does not emit exactly one item before successfully completing. + + - seealso: [single operator on reactivex.io](http://reactivex.io/documentation/operators/first.html) + + - returns: An observable sequence that emits a single item or throws an exception if more (or none) of them are emitted. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func single() + -> Observable { + return SingleAsync(source: asObservable()) + } + + /** + The single operator is similar to first, but throws a `RxError.NoElements` or `RxError.MoreThanOneElement` + if the source Observable does not emit exactly one item before successfully completing. + + - seealso: [single operator on reactivex.io](http://reactivex.io/documentation/operators/first.html) + + - parameter predicate: A function to test each source element for a condition. + - returns: An observable sequence that emits a single item or throws an exception if more (or none) of them are emitted. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func single(_ predicate: @escaping (E) throws -> Bool) + -> Observable { + return SingleAsync(source: asObservable(), predicate: predicate) + } + +} diff --git a/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift b/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift new file mode 100644 index 0000000..e975ead --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observables/Observable+Time.swift @@ -0,0 +1,293 @@ +// +// Observable+Time.swift +// Rx +// +// Created by Krunoslav Zaher on 3/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +// MARK: throttle +extension ObservableType { + + /** + Returns an Observable that emits the first and the latest item emitted by the source Observable during sequential time windows of a specified duration. + + This operator makes sure that no two elements are emitted in less then dueTime. + + - seealso: [debounce operator on reactivex.io](http://reactivex.io/documentation/operators/debounce.html) + + - parameter dueTime: Throttling duration for each element. + - parameter latest: Should latest element received in a dueTime wide time window since last element emission be emitted. + - parameter scheduler: Scheduler to run the throttle timers and send events on. + - returns: The throttled sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func throttle(_ dueTime: RxTimeInterval, latest: Bool = true, scheduler: SchedulerType) + -> Observable { + return Throttle(source: self.asObservable(), dueTime: dueTime, latest: latest, scheduler: scheduler) + } + + /** + Ignores elements from an observable sequence which are followed by another element within a specified relative time duration, using the specified scheduler to run throttling timers. + + - seealso: [debounce operator on reactivex.io](http://reactivex.io/documentation/operators/debounce.html) + + - parameter dueTime: Throttling duration for each element. + - parameter scheduler: Scheduler to run the throttle timers and send events on. + - returns: The throttled sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func debounce(_ dueTime: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return Debounce(source: self.asObservable(), dueTime: dueTime, scheduler: scheduler) + } +} + +// MARK: sample + +extension ObservableType { + + /** + Samples the source observable sequence using a sampler observable sequence producing sampling ticks. + + Upon each sampling tick, the latest element (if any) in the source sequence during the last sampling interval is sent to the resulting sequence. + + **In case there were no new elements between sampler ticks, no element is sent to the resulting sequence.** + + - seealso: [sample operator on reactivex.io](http://reactivex.io/documentation/operators/sample.html) + + - parameter sampler: Sampling tick sequence. + - returns: Sampled observable sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func sample(_ sampler: O) + -> Observable { + return Sample(source: self.asObservable(), sampler: sampler.asObservable(), onlyNew: true) + } +} + +extension Observable where Element : SignedInteger { + /** + Returns an observable sequence that produces a value after each period, using the specified scheduler to run timers and to send out observer messages. + + - seealso: [interval operator on reactivex.io](http://reactivex.io/documentation/operators/interval.html) + + - parameter period: Period for producing the values in the resulting sequence. + - parameter scheduler: Scheduler to run the timer on. + - returns: An observable sequence that produces a value after each period. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func interval(_ period: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return Timer(dueTime: period, + period: period, + scheduler: scheduler + ) + } +} + +// MARK: timer + +extension Observable where Element: SignedInteger { + /** + Returns an observable sequence that periodically produces a value after the specified initial relative due time has elapsed, using the specified scheduler to run timers. + + - seealso: [timer operator on reactivex.io](http://reactivex.io/documentation/operators/timer.html) + + - parameter dueTime: Relative time at which to produce the first value. + - parameter period: Period to produce subsequent values. + - parameter scheduler: Scheduler to run timers on. + - returns: An observable sequence that produces a value after due time has elapsed and then each period. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public static func timer(_ dueTime: RxTimeInterval, period: RxTimeInterval? = nil, scheduler: SchedulerType) + -> Observable { + return Timer( + dueTime: dueTime, + period: period, + scheduler: scheduler + ) + } +} + +// MARK: take + +extension ObservableType { + + /** + Takes elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + + - seealso: [take operator on reactivex.io](http://reactivex.io/documentation/operators/take.html) + + - parameter duration: Duration for taking elements from the start of the sequence. + - parameter scheduler: Scheduler to run the timer on. + - returns: An observable sequence with the elements taken during the specified duration from the start of the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func take(_ duration: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return TakeTime(source: self.asObservable(), duration: duration, scheduler: scheduler) + } +} + +// MARK: skip + +extension ObservableType { + + /** + Skips elements for the specified duration from the start of the observable source sequence, using the specified scheduler to run timers. + + - seealso: [skip operator on reactivex.io](http://reactivex.io/documentation/operators/skip.html) + + - parameter duration: Duration for skipping elements from the start of the sequence. + - parameter scheduler: Scheduler to run the timer on. + - returns: An observable sequence with the elements skipped during the specified duration from the start of the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func skip(_ duration: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return SkipTime(source: self.asObservable(), duration: duration, scheduler: scheduler) + } +} + +// MARK: ignoreElements + +extension ObservableType { + + /** + Skips elements and completes (or errors) when the receiver completes (or errors). Equivalent to filter that always returns false. + + - seealso: [ignoreElements operator on reactivex.io](http://reactivex.io/documentation/operators/ignoreelements.html) + + - returns: An observable sequence that skips all elements of the source sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func ignoreElements() + -> Observable { + return filter { _ -> Bool in + return false + } + } +} + +// MARK: delaySubscription + +extension ObservableType { + + /** + Time shifts the observable sequence by delaying the subscription with the specified relative time duration, using the specified scheduler to run timers. + + - seealso: [delay operator on reactivex.io](http://reactivex.io/documentation/operators/delay.html) + + - parameter dueTime: Relative time shift of the subscription. + - parameter scheduler: Scheduler to run the subscription delay timer on. + - returns: Time-shifted sequence. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func delaySubscription(_ dueTime: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return DelaySubscription(source: self.asObservable(), dueTime: dueTime, scheduler: scheduler) + } +} + +// MARK: buffer + +extension ObservableType { + + /** + Projects each element of an observable sequence into a buffer that's sent out when either it's full or a given amount of time has elapsed, using the specified scheduler to run timers. + + A useful real-world analogy of this overload is the behavior of a ferry leaving the dock when all seats are taken, or at the scheduled time of departure, whichever event occurs first. + + - seealso: [buffer operator on reactivex.io](http://reactivex.io/documentation/operators/buffer.html) + + - parameter timeSpan: Maximum time length of a buffer. + - parameter count: Maximum element count of a buffer. + - parameter scheduler: Scheduler to run buffering timers on. + - returns: An observable sequence of buffers. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func buffer(timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) + -> Observable<[E]> { + return BufferTimeCount(source: self.asObservable(), timeSpan: timeSpan, count: count, scheduler: scheduler) + } +} + +// MARK: window + +extension ObservableType { + + /** + Projects each element of an observable sequence into a window that is completed when either it’s full or a given amount of time has elapsed. + + - seealso: [window operator on reactivex.io](http://reactivex.io/documentation/operators/window.html) + + - parameter timeSpan: Maximum time length of a window. + - parameter count: Maximum element count of a window. + - parameter scheduler: Scheduler to run windowing timers on. + - returns: An observable sequence of windows (instances of `Observable`). + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func window(timeSpan: RxTimeInterval, count: Int, scheduler: SchedulerType) + -> Observable> { + return WindowTimeCount(source: self.asObservable(), timeSpan: timeSpan, count: count, scheduler: scheduler) + } +} + +// MARK: timeout + +extension ObservableType { + + /** + Applies a timeout policy for each element in the observable sequence. If the next element isn't received within the specified timeout duration starting from its predecessor, a TimeoutError is propagated to the observer. + + - seealso: [timeout operator on reactivex.io](http://reactivex.io/documentation/operators/timeout.html) + + - parameter dueTime: Maximum duration between values before a timeout occurs. + - parameter scheduler: Scheduler to run the timeout timer on. + - returns: An observable sequence with a TimeoutError in case of a timeout. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func timeout(_ dueTime: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return Timeout(source: self.asObservable(), dueTime: dueTime, other: Observable.error(RxError.timeout), scheduler: scheduler) + } + + /** + Applies a timeout policy for each element in the observable sequence, using the specified scheduler to run timeout timers. If the next element isn't received within the specified timeout duration starting from its predecessor, the other observable sequence is used to produce future messages from that point on. + + - seealso: [timeout operator on reactivex.io](http://reactivex.io/documentation/operators/timeout.html) + + - parameter dueTime: Maximum duration between values before a timeout occurs. + - parameter other: Sequence to return in case of a timeout. + - parameter scheduler: Scheduler to run the timeout timer on. + - returns: The source sequence switching to the other sequence in case of a timeout. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func timeout(_ dueTime: RxTimeInterval, other: O, scheduler: SchedulerType) + -> Observable where E == O.E { + return Timeout(source: self.asObservable(), dueTime: dueTime, other: other.asObservable(), scheduler: scheduler) + } +} + +// MARK: delay + +extension ObservableType { + + /** + Returns an observable sequence by the source observable sequence shifted forward in time by a specified delay. Error events from the source observable sequence are not delayed. + + - seealso: [delay operator on reactivex.io](http://reactivex.io/documentation/operators/delay.html) + + - parameter dueTime: Relative time shift of the source by. + - parameter scheduler: Scheduler to run the subscription delay timer on. + - returns: the source Observable shifted in time by the specified delay. + */ + // @warn_unused_result(message="http://git.io/rxs.uo") + public func delay(_ dueTime: RxTimeInterval, scheduler: SchedulerType) + -> Observable { + return Delay(source: self.asObservable(), dueTime: dueTime, scheduler: scheduler) + } +} diff --git a/Pods/RxSwift/RxSwift/ObserverType.swift b/Pods/RxSwift/RxSwift/ObserverType.swift new file mode 100644 index 0000000..b604e63 --- /dev/null +++ b/Pods/RxSwift/RxSwift/ObserverType.swift @@ -0,0 +1,56 @@ +// +// ObserverType.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Supports push-style iteration over an observable sequence. +*/ +public protocol ObserverType { + /** + The type of elements in sequence that observer can observe. + */ + associatedtype E + + /** + Notify observer about sequence event. + + - parameter event: Event that occured. + */ + func on(_ event: Event) +} + +/** +Convenience API extensions to provide alternate next, error, completed events +*/ +public extension ObserverType { + + /** + Convenience method equivalent to `on(.next(element: E))` + + - parameter element: Next element to send to observer(s) + */ + final func onNext(_ element: E) { + on(.next(element)) + } + + /** + Convenience method equivalent to `on(.completed)` + */ + final func onCompleted() { + on(.completed) + } + + /** + Convenience method equivalent to `on(.error(Swift.Error))` + - parameter error: Swift.Error to send to observer(s) + */ + final func onError(_ error: Swift.Error) { + on(.error(error)) + } +} diff --git a/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift b/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift new file mode 100644 index 0000000..72376e4 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift @@ -0,0 +1,34 @@ +// +// AnonymousObserver.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class AnonymousObserver : ObserverBase { + typealias Element = ElementType + + typealias EventHandler = (Event) -> Void + + private let _eventHandler : EventHandler + + init(_ eventHandler: @escaping EventHandler) { +#if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) +#endif + _eventHandler = eventHandler + } + + override func onCore(_ event: Event) { + return _eventHandler(event) + } + +#if TRACE_RESOURCES + deinit { + let _ = AtomicDecrement(&resourceCount) + } +#endif +} diff --git a/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift b/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift new file mode 100644 index 0000000..4ff3fe0 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observers/ObserverBase.swift @@ -0,0 +1,39 @@ +// +// ObserverBase.swift +// Rx +// +// Created by Krunoslav Zaher on 2/15/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +class ObserverBase : Disposable, ObserverType { + typealias E = ElementType + + private var _isStopped: AtomicInt = 0 + + func on(_ event: Event) { + switch event { + case .next: + if _isStopped == 0 { + onCore(event) + } + case .error, .completed: + + if !AtomicCompareAndSwap(0, 1, &_isStopped) { + return + } + + onCore(event) + } + } + + func onCore(_ event: Event) { + abstractMethod() + } + + func dispose() { + _isStopped = 1 + } +} diff --git a/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift b/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift new file mode 100644 index 0000000..d58be82 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Observers/TailRecursiveSink.swift @@ -0,0 +1,152 @@ +// +// TailRecursiveSink.swift +// Rx +// +// Created by Krunoslav Zaher on 3/21/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +enum TailRecursiveSinkCommand { + case moveNext + case dispose +} + +#if DEBUG || TRACE_RESOURCES + public var maxTailRecursiveSinkStackSize = 0 +#endif + +/// This class is usually used with `Generator` version of the operators. +class TailRecursiveSink + : Sink + , InvocableWithValueType where S.Iterator.Element: ObservableConvertibleType, S.Iterator.Element.E == O.E { + typealias Value = TailRecursiveSinkCommand + typealias E = O.E + typealias SequenceGenerator = (generator: S.Iterator, remaining: IntMax?) + + var _generators: [SequenceGenerator] = [] + var _isDisposed = false + var _subscription = SerialDisposable() + + // this is thread safe object + var _gate = AsyncLock>>() + + override init(observer: O, cancel: Cancelable) { + super.init(observer: observer, cancel: cancel) + } + + func run(_ sources: SequenceGenerator) -> Disposable { + _generators.append(sources) + + schedule(.moveNext) + + return _subscription + } + + func invoke(_ command: TailRecursiveSinkCommand) { + switch command { + case .dispose: + disposeCommand() + case .moveNext: + moveNextCommand() + } + } + + // simple implementation for now + func schedule(_ command: TailRecursiveSinkCommand) { + _gate.invoke(InvocableScheduledItem(invocable: self, state: command)) + } + + func done() { + forwardOn(.completed) + dispose() + } + + func extract(_ observable: Observable) -> SequenceGenerator? { + abstractMethod() + } + + // should be done on gate locked + + private func moveNextCommand() { + var next: Observable? = nil + + repeat { + guard let (g, left) = _generators.last else { + break + } + + if _isDisposed { + return + } + + _generators.removeLast() + + var e = g + + guard let nextCandidate = e.next()?.asObservable() else { + continue + } + + // `left` is a hint of how many elements are left in generator. + // In case this is the last element, then there is no need to push + // that generator on stack. + // + // This is an optimization used to make sure in tail recursive case + // there is no memory leak in case this operator is used to generate non terminating + // sequence. + + if let knownOriginalLeft = left { + // `- 1` because generator.next() has just been called + if knownOriginalLeft - 1 >= 1 { + _generators.append((e, knownOriginalLeft - 1)) + } + } + else { + _generators.append((e, nil)) + } + + let nextGenerator = extract(nextCandidate) + + if let nextGenerator = nextGenerator { + _generators.append(nextGenerator) + #if DEBUG || TRACE_RESOURCES + if maxTailRecursiveSinkStackSize < _generators.count { + maxTailRecursiveSinkStackSize = _generators.count + } + #endif + } + else { + next = nextCandidate + } + } while next == nil + + if next == nil { + done() + return + } + + let disposable = SingleAssignmentDisposable() + _subscription.disposable = disposable + disposable.setDisposable(subscribeToNext(next!)) + } + + func subscribeToNext(_ source: Observable) -> Disposable { + abstractMethod() + } + + func disposeCommand() { + _isDisposed = true + _generators.removeAll(keepingCapacity: false) + } + + override func dispose() { + super.dispose() + + _subscription.dispose() + + schedule(.dispose) + } +} + diff --git a/Pods/RxSwift/RxSwift/Platform/Platform.Darwin.swift b/Pods/RxSwift/RxSwift/Platform/Platform.Darwin.swift new file mode 100644 index 0000000..9c0b3f9 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Platform/Platform.Darwin.swift @@ -0,0 +1,46 @@ +// +// Platform.Darwin.swift +// Rx +// +// Created by Krunoslav Zaher on 12/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(OSX) || os(iOS) || os(tvOS) || os(watchOS) + + import Darwin + import Foundation + + #if TRACE_RESOURCES + public typealias AtomicInt = Int32 + #else + typealias AtomicInt = Int32 + #endif + + let AtomicCompareAndSwap = OSAtomicCompareAndSwap32 + let AtomicIncrement = OSAtomicIncrement32 + let AtomicDecrement = OSAtomicDecrement32 + + extension Thread { + static func setThreadLocalStorageValue(_ value: T?, forKey key: AnyObject & NSCopying + ) { + let currentThread = Thread.current + let threadDictionary = currentThread.threadDictionary + + if let newValue = value { + threadDictionary.setObject(newValue, forKey: key) + } + else { + threadDictionary.removeObject(forKey: key) + } + + } + static func getThreadLocalStorageValueForKey(_ key: AnyObject & NSCopying) -> T? { + let currentThread = Thread.current + let threadDictionary = currentThread.threadDictionary + + return threadDictionary[key] as? T + } + } + +#endif diff --git a/Pods/RxSwift/RxSwift/Platform/Platform.Linux.swift b/Pods/RxSwift/RxSwift/Platform/Platform.Linux.swift new file mode 100644 index 0000000..ff7c043 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Platform/Platform.Linux.swift @@ -0,0 +1,222 @@ +// +// Platform.Linux.swift +// Rx +// +// Created by Krunoslav Zaher on 12/29/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +#if os(Linux) + //////////////////////////////////////////////////////////////////////////////// + // This is not the greatest API in the world, this is just a tribute. + // !!! Proof of concept until libdispatch becomes operational. !!! + //////////////////////////////////////////////////////////////////////////////// + + import Foundation + import XCTest + import Glibc + import SwiftShims + + // MARK: CoreFoundation run loop mock + + public typealias CFRunLoopRef = Int + public let kCFRunLoopDefaultMode = "CFRunLoopDefaultMode" + + typealias Action = () -> () + + var queue = Queue(capacity: 100) + + var runLoopCounter = 0 + + extension NSThread { + public var isMainThread: Bool { + return true + } + } + + public func CFRunLoopWakeUp(_ runLoop: CFRunLoopRef) { + } + + public func CFRunLoopStop(_ runLoop: CFRunLoopRef) { + runLoopCounter -= 1 + } + + public func CFRunLoopPerformBlock(_ runLoop: CFRunLoopRef, _ mode: String, _ action: () -> ()) { + queue.enqueue(element: action) + } + + public func CFRunLoopRun() { + runLoopCounter += 1 + let currentValueOfCounter = runLoopCounter + while let front = queue.dequeue() { + front() + if runLoopCounter < currentValueOfCounter - 1 { + fatalError("called stop twice") + } + + if runLoopCounter == currentValueOfCounter - 1 { + break + } + } + } + + public func CFRunLoopGetCurrent() -> CFRunLoopRef { + return 0 + } + + // MARK: Atomic, just something that works for single thread case + + #if TRACE_RESOURCES + public typealias AtomicInt = Int64 + #else + typealias AtomicInt = Int64 + #endif + + func AtomicIncrement(_ increment: UnsafeMutablePointer) -> AtomicInt { + increment.memory = increment.memory + 1 + return increment.memory + } + + func AtomicDecrement(_ increment: UnsafeMutablePointer) -> AtomicInt { + increment.memory = increment.memory - 1 + return increment.memory + } + + func AtomicCompareAndSwap(_ l: AtomicInt, _ r: AtomicInt, _ target: UnsafeMutablePointer) -> Bool { + //return __sync_val_compare_and_swap(target, l, r) + if target.memory == l { + target.memory = r + return true + } + + return false + } + + extension NSThread { + static func setThreadLocalStorageValue(value: T?, forKey key: String) { + let currentThread = NSThread.currentThread() + var threadDictionary = currentThread.threadDictionary + + if let newValue = value { + threadDictionary[key] = newValue + } + else { + threadDictionary[key] = nil + } + + currentThread.threadDictionary = threadDictionary + } + + static func getThreadLocalStorageValueForKey(key: String) -> T? { + let currentThread = NSThread.currentThread() + let threadDictionary = currentThread.threadDictionary + + return threadDictionary[key] as? T + } + } + + // + + // MARK: objc mock + + public func objc_sync_enter(_ lock: AnyObject) { + } + + public func objc_sync_exit(_ lock: AnyObject) { + + } + + + // MARK: libdispatch + + public typealias dispatch_time_t = Int + public typealias dispatch_source_t = Int + public typealias dispatch_source_type_t = Int + public typealias dispatch_queue_t = Int + public typealias dispatch_object_t = Int + public typealias dispatch_block_t = () -> () + public typealias dispatch_queue_attr_t = Int + public typealias qos_class_t = Int + + public let DISPATCH_QUEUE_SERIAL = 0 + + public let DISPATCH_QUEUE_PRIORITY_HIGH = 1 + public let DISPATCH_QUEUE_PRIORITY_DEFAULT = 2 + public let DISPATCH_QUEUE_PRIORITY_LOW = 3 + + public let QOS_CLASS_USER_INTERACTIVE = 0 + public let QOS_CLASS_USER_INITIATED = 1 + public let QOS_CLASS_DEFAULT = 2 + public let QOS_CLASS_UTILITY = 3 + public let QOS_CLASS_BACKGROUND = 4 + + public let DISPATCH_SOURCE_TYPE_TIMER = 0 + public let DISPATCH_TIME_FOREVER = 1 as UInt64 + public let NSEC_PER_SEC = 1 + + public let DISPATCH_TIME_NOW = -1 + + public func dispatch_time(_ when: dispatch_time_t, _ delta: Int64) -> dispatch_time_t { + return when + Int(delta) + } + + public func dispatch_queue_create(_ label: UnsafePointer, _ attr: dispatch_queue_attr_t!) -> dispatch_queue_t! { + return 0 + } + + public func dispatch_set_target_queue(_ object: dispatch_object_t!, _ queue: dispatch_queue_t!) { + } + + public func dispatch_async(_ queue2: dispatch_queue_t, _ block: dispatch_block_t) { + queue.enqueue(block) + } + + public func dispatch_source_create(_ type: dispatch_source_type_t, _ handle: UInt, _ mask: UInt, _ queue: dispatch_queue_t!) -> dispatch_source_t! { + return 0 + } + + public func dispatch_source_set_timer(_ source: dispatch_source_t, _ start: dispatch_time_t, _ interval: UInt64, _ leeway: UInt64) { + + } + + public func dispatch_source_set_event_handler(_ source: dispatch_source_t, _ handler: dispatch_block_t!) { + queue.enqueue(handler) + } + + public func dispatch_resume(_ object: dispatch_object_t) { + } + + public func dispatch_source_cancel(_ source: dispatch_source_t) { + } + + public func dispatch_get_global_queue(_ identifier: Int, _ flags: UInt) -> dispatch_queue_t! { + return 0 + } + + public func dispatch_get_main_queue() -> dispatch_queue_t! { + return 0 + } + + // MARK: XCTest + + public class Expectation { + public func fulfill() { + } + } + + extension XCTestCase { + public func setUp() { + } + + public func tearDown() { + } + + public func expectationWithDescription(description: String) -> Expectation { + return Expectation() + } + + public func waitForExpectationsWithTimeout(time: NSTimeInterval, action: Swift.Error? -> Void) { + } + } + +#endif diff --git a/Pods/RxSwift/RxSwift/Reactive.swift b/Pods/RxSwift/RxSwift/Reactive.swift new file mode 100644 index 0000000..7b8706d --- /dev/null +++ b/Pods/RxSwift/RxSwift/Reactive.swift @@ -0,0 +1,78 @@ +// +// Reactive.swift +// Rx +// +// Created by Yury Korolev on 5/2/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +/** + Use `Reactive` proxy as customization point for constrained protocol extensions. + + General pattern would be: + + // 1. Extend Reactive protocol with constrain on Base + // Read as: Reactive Extension where Base is a SomeType + extension Reactive where Base: SomeType { + // 2. Put any specific reactive extension for SomeType here + } + + With this approach we can have more specialized methods and properties using + `Base` and not just specialized on common base type. + + */ + +public struct Reactive { + /** + Base object to extend. + */ + public let base: Base + + /** + Creates extensions with base object. + + - parameter base: Base object. + */ + public init(_ base: Base) { + self.base = base + } +} + +/** + A type that has reactive extensions. + */ +public protocol ReactiveCompatible { + associatedtype CompatibleType + + /** + Reactive extensions. + */ + static var rx: Reactive.Type { get } + + /** + Reactive extensions. + */ + var rx: Reactive { get } +} + +public extension ReactiveCompatible { + /** + Reactive extensions. + */ + public static var rx: Reactive.Type { + return Reactive.self + } + + /** + Reactive extensions. + */ + public var rx: Reactive { + return Reactive(self) + } +} + +import Foundation +/** + Extend NSObject with `rx` proxy. +*/ +extension NSObject: ReactiveCompatible { } diff --git a/Pods/RxSwift/RxSwift/Rx.swift b/Pods/RxSwift/RxSwift/Rx.swift new file mode 100644 index 0000000..1b11ffd --- /dev/null +++ b/Pods/RxSwift/RxSwift/Rx.swift @@ -0,0 +1,42 @@ +// +// Rx.swift +// Rx +// +// Created by Krunoslav Zaher on 2/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if TRACE_RESOURCES +/// Counts internal Rx resource allocations (Observables, Observers, Disposables, etc.). This provides a simple way to detect leaks during development. +public var resourceCount: AtomicInt = 0 +#endif + +/// Swift does not implement abstract methods. This method is used as a runtime check to ensure that methods which intended to be abstract (i.e., they should be implemented in subclasses) are not called directly on the superclass. +func abstractMethod() -> Swift.Never { + rxFatalError("Abstract method") +} + +func rxFatalError(_ lastMessage: String) -> Swift.Never { + // The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours. + fatalError(lastMessage) +} + +func incrementChecked(_ i: inout Int) throws -> Int { + if i == Int.max { + throw RxError.overflow + } + let result = i + i += 1 + return result +} + +func decrementChecked(_ i: inout Int) throws -> Int { + if i == Int.min { + throw RxError.overflow + } + let result = i + i -= 1 + return result +} diff --git a/Pods/RxSwift/RxSwift/RxMutableBox.swift b/Pods/RxSwift/RxSwift/RxMutableBox.swift new file mode 100644 index 0000000..83ff9f7 --- /dev/null +++ b/Pods/RxSwift/RxSwift/RxMutableBox.swift @@ -0,0 +1,37 @@ +// +// RxMutableBox.swift +// RxSwift +// +// Created by Krunoslav Zaher on 5/22/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Creates mutable reference wrapper for any type. +*/ +class RxMutableBox : CustomDebugStringConvertible { + /** + Wrapped value + */ + var value : T + + /** + Creates reference wrapper for `value`. + + - parameter value: Value to wrap. + */ + init (_ value: T) { + self.value = value + } +} + +extension RxMutableBox { + /** + - returns: Box description. + */ + var debugDescription: String { + return "MutatingBox(\(self.value))" + } +} diff --git a/Pods/RxSwift/RxSwift/SchedulerType.swift b/Pods/RxSwift/RxSwift/SchedulerType.swift new file mode 100644 index 0000000..ba92ff1 --- /dev/null +++ b/Pods/RxSwift/RxSwift/SchedulerType.swift @@ -0,0 +1,78 @@ +// +// SchedulerType.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Type that represents time interval in the context of RxSwift. +*/ +public typealias RxTimeInterval = TimeInterval + +/** +Type that represents absolute time in the context of RxSwift. +*/ +public typealias RxTime = Date + +/** +Represents an object that schedules units of work. +*/ +public protocol SchedulerType: ImmediateSchedulerType { + + /** + - returns: Current time. + */ + var now : RxTime { + get + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + func scheduleRelative(_ state: StateType, dueTime: RxTimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable + + /** + Schedules a periodic piece of work. + + - parameter state: State passed to the action to be executed. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + func schedulePeriodic(_ state: StateType, startAfter: RxTimeInterval, period: RxTimeInterval, action: @escaping (StateType) -> StateType) -> Disposable +} + +extension SchedulerType { + + /** + Periodic task will be emulated using recursive scheduling. + + - parameter state: Initial state passed to the action upon the first iteration. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - returns: The disposable object used to cancel the scheduled recurring action (best effort). + */ + public func schedulePeriodic(_ state: StateType, startAfter: RxTimeInterval, period: RxTimeInterval, action: @escaping (StateType) -> StateType) -> Disposable { + let schedule = SchedulePeriodicRecursive(scheduler: self, startAfter: startAfter, period: period, action: action, state: state) + + return schedule.start() + } + + func scheduleRecursive(_ state: State, dueTime: RxTimeInterval, action: @escaping (State, AnyRecursiveScheduler) -> ()) -> Disposable { + let scheduler = AnyRecursiveScheduler(scheduler: self, action: action) + + scheduler.schedule(state, dueTime: dueTime) + + return Disposables.create(with: scheduler.dispose) + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift new file mode 100644 index 0000000..56da6e0 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift @@ -0,0 +1,87 @@ +// +// ConcurrentDispatchQueueScheduler.swift +// RxSwift +// +// Created by Krunoslav Zaher on 7/5/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +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. + +This scheduler is suitable when some work needs to be performed in background. +*/ +public class ConcurrentDispatchQueueScheduler: SchedulerType { + public typealias TimeInterval = Foundation.TimeInterval + public typealias Time = Date + + public var now : Date { + return Date() + } + + let configuration: DispatchQueueConfiguration + + /** + Constructs new `ConcurrentDispatchQueueScheduler` that wraps `queue`. + + - parameter queue: Target dispatch queue. + */ + public init(queue: DispatchQueue, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0)) { + configuration = DispatchQueueConfiguration(queue: queue, leeway: leeway) + } + + /** + Convenience init for scheduler that wraps one of the global concurrent dispatch queues. + + - parameter globalConcurrentQueueQOS: Target global dispatch queue, by quality of service class. + */ + @available(iOS 8, OSX 10.10, *) + public convenience init(globalConcurrentQueueQOS: DispatchQueueSchedulerQOS, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0)) { + let priority = globalConcurrentQueueQOS.qos + self.init(queue: DispatchQueue( + label: "rxswift.queue.\(globalConcurrentQueueQOS)", + qos: priority, + attributes: [DispatchQueue.Attributes.concurrent], + target: nil), + leeway: leeway + ) + } + + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + return self.configuration.schedule(state, action: action) + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func scheduleRelative(_ state: StateType, dueTime: Foundation.TimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable { + return self.configuration.scheduleRelative(state, dueTime: dueTime, action: action) + } + + /** + Schedules a periodic piece of work. + + - parameter state: State passed to the action to be executed. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedulePeriodic(_ state: StateType, startAfter: TimeInterval, period: TimeInterval, action: @escaping (StateType) -> StateType) -> Disposable { + return self.configuration.schedulePeriodic(state, startAfter: startAfter, period: period, action: action) + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift new file mode 100644 index 0000000..03a369d --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/ConcurrentMainScheduler.swift @@ -0,0 +1,90 @@ +// +// ConcurrentMainScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 10/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +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. + +This scheduler is optimized for `subscribeOn` operator. If you want to observe observable sequence elements on main thread using `observeOn` operator, +`MainScheduler` is more suitable for that purpose. +*/ +public final class ConcurrentMainScheduler : SchedulerType { + public typealias TimeInterval = Foundation.TimeInterval + public typealias Time = Date + + private let _mainScheduler: MainScheduler + private let _mainQueue: DispatchQueue + + /** + - returns: Current time. + */ + public var now : Date { + return _mainScheduler.now as Date + } + + private init(mainScheduler: MainScheduler) { + _mainQueue = DispatchQueue.main + _mainScheduler = mainScheduler + } + + /** + Singleton instance of `ConcurrentMainScheduler` + */ + public static let instance = ConcurrentMainScheduler(mainScheduler: MainScheduler.instance) + + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + if Thread.current.isMainThread { + return action(state) + } + + let cancel = SingleAssignmentDisposable() + + _mainQueue.async { + if cancel.isDisposed { + return + } + + cancel.setDisposable(action(state)) + } + + return cancel + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func scheduleRelative(_ state: StateType, dueTime: Foundation.TimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable { + return _mainScheduler.scheduleRelative(state, dueTime: dueTime, action: action) + } + + /** + Schedules a periodic piece of work. + + - parameter state: State passed to the action to be executed. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedulePeriodic(_ state: StateType, startAfter: TimeInterval, period: TimeInterval, action: @escaping (StateType) -> StateType) -> Disposable { + return _mainScheduler.schedulePeriodic(state, startAfter: startAfter, period: period, action: action) + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift new file mode 100644 index 0000000..87936aa --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/CurrentThreadScheduler.swift @@ -0,0 +1,150 @@ +// +// CurrentThreadScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 8/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +#if os(Linux) + let CurrentThreadSchedulerKeyInstance = "RxSwift.CurrentThreadScheduler.SchedulerKey" + let CurrentThreadSchedulerQueueKeyInstance = "RxSwift.CurrentThreadScheduler.Queue" + + typealias CurrentThreadSchedulerValue = NSString + let CurrentThreadSchedulerValueInstance = "RxSwift.CurrentThreadScheduler.SchedulerKey" as NSString +#else + // temporary workaround + + let CurrentThreadSchedulerKeyInstance = "RxSwift.CurrentThreadScheduler.SchedulerKey" + let CurrentThreadSchedulerQueueKeyInstance = "RxSwift.CurrentThreadScheduler.Queue" + + typealias CurrentThreadSchedulerValue = NSString + let CurrentThreadSchedulerValueInstance = "RxSwift.CurrentThreadScheduler.SchedulerKey" as NSString + + /* + let CurrentThreadSchedulerKeyInstance = CurrentThreadSchedulerKey() + let CurrentThreadSchedulerQueueKeyInstance = CurrentThreadSchedulerQueueKey() + + typealias CurrentThreadSchedulerValue = CurrentThreadSchedulerKey + let CurrentThreadSchedulerValueInstance = CurrentThreadSchedulerKeyInstance + + @objc class CurrentThreadSchedulerKey : NSObject, NSCopying { + override func isEqual(_ object: AnyObject?) -> Bool { + return object === CurrentThreadSchedulerKeyInstance + } + + override var hash: Int { return -904739208 } + + //func copy(with zone: NSZone? = nil) -> AnyObject { + func copyWithZone(zone: NSZone) -> AnyObject { + return CurrentThreadSchedulerKeyInstance + } + } + + @objc class CurrentThreadSchedulerQueueKey : NSObject, NSCopying { + override func isEqual(_ object: AnyObject?) -> Bool { + return object === CurrentThreadSchedulerQueueKeyInstance + } + + override var hash: Int { return -904739207 } + + //func copy(with: NSZone?) -> AnyObject { + func copyWithZone(zone: NSZone) -> AnyObject { + return CurrentThreadSchedulerQueueKeyInstance + } + }*/ +#endif + +/** +Represents an object that schedules units of work on the current thread. + +This is the default scheduler for operators that generate elements. + +This scheduler is also sometimes called `trampoline scheduler`. +*/ +public class CurrentThreadScheduler : ImmediateSchedulerType { + typealias ScheduleQueue = RxMutableBox> + + /** + The singleton instance of the current thread scheduler. + */ + public static let instance = CurrentThreadScheduler() + + static var queue : ScheduleQueue? { + get { + return Thread.getThreadLocalStorageValueForKey(CurrentThreadSchedulerQueueKeyInstance as NSString) + } + set { + Thread.setThreadLocalStorageValue(newValue, forKey: CurrentThreadSchedulerQueueKeyInstance as NSString) + } + } + + /** + Gets a value that indicates whether the caller must call a `schedule` method. + */ + public static fileprivate(set) var isScheduleRequired: Bool { + get { + let value: CurrentThreadSchedulerValue? = Thread.getThreadLocalStorageValueForKey(CurrentThreadSchedulerKeyInstance as NSString) + return value == nil + } + set(isScheduleRequired) { + Thread.setThreadLocalStorageValue(isScheduleRequired ? nil : CurrentThreadSchedulerValueInstance, forKey: CurrentThreadSchedulerKeyInstance as NSString) + } + } + + /** + Schedules an action to be executed as soon as possible on current thread. + + If this method is called on some thread that doesn't have `CurrentThreadScheduler` installed, scheduler will be + automatically installed and uninstalled after all work is performed. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + if CurrentThreadScheduler.isScheduleRequired { + CurrentThreadScheduler.isScheduleRequired = false + + let disposable = action(state) + + defer { + CurrentThreadScheduler.isScheduleRequired = true + CurrentThreadScheduler.queue = nil + } + + guard let queue = CurrentThreadScheduler.queue else { + return disposable + } + + while let latest = queue.value.dequeue() { + if latest.isDisposed { + continue + } + latest.invoke() + } + + return disposable + } + + let existingQueue = CurrentThreadScheduler.queue + + let queue: RxMutableBox> + if let existingQueue = existingQueue { + queue = existingQueue + } + else { + queue = RxMutableBox(Queue(capacity: 1)) + CurrentThreadScheduler.queue = queue + } + + let scheduledItem = ScheduledItem(action: action, state: state) + queue.value.enqueue(scheduledItem) + + // In Xcode 7.3, `return scheduledItem` causes segmentation fault 11 on release build. + // To workaround this compiler issue, returns AnonymousDisposable that disposes scheduledItem. + return Disposables.create(with: scheduledItem.dispose) + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift b/Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift new file mode 100644 index 0000000..a816496 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift @@ -0,0 +1,54 @@ +// +// DispatchQueueSchedulerQOS.swift +// RxSwift +// +// Created by John C. "Hsoi" Daub on 12/30/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Identifies one of the global concurrent dispatch queues with specified quality of service class. +*/ +public enum DispatchQueueSchedulerQOS { + + /** + Identifies global dispatch queue with `QOS_CLASS_USER_INTERACTIVE` + */ + case userInteractive + + /** + Identifies global dispatch queue with `QOS_CLASS_USER_INITIATED` + */ + case userInitiated + + /** + Identifies global dispatch queue with `QOS_CLASS_DEFAULT` + */ + case `default` + + /** + Identifies global dispatch queue with `QOS_CLASS_UTILITY` + */ + case utility + + /** + Identifies global dispatch queue with `QOS_CLASS_BACKGROUND` + */ + case background +} + + +@available(iOS 8, OSX 10.10, *) +extension DispatchQueueSchedulerQOS { + var qos: DispatchQoS { + switch self { + case .userInteractive: return .userInteractive + case .userInitiated: return .userInitiated + case .default: return .default + case .utility: return .utility + case .background: return .background + } + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift new file mode 100644 index 0000000..3545244 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/HistoricalScheduler.swift @@ -0,0 +1,25 @@ +// +// HistoricalScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 12/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** + Provides a virtual time scheduler that uses `NSDate` for absolute time and `NSTimeInterval` for relative time. +*/ +public class HistoricalScheduler : VirtualTimeScheduler { + + /** + Creates a new historical scheduler with initial clock value. + + - parameter initialClock: Initial value for virtual clock. + */ + public init(initialClock: RxTime = Date(timeIntervalSince1970: 0)) { + super.init(initialClock: initialClock, converter: HistoricalSchedulerTimeConverter()) + } + +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift b/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift new file mode 100644 index 0000000..29fa377 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift @@ -0,0 +1,83 @@ +// +// HistoricalSchedulerTimeConverter.swift +// Rx +// +// Created by Krunoslav Zaher on 12/27/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** + Converts historial virtual time into real time. + + Since historical virtual time is also measured in `NSDate`, this converter is identity function. + */ +public struct HistoricalSchedulerTimeConverter : VirtualTimeConverterType { + /** + Virtual time unit used that represents ticks of virtual clock. + */ + public typealias VirtualTimeUnit = RxTime + + /** + Virtual time unit used to represent differences of virtual times. + */ + public typealias VirtualTimeIntervalUnit = RxTimeInterval + + /** + Returns identical value of argument passed because historical virtual time is equal to real time, just + decoupled from local machine clock. + */ + public func convertFromVirtualTime(_ virtualTime: VirtualTimeUnit) -> RxTime { + return virtualTime + } + + /** + Returns identical value of argument passed because historical virtual time is equal to real time, just + decoupled from local machine clock. + */ + public func convertToVirtualTime(_ time: RxTime) -> VirtualTimeUnit { + return time + } + + /** + Returns identical value of argument passed because historical virtual time is equal to real time, just + decoupled from local machine clock. + */ + public func convertFromVirtualTimeInterval(_ virtualTimeInterval: VirtualTimeIntervalUnit) -> RxTimeInterval { + return virtualTimeInterval + } + + /** + Returns identical value of argument passed because historical virtual time is equal to real time, just + decoupled from local machine clock. + */ + public func convertToVirtualTimeInterval(_ timeInterval: RxTimeInterval) -> VirtualTimeIntervalUnit { + return timeInterval + } + + /** + Offsets `NSDate` by time interval. + + - parameter time: Time. + - parameter timeInterval: Time interval offset. + - returns: Time offsetted by time interval. + */ + public func offsetVirtualTime(_ time: VirtualTimeUnit, offset: VirtualTimeIntervalUnit) -> VirtualTimeUnit { + return time.addingTimeInterval(offset) + } + + /** + Compares two `NSDate`s. + */ + public func compareVirtualTime(_ lhs: VirtualTimeUnit, _ rhs: VirtualTimeUnit) -> VirtualTimeComparison { + switch lhs.compare(rhs as Date) { + case .orderedAscending: + return .lessThan + case .orderedSame: + return .equal + case .orderedDescending: + return .greaterThan + } + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift new file mode 100644 index 0000000..b1ff684 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift @@ -0,0 +1,39 @@ +// +// ImmediateScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 10/17/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Represents an object that schedules units of work to run immediately on the current thread. +*/ +private class ImmediateScheduler : ImmediateSchedulerType { + + private let _asyncLock = AsyncLock() + + /** + Schedules an action to be executed immediatelly. + + In case `schedule` is called recursively from inside of `action` callback, scheduled `action` will be enqueued + and executed after current `action`. (`AsyncLock` behavior) + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + let disposable = SingleAssignmentDisposable() + _asyncLock.invoke(AnonymousInvocable { + if disposable.isDisposed { + return + } + disposable.setDisposable(action(state)) + }) + + return disposable + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift b/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift new file mode 100644 index 0000000..e74d881 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/Internal/AnonymousInvocable.swift @@ -0,0 +1,21 @@ +// +// AnonymousInvocable.swift +// Rx +// +// Created by Krunoslav Zaher on 11/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct AnonymousInvocable : InvocableType { + private let _action: () -> () + + init(_ action: @escaping () -> ()) { + _action = action + } + + func invoke() { + _action() + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift b/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift new file mode 100644 index 0000000..bd31a1d --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/Internal/DispatchQueueConfiguration.swift @@ -0,0 +1,103 @@ +// +// DispatchQueueConfiguration.swift +// Rx +// +// Created by Krunoslav Zaher on 7/23/16. +// Copyright © 2016 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct DispatchQueueConfiguration { + let queue: DispatchQueue + let leeway: DispatchTimeInterval +} + +private func dispatchInterval(_ interval: Foundation.TimeInterval) -> DispatchTimeInterval { + precondition(interval >= 0.0) + // TODO: Replace 1000 with something that actually works + // NSEC_PER_MSEC returns 1000000 + return DispatchTimeInterval.milliseconds(Int(interval * 1000.0)) +} + +extension DispatchQueueConfiguration { + func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + let cancel = SingleAssignmentDisposable() + + queue.async { + if cancel.isDisposed { + return + } + + + cancel.setDisposable(action(state)) + } + + return cancel + } + + func scheduleRelative(_ state: StateType, dueTime: Foundation.TimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable { + let deadline = DispatchTime.now() + dispatchInterval(dueTime) + + let compositeDisposable = CompositeDisposable() + + let timer = DispatchSource.makeTimerSource(queue: queue) + timer.scheduleOneshot(deadline: deadline) + + // TODO: + // This looks horrible, and yes, it is. + // It looks like Apple has made a conceputal change here, and I'm unsure why. + // Need more info on this. + // It looks like just setting timer to fire and not holding a reference to it + // until deadline causes timer cancellation. + var timerReference: DispatchSourceTimer? = timer + let cancelTimer = Disposables.create { + timerReference?.cancel() + timerReference = nil + } + + timer.setEventHandler(handler: { + if compositeDisposable.isDisposed { + return + } + _ = compositeDisposable.insert(action(state)) + cancelTimer.dispose() + }) + timer.resume() + + _ = compositeDisposable.insert(cancelTimer) + + return compositeDisposable + } + + func schedulePeriodic(_ state: StateType, startAfter: TimeInterval, period: TimeInterval, action: @escaping (StateType) -> StateType) -> Disposable { + let initial = DispatchTime.now() + dispatchInterval(startAfter) + + var timerState = state + + let timer = DispatchSource.makeTimerSource(queue: queue) + timer.scheduleRepeating(deadline: initial, interval: dispatchInterval(period), leeway: leeway) + + // TODO: + // This looks horrible, and yes, it is. + // It looks like Apple has made a conceputal change here, and I'm unsure why. + // Need more info on this. + // It looks like just setting timer to fire and not holding a reference to it + // until deadline causes timer cancellation. + var timerReference: DispatchSourceTimer? = timer + let cancelTimer = Disposables.create { + timerReference?.cancel() + timerReference = nil + } + + timer.setEventHandler(handler: { + if cancelTimer.isDisposed { + return + } + timerState = action(timerState) + }) + timer.resume() + + return cancelTimer + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift b/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift new file mode 100644 index 0000000..7f2676b --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableScheduledItem.swift @@ -0,0 +1,24 @@ +// +// InvocableScheduledItem.swift +// Rx +// +// Created by Krunoslav Zaher on 11/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct InvocableScheduledItem : InvocableType { + + let _invocable: I + let _state: I.Value + + init(invocable: I, state: I.Value) { + _invocable = invocable + _state = state + } + + func invoke() { + _invocable.invoke(_state) + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift b/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift new file mode 100644 index 0000000..6a7de26 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/Internal/InvocableType.swift @@ -0,0 +1,19 @@ +// +// InvocableType.swift +// Rx +// +// Created by Krunoslav Zaher on 11/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol InvocableType { + func invoke() +} + +protocol InvocableWithValueType { + associatedtype Value + + func invoke(_ value: Value) +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift b/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift new file mode 100644 index 0000000..5d5ab96 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItem.swift @@ -0,0 +1,37 @@ +// +// ScheduledItem.swift +// Rx +// +// Created by Krunoslav Zaher on 9/2/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +struct ScheduledItem + : ScheduledItemType + , InvocableType { + typealias Action = (T) -> Disposable + + private let _action: Action + private let _state: T + + private let _disposable = SingleAssignmentDisposable() + + var isDisposed: Bool { + return _disposable.isDisposed + } + + init(action: @escaping Action, state: T) { + _action = action + _state = state + } + + func invoke() { + _disposable.setDisposable(_action(_state)) + } + + func dispose() { + _disposable.dispose() + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift b/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift new file mode 100644 index 0000000..2a1eca2 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/Internal/ScheduledItemType.swift @@ -0,0 +1,15 @@ +// +// ScheduledItemType.swift +// Rx +// +// Created by Krunoslav Zaher on 11/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +protocol ScheduledItemType + : Cancelable + , InvocableType { + func invoke() +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift new file mode 100644 index 0000000..61c01e9 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift @@ -0,0 +1,76 @@ +// +// MainScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +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. + +This scheduler is usually used to perform UI work. + +Main scheduler is a specialization of `SerialDispatchQueueScheduler`. + +This scheduler is optimized for `observeOn` operator. To ensure observable sequence is subscribed on main thread using `subscribeOn` +operator please use `ConcurrentMainScheduler` because it is more optimized for that purpose. +*/ +public final class MainScheduler : SerialDispatchQueueScheduler { + + private let _mainQueue: DispatchQueue + + var numberEnqueued: AtomicInt = 0 + + /** + Initializes new instance of `MainScheduler`. + */ + public init() { + _mainQueue = DispatchQueue.main + super.init(serialQueue: _mainQueue) + } + + /** + Singleton instance of `MainScheduler` + */ + public static let instance = MainScheduler() + + /** + Singleton instance of `MainScheduler` that always schedules work asynchronously + and doesn't perform optimizations for calls scheduled from main thread. + */ + public static let asyncInstance = SerialDispatchQueueScheduler(serialQueue: DispatchQueue.main) + + /** + In case this method is called on a background thread it will throw an exception. + */ + public class func ensureExecutingOnScheduler(errorMessage: String? = nil) { + if !Thread.current.isMainThread { + rxFatalError(errorMessage ?? "Executing on backgound thread. Please use `MainScheduler.instance.schedule` to schedule work on main thread.") + } + } + + override func scheduleInternal(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + let currentNumberEnqueued = AtomicIncrement(&numberEnqueued) + + if Thread.current.isMainThread && currentNumberEnqueued == 1 { + let disposable = action(state) + _ = AtomicDecrement(&numberEnqueued) + return disposable + } + + let cancel = SingleAssignmentDisposable() + + _mainQueue.async { + if !cancel.isDisposed { + _ = action(state) + } + + _ = AtomicDecrement(&self.numberEnqueued) + } + + return cancel + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift new file mode 100644 index 0000000..38d4922 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift @@ -0,0 +1,57 @@ +// +// OperationQueueScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 4/4/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Abstracts the work that needs to be performed on a specific `NSOperationQueue`. + +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`. +*/ +public class OperationQueueScheduler: ImmediateSchedulerType { + public let operationQueue: OperationQueue + + /** + Constructs new instance of `OperationQueueScheduler` that performs work on `operationQueue`. + + - parameter operationQueue: Operation queue targeted to perform work on. + */ + public init(operationQueue: OperationQueue) { + self.operationQueue = operationQueue + } + + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + - 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. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + + let compositeDisposable = CompositeDisposable() + + weak var compositeDisposableWeak = compositeDisposable + + let operation = BlockOperation { + if compositeDisposableWeak?.isDisposed ?? false { + return + } + + let disposable = action(state) + let _ = compositeDisposableWeak?.insert(disposable) + } + + self.operationQueue.addOperation(operation) + + let _ = compositeDisposable.insert(Disposables.create(with: operation.cancel)) + + return compositeDisposable + } + +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift new file mode 100644 index 0000000..6ad5456 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/RecursiveScheduler.swift @@ -0,0 +1,193 @@ +// +// RecursiveScheduler.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/7/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Type erased recursive scheduler. +*/ +class AnyRecursiveScheduler { + typealias Action = (State, AnyRecursiveScheduler) -> Void + + private let _lock = NSRecursiveLock() + + // state + private let _group = CompositeDisposable() + + private var _scheduler: SchedulerType + private var _action: Action? + + init(scheduler: SchedulerType, action: @escaping Action) { + _action = action + _scheduler = scheduler + } + + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the recursive action. + */ + func schedule(_ state: State, dueTime: RxTimeInterval) { + + var isAdded = false + var isDone = false + + var removeKey: CompositeDisposable.DisposeKey? = nil + let d = _scheduler.scheduleRelative(state, dueTime: dueTime) { (state) -> Disposable in + // best effort + if self._group.isDisposed { + return Disposables.create() + } + + let action = self._lock.calculateLocked { () -> Action? in + if isAdded { + self._group.remove(for: removeKey!) + } + else { + isDone = true + } + + return self._action + } + + if let action = action { + action(state, self) + } + + return Disposables.create() + } + + _lock.performLocked { + if !isDone { + removeKey = _group.insert(d) + isAdded = true + } + } + } + + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + */ + func schedule(_ state: State) { + + var isAdded = false + var isDone = false + + var removeKey: CompositeDisposable.DisposeKey? = nil + let d = _scheduler.schedule(state) { (state) -> Disposable in + // best effort + if self._group.isDisposed { + return Disposables.create() + } + + let action = self._lock.calculateLocked { () -> Action? in + if isAdded { + self._group.remove(for: removeKey!) + } + else { + isDone = true + } + + return self._action + } + + if let action = action { + action(state, self) + } + + return Disposables.create() + } + + _lock.performLocked { + if !isDone { + removeKey = _group.insert(d) + isAdded = true + } + } + } + + func dispose() { + _lock.performLocked { + _action = nil + } + _group.dispose() + } +} + +/** +Type erased recursive scheduler. +*/ +class RecursiveImmediateScheduler { + typealias Action = (_ state: State, _ recurse: (State) -> Void) -> Void + + private var _lock = SpinLock() + private let _group = CompositeDisposable() + + private var _action: Action? + private let _scheduler: ImmediateSchedulerType + + init(action: @escaping Action, scheduler: ImmediateSchedulerType) { + _action = action + _scheduler = scheduler + } + + // immediate scheduling + + /** + Schedules an action to be executed recursively. + + - parameter state: State passed to the action to be executed. + */ + func schedule(_ state: State) { + + var isAdded = false + var isDone = false + + var removeKey: CompositeDisposable.DisposeKey? = nil + let d = _scheduler.schedule(state) { (state) -> Disposable in + // best effort + if self._group.isDisposed { + return Disposables.create() + } + + let action = self._lock.calculateLocked { () -> Action? in + if isAdded { + self._group.remove(for: removeKey!) + } + else { + isDone = true + } + + return self._action + } + + if let action = action { + action(state, self.schedule) + } + + return Disposables.create() + } + + _lock.performLocked { + if !isDone { + removeKey = _group.insert(d) + isAdded = true + } + } + } + + func dispose() { + _lock.performLocked { + _action = nil + } + _group.dispose() + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift b/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift new file mode 100644 index 0000000..9374fc5 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift @@ -0,0 +1,63 @@ +// +// SchedulerServices+Emulation.swift +// RxSwift +// +// Created by Krunoslav Zaher on 6/6/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +enum SchedulePeriodicRecursiveCommand { + case tick + case dispatchStart +} + +class SchedulePeriodicRecursive { + typealias RecursiveAction = (State) -> State + typealias RecursiveScheduler = AnyRecursiveScheduler + + private let _scheduler: SchedulerType + private let _startAfter: RxTimeInterval + private let _period: RxTimeInterval + private let _action: RecursiveAction + + private var _state: State + private var _pendingTickCount: AtomicInt = 0 + + init(scheduler: SchedulerType, startAfter: RxTimeInterval, period: RxTimeInterval, action: @escaping RecursiveAction, state: State) { + _scheduler = scheduler + _startAfter = startAfter + _period = period + _action = action + _state = state + } + + func start() -> Disposable { + return _scheduler.scheduleRecursive(SchedulePeriodicRecursiveCommand.tick, dueTime: _startAfter, action: self.tick) + } + + func tick(_ command: SchedulePeriodicRecursiveCommand, scheduler: RecursiveScheduler) -> Void { + // Tries to emulate periodic scheduling as best as possible. + // The problem that could arise is if handling periodic ticks take too long, or + // tick interval is short. + switch command { + case .tick: + scheduler.schedule(.tick, dueTime: _period) + + // The idea is that if on tick there wasn't any item enqueued, schedule to perform work immediatelly. + // Else work will be scheduled after previous enqueued work completes. + if AtomicIncrement(&_pendingTickCount) == 1 { + self.tick(.dispatchStart, scheduler: scheduler) + } + + case .dispatchStart: + _state = _action(_state) + // Start work and schedule check is this last batch of work + if AtomicDecrement(&_pendingTickCount) > 0 { + // This gives priority to scheduler emulation, it's not perfect, but helps + scheduler.schedule(SchedulePeriodicRecursiveCommand.dispatchStart) + } + } + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift new file mode 100644 index 0000000..01733b0 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/SerialDispatchQueueScheduler.swift @@ -0,0 +1,124 @@ +// +// SerialDispatchQueueScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 2/8/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Abstracts the work that needs to be performed on a specific `dispatch_queue_t`. It will make sure +that even if concurrent dispatch queue is passed, it's transformed into a serial one. + +It is extremely important that this scheduler is serial, because +certain operator perform optimizations that rely on that property. + +Because there is no way of detecting is passed dispatch queue serial or +concurrent, for every queue that is being passed, worst case (concurrent) +will be assumed, and internal serial proxy dispatch queue will be created. + +This scheduler can also be used with internal serial queue alone. + +In case some customization need to be made on it before usage, +internal serial queue can be customized using `serialQueueConfiguration` +callback. +*/ +public class SerialDispatchQueueScheduler : SchedulerType { + public typealias TimeInterval = Foundation.TimeInterval + public typealias Time = Date + + /** + - returns: Current time. + */ + public var now : Date { + return Date() + } + + let configuration: DispatchQueueConfiguration + + init(serialQueue: DispatchQueue, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0)) { + configuration = DispatchQueueConfiguration(queue: serialQueue, leeway: leeway) + } + + /** + Constructs new `SerialDispatchQueueScheduler` with internal serial queue named `internalSerialQueueName`. + + Additional dispatch queue properties can be set after dispatch queue is created using `serialQueueConfiguration`. + + - parameter internalSerialQueueName: Name of internal serial dispatch queue. + - parameter serialQueueConfiguration: Additional configuration of internal serial dispatch queue. + */ + public convenience init(internalSerialQueueName: String, serialQueueConfiguration: ((DispatchQueue) -> Void)? = nil, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0)) { + let queue = DispatchQueue(label: internalSerialQueueName, attributes: []) + serialQueueConfiguration?(queue) + self.init(serialQueue: queue, leeway: leeway) + } + + /** + Constructs new `SerialDispatchQueueScheduler` named `internalSerialQueueName` that wraps `queue`. + + - parameter queue: Possibly concurrent dispatch queue used to perform work. + - parameter internalSerialQueueName: Name of internal serial dispatch queue proxy. + */ + public convenience init(queue: DispatchQueue, internalSerialQueueName: String, leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0)) { + // Swift 3.0 IUO + let serialQueue = DispatchQueue(label: internalSerialQueueName, + attributes: [], + target: queue) + self.init(serialQueue: serialQueue, leeway: leeway) + } + + /** + Constructs new `SerialDispatchQueueScheduler` that wraps on of the global concurrent dispatch queues. + + - parameter globalConcurrentQueueQOS: Identifier for global dispatch queue with specified quality of service class. + - parameter internalSerialQueueName: Custom name for internal serial dispatch queue proxy. + */ + @available(iOS 8, OSX 10.10, *) + public convenience init(globalConcurrentQueueQOS: DispatchQueueSchedulerQOS, internalSerialQueueName: String = "rx.global_dispatch_queue.serial", leeway: DispatchTimeInterval = DispatchTimeInterval.nanoseconds(0)) { + let priority = globalConcurrentQueueQOS.qos + self.init(queue: DispatchQueue.global(qos: priority.qosClass), internalSerialQueueName: internalSerialQueueName, leeway: leeway) + } + + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + return self.scheduleInternal(state, action: action) + } + + func scheduleInternal(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + return self.configuration.schedule(state, action: action) + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public final func scheduleRelative(_ state: StateType, dueTime: Foundation.TimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable { + return self.configuration.scheduleRelative(state, dueTime: dueTime, action: action) + } + + /** + Schedules a periodic piece of work. + + - parameter state: State passed to the action to be executed. + - parameter startAfter: Period after which initial work should be run. + - parameter period: Period for running the work periodically. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedulePeriodic(_ state: StateType, startAfter: TimeInterval, period: TimeInterval, action: @escaping (StateType) -> StateType) -> Disposable { + return self.configuration.schedulePeriodic(state, startAfter: startAfter, period: period, action: action) + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift b/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift new file mode 100644 index 0000000..c5476a0 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeConverterType.swift @@ -0,0 +1,115 @@ +// +// VirtualTimeConverterType.swift +// Rx +// +// Created by Krunoslav Zaher on 12/23/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Parametrization for virtual time used by `VirtualTimeScheduler`s. +*/ +public protocol VirtualTimeConverterType { + /** + Virtual time unit used that represents ticks of virtual clock. + */ + associatedtype VirtualTimeUnit + + /** + Virtual time unit used to represent differences of virtual times. + */ + associatedtype VirtualTimeIntervalUnit + + /** + Converts virtual time to real time. + + - parameter virtualTime: Virtual time to convert to `NSDate`. + - returns: `NSDate` corresponding to virtual time. + */ + func convertFromVirtualTime(_ virtualTime: VirtualTimeUnit) -> RxTime + + /** + Converts real time to virtual time. + + - parameter time: `NSDate` to convert to virtual time. + - returns: Virtual time corresponding to `NSDate`. + */ + func convertToVirtualTime(_ time: RxTime) -> VirtualTimeUnit + + /** + Converts from virtual time interval to `NSTimeInterval`. + + - parameter virtualTimeInterval: Virtual time interval to convert to `NSTimeInterval`. + - returns: `NSTimeInterval` corresponding to virtual time interval. + */ + func convertFromVirtualTimeInterval(_ virtualTimeInterval: VirtualTimeIntervalUnit) -> RxTimeInterval + + /** + Converts from virtual time interval to `NSTimeInterval`. + + - parameter timeInterval: `NSTimeInterval` to convert to virtual time interval. + - returns: Virtual time interval corresponding to time interval. + */ + func convertToVirtualTimeInterval(_ timeInterval: RxTimeInterval) -> VirtualTimeIntervalUnit + + /** + Offsets virtual time by virtual time interval. + + - parameter time: Virtual time. + - parameter offset: Virtual time interval. + - returns: Time corresponding to time offsetted by virtual time interval. + */ + func offsetVirtualTime(_ time: VirtualTimeUnit, offset: VirtualTimeIntervalUnit) -> VirtualTimeUnit + + /** + This is aditional abstraction because `NSDate` is unfortunately not comparable. + Extending `NSDate` with `Comparable` would be too risky because of possible collisions with other libraries. + */ + func compareVirtualTime(_ lhs: VirtualTimeUnit, _ rhs: VirtualTimeUnit) -> VirtualTimeComparison +} + +/** + Virtual time comparison result. + + This is aditional abstraction because `NSDate` is unfortunately not comparable. + Extending `NSDate` with `Comparable` would be too risky because of possible collisions with other libraries. +*/ +public enum VirtualTimeComparison { + /** + lhs < rhs. + */ + case lessThan + /** + lhs == rhs. + */ + case equal + /** + lhs > rhs. + */ + case greaterThan +} + +extension VirtualTimeComparison { + /** + lhs < rhs. + */ + var lessThen: Bool { + return self == .lessThan + } + + /** + lhs > rhs + */ + var greaterThan: Bool { + return self == .greaterThan + } + + /** + lhs == rhs + */ + var equal: Bool { + return self == .equal + } +} diff --git a/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift b/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift new file mode 100644 index 0000000..d1ba5e4 --- /dev/null +++ b/Pods/RxSwift/RxSwift/Schedulers/VirtualTimeScheduler.swift @@ -0,0 +1,292 @@ +// +// VirtualTimeScheduler.swift +// Rx +// +// Created by Krunoslav Zaher on 2/14/15. +// Copyright © 2015 Krunoslav Zaher. All rights reserved. +// + +import Foundation + +/** +Base class for virtual time schedulers using a priority queue for scheduled items. +*/ +open class VirtualTimeScheduler + : SchedulerType + , CustomDebugStringConvertible { + + public typealias VirtualTime = Converter.VirtualTimeUnit + public typealias VirtualTimeInterval = Converter.VirtualTimeIntervalUnit + + private var _running : Bool + + private var _clock: VirtualTime + + fileprivate var _schedulerQueue : PriorityQueue> + private var _converter: Converter + + private var _nextId = 0 + + /** + - returns: Current time. + */ + public var now: RxTime { + return _converter.convertFromVirtualTime(clock) + } + + /** + - returns: Scheduler's absolute time clock value. + */ + public var clock: VirtualTime { + return _clock + } + + /** + Creates a new virtual time scheduler. + + - parameter initialClock: Initial value for the clock. + */ + public init(initialClock: VirtualTime, converter: Converter) { + _clock = initialClock + _running = false + _converter = converter + _schedulerQueue = PriorityQueue(hasHigherPriority: { + switch converter.compareVirtualTime($0.time, $1.time) { + case .lessThan: + return true + case .equal: + return $0.id < $1.id + case .greaterThan: + return false + } + }) + #if TRACE_RESOURCES + let _ = AtomicIncrement(&resourceCount) + #endif + } + + /** + Schedules an action to be executed immediatelly. + + - parameter state: State passed to the action to be executed. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func schedule(_ state: StateType, action: @escaping (StateType) -> Disposable) -> Disposable { + return self.scheduleRelative(state, dueTime: 0.0) { a in + return action(a) + } + } + + /** + Schedules an action to be executed. + + - parameter state: State passed to the action to be executed. + - parameter dueTime: Relative time after which to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func scheduleRelative(_ state: StateType, dueTime: RxTimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable { + let time = self.now.addingTimeInterval(dueTime) + let absoluteTime = _converter.convertToVirtualTime(time) + let adjustedTime = self.adjustScheduledTime(absoluteTime) + return scheduleAbsoluteVirtual(state, time: adjustedTime, action: action) + } + + /** + Schedules an action to be executed after relative time has passed. + + - parameter state: State passed to the action to be executed. + - parameter time: Absolute time when to execute the action. If this is less or equal then `now`, `now + 1` will be used. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func scheduleRelativeVirtual(_ state: StateType, dueTime: VirtualTimeInterval, action: @escaping (StateType) -> Disposable) -> Disposable { + let time = _converter.offsetVirtualTime(self.clock, offset: dueTime) + return scheduleAbsoluteVirtual(state, time: time, action: action) + } + + /** + Schedules an action to be executed at absolute virtual time. + + - parameter state: State passed to the action to be executed. + - parameter time: Absolute time when to execute the action. + - parameter action: Action to be executed. + - returns: The disposable object used to cancel the scheduled action (best effort). + */ + public func scheduleAbsoluteVirtual(_ state: StateType, time: Converter.VirtualTimeUnit, action: @escaping (StateType) -> Disposable) -> Disposable { + MainScheduler.ensureExecutingOnScheduler() + + let compositeDisposable = CompositeDisposable() + + let item = VirtualSchedulerItem(action: { + let dispose = action(state) + return dispose + }, time: time, id: _nextId) + + _nextId += 1 + + _schedulerQueue.enqueue(item) + + _ = compositeDisposable.insert(item) + + return compositeDisposable + } + + /** + Adjusts time of scheduling before adding item to schedule queue. + */ + open func adjustScheduledTime(_ time: Converter.VirtualTimeUnit) -> Converter.VirtualTimeUnit { + return time + } + + /** + Starts the virtual time scheduler. + */ + public func start() { + MainScheduler.ensureExecutingOnScheduler() + + if _running { + return + } + + _running = true + repeat { + guard let next = findNext() else { + break + } + + if _converter.compareVirtualTime(next.time, self.clock).greaterThan { + _clock = next.time + } + + next.invoke() + _schedulerQueue.remove(next) + } while _running + + _running = false + } + + func findNext() -> VirtualSchedulerItem? { + while let front = _schedulerQueue.peek() { + if front.isDisposed { + _schedulerQueue.remove(front) + continue + } + + return front + } + + return nil + } + + /** + Advances the scheduler's clock to the specified time, running all work till that point. + + - parameter virtualTime: Absolute time to advance the scheduler's clock to. + */ + public func advanceTo(_ virtualTime: VirtualTime) { + MainScheduler.ensureExecutingOnScheduler() + + if _running { + fatalError("Scheduler is already running") + } + + _running = true + repeat { + guard let next = findNext() else { + break + } + + if _converter.compareVirtualTime(next.time, virtualTime).greaterThan { + break + } + + if _converter.compareVirtualTime(next.time, self.clock).greaterThan { + _clock = next.time + } + + next.invoke() + _schedulerQueue.remove(next) + } while _running + + _clock = virtualTime + _running = false + } + + /** + Advances the scheduler's clock by the specified relative time. + */ + public func sleep(_ virtualInterval: VirtualTimeInterval) { + MainScheduler.ensureExecutingOnScheduler() + + let sleepTo = _converter.offsetVirtualTime(clock, offset: virtualInterval) + if _converter.compareVirtualTime(sleepTo, clock).lessThen { + fatalError("Can't sleep to past.") + } + + _clock = sleepTo + } + + /** + Stops the virtual time scheduler. + */ + public func stop() { + MainScheduler.ensureExecutingOnScheduler() + + _running = false + } + + #if TRACE_RESOURCES + deinit { + _ = AtomicDecrement(&resourceCount) + } + #endif +} + +// MARK: description + +extension VirtualTimeScheduler { + /** + A textual representation of `self`, suitable for debugging. + */ + public var debugDescription: String { + return self._schedulerQueue.debugDescription + } +} + +class VirtualSchedulerItem