├── Pods ├── Headers │ └── Private │ │ ├── Representor │ │ └── Representor.h │ │ └── URITemplate │ │ └── URITemplate.h ├── Target Support Files │ ├── Result │ │ ├── Result-prefix.pch │ │ ├── Result.modulemap │ │ ├── Result-dummy.m │ │ ├── Result-umbrella.h │ │ ├── Result.xcconfig │ │ └── Info.plist │ ├── RxSwift │ │ ├── RxSwift-prefix.pch │ │ ├── RxSwift.modulemap │ │ ├── RxSwift-dummy.m │ │ ├── RxSwift-umbrella.h │ │ ├── RxSwift.xcconfig │ │ └── Info.plist │ ├── Hyperdrive │ │ ├── Hyperdrive-prefix.pch │ │ ├── Hyperdrive.modulemap │ │ ├── Hyperdrive-dummy.m │ │ ├── Hyperdrive-umbrella.h │ │ ├── Hyperdrive.xcconfig │ │ └── Info.plist │ ├── WebLinking │ │ ├── WebLinking-prefix.pch │ │ ├── WebLinking.modulemap │ │ ├── WebLinking-dummy.m │ │ ├── WebLinking-umbrella.h │ │ ├── WebLinking.xcconfig │ │ └── Info.plist │ ├── Representor │ │ ├── Representor-prefix.pch │ │ ├── Representor.modulemap │ │ ├── Representor-dummy.m │ │ ├── Representor-umbrella.h │ │ ├── Representor.xcconfig │ │ └── Info.plist │ ├── URITemplate │ │ ├── URITemplate-prefix.pch │ │ ├── URITemplate.modulemap │ │ ├── URITemplate-dummy.m │ │ ├── URITemplate-umbrella.h │ │ ├── URITemplate.xcconfig │ │ └── Info.plist │ ├── Pods-RxHyperdrive │ │ ├── Pods-RxHyperdrive.modulemap │ │ ├── Pods-RxHyperdrive-dummy.m │ │ ├── Pods-RxHyperdrive-umbrella.h │ │ ├── Info.plist │ │ ├── Pods-RxHyperdrive.debug.xcconfig │ │ └── Pods-RxHyperdrive.release.xcconfig │ └── Pods-RxHyperdriveTests │ │ ├── Pods-RxHyperdriveTests.modulemap │ │ ├── Pods-RxHyperdriveTests-dummy.m │ │ ├── Pods-RxHyperdriveTests-umbrella.h │ │ ├── Info.plist │ │ ├── Pods-RxHyperdriveTests.debug.xcconfig │ │ └── Pods-RxHyperdriveTests.release.xcconfig ├── RxSwift │ ├── RxSwift │ │ ├── Disposables │ │ │ ├── NAryDisposable.swift │ │ │ ├── StableCompositeDisposable.swift │ │ │ ├── DisposeBase.swift │ │ │ ├── SubscriptionDisposable.swift │ │ │ ├── NopDisposable.swift │ │ │ ├── BooleanDisposable.swift │ │ │ ├── ScopedDisposable.swift │ │ │ ├── BinaryDisposable.swift │ │ │ ├── AnonymousDisposable.swift │ │ │ ├── ScheduledDisposable.swift │ │ │ ├── DisposeBag.swift │ │ │ ├── SingleAssignmentDisposable.swift │ │ │ └── SerialDisposable.swift │ │ ├── Schedulers │ │ │ ├── ScheduledItemType.swift │ │ │ ├── InvocableType.swift │ │ │ ├── AnonymousInvocable.swift │ │ │ ├── InvocableScheduledItem.swift │ │ │ ├── DispatchQueueSchedulerPriority.swift │ │ │ ├── ScheduledItem.swift │ │ │ ├── ImmediateScheduler.swift │ │ │ ├── OperationQueueScheduler.swift │ │ │ ├── MainScheduler.swift │ │ │ └── SchedulerServices+Emulation.swift │ │ ├── Disposable.swift │ │ ├── Concurrency │ │ │ ├── SynchronizedUnsubscribeType.swift │ │ │ ├── LockOwnerType.swift │ │ │ ├── SynchronizedDisposeType.swift │ │ │ ├── SynchronizedOnType.swift │ │ │ ├── SynchronizedSubscribeType.swift │ │ │ ├── Lock.swift │ │ │ └── AsyncLock.swift │ │ ├── Observables │ │ │ ├── Implementations │ │ │ │ ├── Never.swift │ │ │ │ ├── Empty.swift │ │ │ │ ├── FailWith.swift │ │ │ │ ├── Sink.swift │ │ │ │ ├── StartWith.swift │ │ │ │ ├── Producer.swift │ │ │ │ ├── Repeat.swift │ │ │ │ ├── AddRef.swift │ │ │ │ ├── ToArray.swift │ │ │ │ ├── Do.swift │ │ │ │ ├── DelaySubscription.swift │ │ │ │ ├── AnonymousObservable.swift │ │ │ │ ├── Debug.swift │ │ │ │ ├── Sequence.swift │ │ │ │ ├── Range.swift │ │ │ │ ├── Deferred.swift │ │ │ │ ├── Concat.swift │ │ │ │ ├── Just.swift │ │ │ │ ├── Filter.swift │ │ │ │ ├── TakeLast.swift │ │ │ │ ├── SubscribeOn.swift │ │ │ │ ├── Scan.swift │ │ │ │ ├── ElementAt.swift │ │ │ │ ├── DistinctUntilChanged.swift │ │ │ │ ├── Timer.swift │ │ │ │ ├── ConnectableObservable.swift │ │ │ │ ├── SingleAsync.swift │ │ │ │ ├── Generate.swift │ │ │ │ ├── Multicast.swift │ │ │ │ ├── ObserveOnSerialDispatchQueue.swift │ │ │ │ ├── Using.swift │ │ │ │ ├── Reduce.swift │ │ │ │ ├── RefCount.swift │ │ │ │ ├── ShareReplay1.swift │ │ │ │ └── Throttle.swift │ │ │ ├── Observable+Debug.swift │ │ │ ├── Observable+Concurrency.swift │ │ │ └── Observable+Aggregate.swift │ │ ├── Cancelable.swift │ │ ├── ObservableConvertibleType.swift │ │ ├── DataStructures │ │ │ └── InfiniteSequence.swift │ │ ├── Subjects │ │ │ ├── SubjectType.swift │ │ │ └── Variable.swift │ │ ├── ConnectableObservableType.swift │ │ ├── Observers │ │ │ ├── AnonymousObserver.swift │ │ │ └── ObserverBase.swift │ │ ├── ObserverType+Extensions.swift │ │ ├── Observable.swift │ │ ├── ObserverType.swift │ │ ├── RxBox.swift │ │ ├── Rx.swift │ │ ├── ImmediateSchedulerType.swift │ │ ├── Error.swift │ │ ├── ObservableType.swift │ │ ├── AnyObserver.swift │ │ ├── Event.swift │ │ └── SchedulerType.swift │ └── LICENSE.md ├── Representor │ ├── Representor │ │ ├── Builder │ │ │ ├── TransitionBuilder.swift │ │ │ └── RepresentorBuilder.swift │ │ ├── Representor.h │ │ ├── Transition.swift │ │ ├── HTTP │ │ │ ├── HTTPTransition.swift │ │ │ ├── HTTPDeserialization.swift │ │ │ ├── HTTPTransitionBuilder.swift │ │ │ └── Adapters │ │ │ │ └── HTTPHALAdapter.swift │ │ └── Representor.swift │ ├── LICENSE │ └── README.md ├── URITemplate │ ├── URITemplate │ │ └── URITemplate.h │ ├── LICENSE │ └── README.md ├── WebLinking │ ├── README.md │ └── LICENSE ├── Result │ ├── LICENSE │ ├── Result │ │ └── ResultType.swift │ └── README.md ├── Hyperdrive │ └── LICENSE └── Manifest.lock ├── Podfile ├── RxHyperdrive.xcodeproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── RxHyperdrive.xcworkspace └── contents.xcworkspacedata ├── .travis.yml ├── RxHyperdrive ├── RxHyperdrive.h ├── Info.plist └── RxHyperdrive.swift ├── RxHyperdrive.podspec ├── RxHyperdriveTests ├── Info.plist └── RxHyperdriveTests.swift ├── LICENSE ├── Podfile.lock └── README.md /Pods/Headers/Private/Representor/Representor.h: -------------------------------------------------------------------------------- 1 | ../../../Representor/Representor/Representor.h -------------------------------------------------------------------------------- /Pods/Headers/Private/URITemplate/URITemplate.h: -------------------------------------------------------------------------------- 1 | ../../../URITemplate/URITemplate/URITemplate.h -------------------------------------------------------------------------------- /Pods/Target Support Files/Result/Result-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RxSwift/RxSwift-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Hyperdrive/Hyperdrive-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebLinking/WebLinking-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Representor/Representor-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Pods/Target Support Files/URITemplate/URITemplate-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | 3 | target 'RxHyperdrive' do 4 | podspec 5 | end 6 | 7 | target 'RxHyperdriveTests' do 8 | podspec 9 | end 10 | 11 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Result/Result.modulemap: -------------------------------------------------------------------------------- 1 | framework module Result { 2 | umbrella header "Result-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Result/Result-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Result : NSObject 3 | @end 4 | @implementation PodsDummy_Result 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RxSwift/RxSwift.modulemap: -------------------------------------------------------------------------------- 1 | framework module RxSwift { 2 | umbrella header "RxSwift-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RxSwift/RxSwift-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_RxSwift : NSObject 3 | @end 4 | @implementation PodsDummy_RxSwift 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Hyperdrive/Hyperdrive.modulemap: -------------------------------------------------------------------------------- 1 | framework module Hyperdrive { 2 | umbrella header "Hyperdrive-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebLinking/WebLinking.modulemap: -------------------------------------------------------------------------------- 1 | framework module WebLinking { 2 | umbrella header "WebLinking-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Representor/Representor.modulemap: -------------------------------------------------------------------------------- 1 | framework module Representor { 2 | umbrella header "Representor-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/URITemplate/URITemplate.modulemap: -------------------------------------------------------------------------------- 1 | framework module URITemplate { 2 | umbrella header "URITemplate-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Hyperdrive/Hyperdrive-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Hyperdrive : NSObject 3 | @end 4 | @implementation PodsDummy_Hyperdrive 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Representor/Representor-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Representor : NSObject 3 | @end 4 | @implementation PodsDummy_Representor 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/URITemplate/URITemplate-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_URITemplate : NSObject 3 | @end 4 | @implementation PodsDummy_URITemplate 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebLinking/WebLinking-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_WebLinking : NSObject 3 | @end 4 | @implementation PodsDummy_WebLinking 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Result/Result-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double ResultVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char ResultVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RxSwift/RxSwift-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double RxSwiftVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char RxSwiftVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdrive/Pods-RxHyperdrive.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_RxHyperdrive { 2 | umbrella header "Pods-RxHyperdrive-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Hyperdrive/Hyperdrive-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double HyperdriveVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char HyperdriveVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdrive/Pods-RxHyperdrive-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RxHyperdrive : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RxHyperdrive 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebLinking/WebLinking-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double WebLinkingVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char WebLinkingVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdriveTests/Pods-RxHyperdriveTests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_RxHyperdriveTests { 2 | umbrella header "Pods-RxHyperdriveTests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdriveTests/Pods-RxHyperdriveTests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_RxHyperdriveTests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_RxHyperdriveTests 5 | @end 6 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdrive/Pods-RxHyperdrive-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_RxHyperdriveVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_RxHyperdriveVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /RxHyperdrive.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Representor/Representor-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "Representor.h" 4 | 5 | FOUNDATION_EXPORT double RepresentorVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char RepresentorVersionString[]; 7 | 8 | -------------------------------------------------------------------------------- /Pods/Target Support Files/URITemplate/URITemplate-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "URITemplate.h" 4 | 5 | FOUNDATION_EXPORT double URITemplateVersionNumber; 6 | FOUNDATION_EXPORT const unsigned char URITemplateVersionString[]; 7 | 8 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdriveTests/Pods-RxHyperdriveTests-umbrella.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | 4 | FOUNDATION_EXPORT double Pods_RxHyperdriveTestsVersionNumber; 5 | FOUNDATION_EXPORT const unsigned char Pods_RxHyperdriveTestsVersionString[]; 6 | 7 | -------------------------------------------------------------------------------- /RxHyperdrive.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode7 3 | before_install: 4 | - gem install cocoapods --no-document 5 | - gem install xcpretty --no-document 6 | script: 7 | - set -o pipefail 8 | - xcodebuild -workspace RxHyperdrive.xcworkspace -scheme RxHyperdrive test -sdk macosx | xcpretty -c 9 | - pod lib lint --quick 10 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Result/Result.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Result" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/RxSwift/RxSwift.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/RxSwift" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/NAryDisposable.swift: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. 2 | // Take a look at `Preprocessor` target in RxSwift project 3 | // 4 | // NAryDisposable.tt 5 | // RxSwift 6 | // 7 | // Created by Krunoslav Zaher on 8/20/15. 8 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 9 | // 10 | 11 | import Foundation 12 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Hyperdrive/Hyperdrive.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Hyperdrive" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/Representor/Representor.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Representor" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/URITemplate/URITemplate.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/URITemplate" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/Target Support Files/WebLinking/WebLinking.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/WebLinking" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_ROOT = ${SRCROOT} 6 | SKIP_INSTALL = YES -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/ScheduledItemType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledItemType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol ScheduledItemType 12 | : Cancelable 13 | , InvocableType { 14 | func invoke() 15 | } 16 | -------------------------------------------------------------------------------- /Pods/Representor/Representor/Builder/TransitionBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TransitionBuilder.swift 3 | // Representor 4 | // 5 | // Created by Kyle Fuller on 05/11/2014. 6 | // Copyright (c) 2014 Apiary. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// A base protocol used for building transition using a builder pattern 12 | public protocol TransitionBuilderType { 13 | } 14 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Disposable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Respresents disposable resource. 13 | */ 14 | public protocol Disposable { 15 | /** 16 | Dispose resource. 17 | */ 18 | func dispose() 19 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/InvocableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InvocableType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol InvocableType { 12 | func invoke() 13 | } 14 | 15 | protocol InvocableWithValueType { 16 | typealias Value 17 | 18 | func invoke(value: Value) 19 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Concurrency/SynchronizedUnsubscribeType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedUnsubscribeType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol SynchronizedUnsubscribeType : class { 12 | typealias DisposeKey 13 | 14 | func synchronizedUnsubscribe(disposeKey: DisposeKey) 15 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Never.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Never.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Never : Producer { 12 | override func subscribe(observer: O) -> Disposable { 13 | return NopDisposable.instance 14 | } 15 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Cancelable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Cancelable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/12/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents disposable resource with state tracking. 13 | */ 14 | public protocol Cancelable : Disposable { 15 | /** 16 | - returns: Was resource disposed. 17 | */ 18 | var disposed: Bool { get } 19 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Empty.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Empty.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Empty : Producer { 12 | override func subscribe(observer: O) -> Disposable { 13 | observer.on(.Completed) 14 | return NopDisposable.instance 15 | } 16 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/AnonymousInvocable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousInvocable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct AnonymousInvocable : InvocableType { 12 | private let _action: () -> () 13 | 14 | init(_ action: () -> ()) { 15 | _action = action 16 | } 17 | 18 | func invoke() { 19 | _action() 20 | } 21 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/StableCompositeDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StableCompositeDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/12/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public final class StableCompositeDisposable { 12 | public static func create(disposable1: Disposable, _ disposable2: Disposable) -> Disposable { 13 | return BinaryDisposable(disposable1, disposable2) 14 | } 15 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Concurrency/LockOwnerType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LockOwnerType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol LockOwnerType : class, Lock { 12 | var _lock: NSRecursiveLock { get } 13 | } 14 | 15 | extension LockOwnerType { 16 | func lock() { 17 | _lock.lock() 18 | } 19 | 20 | func unlock() { 21 | _lock.unlock() 22 | } 23 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Concurrency/SynchronizedDisposeType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedDisposeType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol SynchronizedDisposeType : class, Disposable, Lock { 12 | func _synchronized_dispose() 13 | } 14 | 15 | extension SynchronizedDisposeType { 16 | func synchronizedDispose() { 17 | lock(); defer { unlock() } 18 | _synchronized_dispose() 19 | } 20 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Concurrency/SynchronizedOnType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedOnType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol SynchronizedOnType : class, ObserverType, Lock { 12 | func _synchronized_on(event: Event) 13 | } 14 | 15 | extension SynchronizedOnType { 16 | func synchronizedOn(event: Event) { 17 | lock(); defer { unlock() } 18 | _synchronized_on(event) 19 | } 20 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/DisposeBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisposeBase.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 4/4/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Base class for all disposables. 13 | */ 14 | public class DisposeBase { 15 | init() { 16 | #if TRACE_RESOURCES 17 | OSAtomicIncrement32(&resourceCount) 18 | #endif 19 | } 20 | 21 | deinit { 22 | #if TRACE_RESOURCES 23 | OSAtomicDecrement32(&resourceCount) 24 | #endif 25 | } 26 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/InvocableScheduledItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InvocableScheduledItem.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 11/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct InvocableScheduledItem : InvocableType { 12 | 13 | let _invocable: I 14 | let _state: I.Value 15 | 16 | init(invocable: I, state: I.Value) { 17 | _invocable = invocable 18 | _state = state 19 | } 20 | 21 | func invoke() { 22 | _invocable.invoke(_state) 23 | } 24 | } -------------------------------------------------------------------------------- /RxHyperdrive/RxHyperdrive.h: -------------------------------------------------------------------------------- 1 | // 2 | // RxHyperdrive.h 3 | // RxHyperdrive 4 | // 5 | // Created by Kyle Fuller on 13/09/2015. 6 | // Copyright © 2015 Cocode. All rights reserved. 7 | // 8 | 9 | @import Foundation; 10 | 11 | //! Project version number for RxHyperdrive. 12 | FOUNDATION_EXPORT double RxHyperdriveVersionNumber; 13 | 14 | //! Project version string for RxHyperdrive. 15 | FOUNDATION_EXPORT const unsigned char RxHyperdriveVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Pods/Representor/Representor/Representor.h: -------------------------------------------------------------------------------- 1 | // 2 | // Representor.h 3 | // Representor 4 | // 5 | // Created by Kyle Fuller on 04/11/2014. 6 | // Copyright (c) 2014 Apiary. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Representor. 12 | FOUNDATION_EXPORT double RepresentorVersionNumber; 13 | 14 | //! Project version string for Representor. 15 | FOUNDATION_EXPORT const unsigned char RepresentorVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/SubscriptionDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubscriptionDisposable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct SubscriptionDisposable : Disposable { 12 | private let _key: T.DisposeKey 13 | private weak var _owner: T? 14 | 15 | init(owner: T, key: T.DisposeKey) { 16 | _owner = owner 17 | _key = key 18 | } 19 | 20 | func dispose() { 21 | _owner?.synchronizedUnsubscribe(_key) 22 | } 23 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/FailWith.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FailWith.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class FailWith : Producer { 12 | private let _error: ErrorType 13 | 14 | init(error: ErrorType) { 15 | _error = error 16 | } 17 | 18 | override func subscribe(observer: O) -> Disposable { 19 | observer.on(.Error(_error)) 20 | return NopDisposable.instance 21 | } 22 | } -------------------------------------------------------------------------------- /Pods/URITemplate/URITemplate/URITemplate.h: -------------------------------------------------------------------------------- 1 | // 2 | // URITemplate.h 3 | // URITemplate 4 | // 5 | // Created by Kyle Fuller on 25/11/2014. 6 | // Copyright (c) 2014 Kyle Fuller. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for URITemplate. 12 | FOUNDATION_EXPORT double URITemplateVersionNumber; 13 | 14 | //! Project version string for URITemplate. 15 | FOUNDATION_EXPORT const unsigned char URITemplateVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/ObservableConvertibleType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableConvertibleType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 9/17/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Type that can be converted to observable sequence (`Observer`). 13 | */ 14 | public protocol ObservableConvertibleType { 15 | /** 16 | Type of elements in sequence. 17 | */ 18 | typealias E 19 | 20 | /** 21 | Converts `self` to `Observable` sequence. 22 | 23 | - returns: Observable sequence that represents `self`. 24 | */ 25 | func asObservable() -> Observable 26 | } 27 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Concurrency/SynchronizedSubscribeType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SynchronizedSubscribeType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol SynchronizedSubscribeType : class, ObservableType, Lock { 12 | func _synchronized_subscribe(observer: O) -> Disposable 13 | } 14 | 15 | extension SynchronizedSubscribeType { 16 | func synchronizedSubscribe(observer: O) -> Disposable { 17 | lock(); defer { unlock() } 18 | return _synchronized_subscribe(observer) 19 | } 20 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/NopDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NopDisposable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents a disposable that does nothing on disposal. 13 | 14 | Nop = No Operation 15 | */ 16 | public struct NopDisposable : Disposable { 17 | 18 | /** 19 | Singleton instance of `NopDisposable`. 20 | */ 21 | public static let instance: Disposable = NopDisposable() 22 | 23 | init() { 24 | 25 | } 26 | 27 | /** 28 | Does nothing. 29 | */ 30 | public func dispose() { 31 | } 32 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Sink.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sink.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/19/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Sink : SingleAssignmentDisposable { 12 | private let _observer: O 13 | 14 | final func forwardOn(event: Event) { 15 | if disposed { 16 | return 17 | } 18 | _observer.on(event) 19 | } 20 | 21 | init(observer: O) { 22 | #if TRACE_RESOURCES 23 | OSAtomicIncrement32(&resourceCount) 24 | #endif 25 | _observer = observer 26 | } 27 | 28 | deinit { 29 | #if TRACE_RESOURCES 30 | OSAtomicDecrement32(&resourceCount) 31 | #endif 32 | } 33 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/DataStructures/InfiniteSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InfiniteSequence.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Sequence that repeats `repeatedValue` infinite number of times. 13 | */ 14 | class InfiniteSequence : SequenceType { 15 | typealias Element = E 16 | typealias Generator = AnyGenerator 17 | 18 | private let _repeatedValue: E 19 | 20 | init(repeatedValue: E) { 21 | _repeatedValue = repeatedValue 22 | } 23 | 24 | func generate() -> Generator { 25 | let repeatedValue = _repeatedValue 26 | return anyGenerator { 27 | return repeatedValue 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/StartWith.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StartWith.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 4/6/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class StartWith: Producer { 12 | let elements: [Element] 13 | let source: Observable 14 | 15 | init(source: Observable, elements: [Element]) { 16 | self.source = source 17 | self.elements = elements 18 | super.init() 19 | } 20 | 21 | override func run(observer: O) -> Disposable { 22 | for e in elements { 23 | observer.on(.Next(e)) 24 | } 25 | 26 | return source.subscribe(observer) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Subjects/SubjectType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubjectType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents an object that is both an observable sequence as well as an observer. 13 | */ 14 | public protocol SubjectType : ObservableType { 15 | /** 16 | The type of the observer that represents this subject. 17 | 18 | Usually this type is type of subject itself, but it doesn't have to be. 19 | */ 20 | typealias SubjectObserverType : ObserverType 21 | 22 | /** 23 | Returns observer interface for subject. 24 | 25 | - returns: Observer interface for subject. 26 | */ 27 | func asObserver() -> SubjectObserverType 28 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/DispatchQueueSchedulerPriority.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DispatchQueueSchedulerPriority.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 7/5/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Identifies one of the global concurrent dispatch queues with specified priority. 13 | */ 14 | public enum DispatchQueueSchedulerPriority { 15 | 16 | /** 17 | Identifies global dispatch queue with `DISPATCH_QUEUE_PRIORITY_HIGH` 18 | */ 19 | case High 20 | 21 | /** 22 | Identifies global dispatch queue with `DISPATCH_QUEUE_PRIORITY_DEFAULT` 23 | */ 24 | case Default 25 | 26 | /** 27 | Identifies global dispatch queue with `DISPATCH_QUEUE_PRIORITY_LOW` 28 | */ 29 | case Low 30 | } 31 | -------------------------------------------------------------------------------- /RxHyperdrive.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |spec| 2 | spec.name = 'RxHyperdrive' 3 | spec.version = '0.1.1' 4 | spec.summary = 'RxSwift extensions for Hyperdrive, the generic Swift Web API client' 5 | spec.homepage = 'https://github.com/kylef/RxHyperdrive' 6 | spec.license = { :type => 'MIT', :file => 'LICENSE' } 7 | spec.author = { 'Kyle Fuller' => 'kyle@fuller.li' } 8 | spec.social_media_url = 'http://twitter.com/kylefuller' 9 | spec.source = { :git => 'https://github.com/kylef/RxHyperdrive.git', :tag => spec.version } 10 | spec.source_files = 'RxHyperdrive/*.{h,swift}' 11 | spec.ios.deployment_target = '8.0' 12 | spec.osx.deployment_target = '10.9' 13 | spec.watchos.deployment_target = '2.0' 14 | spec.requires_arc = true 15 | spec.dependency 'Hyperdrive', '~> 0.2.0' 16 | spec.dependency 'RxSwift', '2.0.0-beta.3' 17 | end 18 | 19 | -------------------------------------------------------------------------------- /RxHyperdriveTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Observable+Debug.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable+Debug.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/2/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | // MARK: debug 12 | 13 | extension ObservableType { 14 | 15 | /** 16 | Prints received events for all observers on standard output. 17 | 18 | - parameter identifier: Identifier that is printed together with event description to standard output. 19 | - returns: An observable sequence whose events are printed to standard output. 20 | */ 21 | @warn_unused_result(message="http://git.io/rxs.uo") 22 | public func debug(identifier: String = "\(__FILE__):\(__LINE__)") 23 | -> Observable { 24 | return Debug(source: self.asObservable(), identifier: identifier) 25 | } 26 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/ConnectableObservableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectableObservableType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents an observable sequence wrapper that can be connected and disconnected from its underlying observable sequence. 13 | */ 14 | public protocol ConnectableObservableType : ObservableType { 15 | /** 16 | 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. 17 | 18 | - returns: Disposable used to disconnect the observable wrapper from its source, causing subscribed observer to stop receiving values from the underlying observable sequence. 19 | */ 20 | func connect() -> Disposable 21 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Producer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Producer.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/20/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Producer : Observable { 12 | override init() { 13 | super.init() 14 | } 15 | 16 | override func subscribe(observer: O) -> Disposable { 17 | if !CurrentThreadScheduler.isScheduleRequired { 18 | return run(observer) 19 | } 20 | else { 21 | return CurrentThreadScheduler.instance.schedule(()) { _ in 22 | return self.run(observer) 23 | } 24 | } 25 | } 26 | 27 | func run(observer: O) -> Disposable { 28 | abstractMethod() 29 | } 30 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observers/AnonymousObserver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousObserver.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class AnonymousObserver : ObserverBase { 12 | typealias Element = ElementType 13 | 14 | typealias EventHandler = Event -> Void 15 | 16 | private let _eventHandler : EventHandler 17 | 18 | init(_ eventHandler: EventHandler) { 19 | #if TRACE_RESOURCES 20 | OSAtomicIncrement32(&resourceCount) 21 | #endif 22 | _eventHandler = eventHandler 23 | } 24 | 25 | override func onCore(event: Event) { 26 | return _eventHandler(event) 27 | } 28 | 29 | #if TRACE_RESOURCES 30 | deinit { 31 | OSAtomicDecrement32(&resourceCount) 32 | } 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /RxHyperdriveTests/RxHyperdriveTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxHyperdriveTests.swift 3 | // RxHyperdriveTests 4 | // 5 | // Created by Kyle Fuller on 13/09/2015. 6 | // Copyright © 2015 Cocode. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import Hyperdrive 11 | @testable import RxHyperdrive 12 | 13 | class RxHyperdriveTests: XCTestCase { 14 | func testReadme() { 15 | let expectation = expectationWithDescription("Request") 16 | 17 | let hyperdrive = Hyperdrive() 18 | 19 | let disposable = hyperdrive.enter("https://polls.apiblueprint.org/") 20 | .flatMap { representor in 21 | hyperdrive.request(representor.transitions["questions"]) 22 | } 23 | .subscribeNext { representor in 24 | print(representor.representors["questions"]) 25 | expectation.fulfill() 26 | } 27 | 28 | waitForExpectationsWithTimeout(5.0, handler: nil) 29 | disposable.dispose() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/ScheduledItem.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledItem.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 9/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct ScheduledItem 12 | : ScheduledItemType 13 | , InvocableType { 14 | typealias Action = T -> Disposable 15 | 16 | private let _action: Action 17 | private let _state: T 18 | 19 | private let _disposable = SingleAssignmentDisposable() 20 | 21 | var disposed: Bool { 22 | get { 23 | return _disposable.disposed 24 | } 25 | } 26 | 27 | init(action: Action, state: T) { 28 | _action = action 29 | _state = state 30 | } 31 | 32 | func invoke() { 33 | _disposable.disposable = _action(_state) 34 | } 35 | 36 | func dispose() { 37 | _disposable.dispose() 38 | } 39 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observers/ObserverBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserverBase.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class ObserverBase : Disposable, ObserverType { 12 | typealias E = ElementType 13 | 14 | private var _isStopped: Int32 = 0 15 | 16 | func on(event: Event) { 17 | switch event { 18 | case .Next: 19 | if _isStopped == 0 { 20 | onCore(event) 21 | } 22 | case .Error, .Completed: 23 | 24 | if !OSAtomicCompareAndSwap32(0, 1, &_isStopped) { 25 | return 26 | } 27 | 28 | onCore(event) 29 | } 30 | } 31 | 32 | func onCore(event: Event) { 33 | abstractMethod() 34 | } 35 | 36 | func dispose() { 37 | _isStopped = 1 38 | } 39 | } -------------------------------------------------------------------------------- /Pods/Target Support Files/Hyperdrive/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.2.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Representor/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.7.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Result/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 0.6-beta.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/URITemplate/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.3.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/WebLinking/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdrive/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/RxSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.0-beta.3 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdriveTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ${PRODUCT_NAME} 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /RxHyperdrive/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSHumanReadableCopyright 24 | Copyright © 2015 Cocode. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdrive/Pods-RxHyperdrive.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Hyperdrive.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Representor.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Result.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/RxSwift.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/URITemplate.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/WebLinking.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Hyperdrive" -framework "Representor" -framework "Result" -framework "RxSwift" -framework "URITemplate" -framework "WebLinking" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-RxHyperdrive 9 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdrive/Pods-RxHyperdrive.release.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Hyperdrive.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Representor.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Result.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/RxSwift.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/URITemplate.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/WebLinking.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Hyperdrive" -framework "Representor" -framework "Result" -framework "RxSwift" -framework "URITemplate" -framework "WebLinking" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-RxHyperdrive 9 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/ObserverType+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserverType+Extensions.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | @available(*, deprecated=2.0.0, message="Please use observer.on(event)") 12 | public func send(observer: O, _ event: Event) { 13 | observer.on(event) 14 | } 15 | 16 | @available(*, deprecated=2.0.0, message="Please use observer.on(.Next(element))") 17 | public func sendNext(observer: O, _ element: O.E) { 18 | observer.on(.Next(element)) 19 | } 20 | 21 | @available(*, deprecated=2.0.0, message="Please use observer.on(.Error(error))") 22 | public func sendError(observer: O, _ error: ErrorType) { 23 | observer.on(.Error(error)) 24 | } 25 | 26 | @available(*, deprecated=2.0.0, message="Please use observer.on(.Completed)") 27 | public func sendCompleted(observer: O) { 28 | observer.on(.Completed) 29 | } 30 | -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdriveTests/Pods-RxHyperdriveTests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Hyperdrive.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Representor.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Result.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/RxSwift.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/URITemplate.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/WebLinking.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Hyperdrive" -framework "Representor" -framework "Result" -framework "RxSwift" -framework "URITemplate" -framework "WebLinking" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-RxHyperdriveTests 9 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/Target Support Files/Pods-RxHyperdriveTests/Pods-RxHyperdriveTests.release.xcconfig: -------------------------------------------------------------------------------- 1 | CODE_SIGN_IDENTITY = 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 4 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/../Frameworks' '@loader_path/Frameworks' 5 | OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Hyperdrive.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Representor.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/Result.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/RxSwift.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/URITemplate.framework/Headers" -iquote "$CONFIGURATION_BUILD_DIR/WebLinking.framework/Headers" 6 | OTHER_LDFLAGS = $(inherited) -framework "Hyperdrive" -framework "Representor" -framework "Result" -framework "RxSwift" -framework "URITemplate" -framework "WebLinking" 7 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 8 | PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-RxHyperdriveTests 9 | PODS_ROOT = ${SRCROOT}/Pods -------------------------------------------------------------------------------- /Pods/WebLinking/README.md: -------------------------------------------------------------------------------- 1 | Web Linking 2 | =========== 3 | 4 | Swift implementation of Web Linking ([RFC5988](https://tools.ietf.org/html/rfc5988)). 5 | 6 | ## Installation 7 | 8 | [CocoaPods](http://cocoapods.org/) is the recommended installation method. 9 | 10 | ```ruby 11 | pod 'WebLinking' 12 | ``` 13 | 14 | ## Example 15 | 16 | Given the following `Link` header on an `NSHTTPURLResponse`. 17 | 18 | ``` 19 | Link: ; rel="next", 20 | ; rel="last" 21 | ``` 22 | 23 | We can find the next link on a response: 24 | 25 | ```swift 26 | if let link = response.findLink(relation: "next") { 27 | println("We have a next link with the URI: \(link.uri).") 28 | } 29 | ``` 30 | 31 | Or introspect all available links: 32 | 33 | ```swift 34 | for link in response.links { 35 | println("We have a link with the relation: \(link.relationType) to \(link.uri).") 36 | } 37 | ``` 38 | 39 | ## License 40 | 41 | Web Linking is licensed under the MIT license. See [LICENSE](LICENSE) for more 42 | info. 43 | 44 | -------------------------------------------------------------------------------- /Pods/RxSwift/LICENSE.md: -------------------------------------------------------------------------------- 1 | **The MIT License** 2 | **Copyright (c) 2015 Krunoslav Zaher** 3 | **All rights reserved.** 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Pods/Result/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Rob Rix 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kyle Fuller. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Pods/Representor/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Zdenek Nemec 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Pods/Result/Result/ResultType.swift: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 Rob Rix. All rights reserved. 2 | 3 | /// A type that can represent either failure with an error or success with a result value. 4 | public protocol ResultType { 5 | typealias Value 6 | typealias Error: ErrorType 7 | 8 | /// Constructs a successful result wrapping a `value`. 9 | init(value: Value) 10 | 11 | /// Constructs a failed result wrapping an `error`. 12 | init(error: Error) 13 | 14 | /// Case analysis for ResultType. 15 | /// 16 | /// Returns the value produced by appliying `ifFailure` to the error if self represents a failure, or `ifSuccess` to the result value if self represents a success. 17 | func analysis(@noescape ifSuccess ifSuccess: Value -> U, @noescape ifFailure: Error -> U) -> U 18 | } 19 | 20 | public extension ResultType { 21 | 22 | /// Returns the value if self represents a success, `nil` otherwise. 23 | var value: Value? { 24 | return analysis(ifSuccess: { $0 }, ifFailure: { _ in nil }) 25 | } 26 | 27 | /// Returns the error if self represents a failure, `nil` otherwise. 28 | var error: Error? { 29 | return analysis(ifSuccess: { _ in nil }, ifFailure: { $0 }) 30 | } 31 | } -------------------------------------------------------------------------------- /Pods/WebLinking/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Kyle Fuller 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Pods/Hyperdrive/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Apiary, LTD. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Pods/URITemplate/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Kyle Fuller 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/BooleanDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BooleanDisposable.swift 3 | // Rx 4 | // 5 | // Created by Junior B. on 10/29/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents a disposable resource that can be checked for disposal status. 13 | */ 14 | public class BooleanDisposable : Disposable, Cancelable { 15 | 16 | internal static let BooleanDisposableTrue = BooleanDisposable(disposed: true) 17 | private var _disposed = false 18 | 19 | /** 20 | Initializes a new instance of the `BooleanDisposable` class 21 | */ 22 | public init() { 23 | } 24 | 25 | /** 26 | Initializes a new instance of the `BooleanDisposable` class with given value 27 | */ 28 | public init(disposed: Bool) { 29 | self._disposed = disposed 30 | } 31 | 32 | /** 33 | - returns: Was resource disposed. 34 | */ 35 | public var disposed: Bool { 36 | get { 37 | return _disposed 38 | } 39 | } 40 | 41 | /** 42 | Sets the status to disposed, which can be observer through the `disposed` property. 43 | */ 44 | public func dispose() { 45 | _disposed = true 46 | } 47 | } -------------------------------------------------------------------------------- /Pods/Result/README.md: -------------------------------------------------------------------------------- 1 | # Result 2 | 3 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | [![CocoaPods](https://img.shields.io/cocoapods/v/Result.svg)](https://cocoapods.org/) 5 | 6 | This is a Swift µframework providing `Result`. 7 | 8 | `Result` values are either successful (wrapping `Value`) or failed (wrapping `Error`). This is similar to Swift’s native `Optional` type, with the addition of an error value to pass some error code, message, or object along to be logged or displayed to the user. 9 | 10 | 11 | ## Use 12 | 13 | [API documentation](http://cocoadocs.org/docsets/Result/) is in the source. 14 | 15 | 16 | ## Integration 17 | 18 | 1. Add this repository as a submodule and/or [add it to your Cartfile](https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile) if you’re using [carthage](https://github.com/Carthage/Carthage/) to manage your dependencies. 19 | 2. Drag `Result.xcodeproj` into your project or workspace. 20 | 3. Link your target against `Result.framework`. 21 | 4. Application targets should ensure that the framework gets copied into their application bundle. (Framework targets should instead require the application linking them to include Result.) 22 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Repeat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Repeat.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 9/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class RepeatElement : Producer { 12 | private let _element: Element 13 | private let _scheduler: ImmediateSchedulerType 14 | 15 | init(element: Element, scheduler: ImmediateSchedulerType) { 16 | _element = element 17 | _scheduler = scheduler 18 | } 19 | 20 | override func run(observer: O) -> Disposable { 21 | let sink = RepeatElementSink(parent: self, observer: observer) 22 | sink.disposable = sink.run() 23 | 24 | return sink 25 | } 26 | } 27 | 28 | class RepeatElementSink : Sink { 29 | typealias Parent = RepeatElement 30 | 31 | private let _parent: Parent 32 | 33 | init(parent: Parent, observer: O) { 34 | _parent = parent 35 | super.init(observer: observer) 36 | } 37 | 38 | func run() -> Disposable { 39 | return _parent._scheduler.scheduleRecursive(_parent._element) { e, recurse in 40 | self.forwardOn(.Next(e)) 41 | recurse(e) 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | A type-erased `ObservableType`. 13 | 14 | It represents a push style sequence. 15 | */ 16 | public class Observable : ObservableType { 17 | /** 18 | Type of elements in sequence. 19 | */ 20 | public typealias E = Element 21 | 22 | init() { 23 | #if TRACE_RESOURCES 24 | OSAtomicIncrement32(&resourceCount) 25 | #endif 26 | } 27 | 28 | public func subscribe(observer: O) -> Disposable { 29 | abstractMethod() 30 | } 31 | 32 | public func asObservable() -> Observable { 33 | return self 34 | } 35 | 36 | deinit { 37 | #if TRACE_RESOURCES 38 | OSAtomicDecrement32(&resourceCount) 39 | #endif 40 | } 41 | 42 | // this is kind of ugly I know :( 43 | // Swift compiler reports "Not supported yet" when trying to override protocol extensions, so ¯\_(ツ)_/¯ 44 | 45 | /** 46 | Optimizations for map operator 47 | */ 48 | internal func composeMap(selector: Element throws -> R) -> Observable { 49 | return Map(source: self, selector: selector) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/ImmediateScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImmediateScheduler.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/17/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents an object that schedules units of work to run immediately on the current thread. 13 | */ 14 | private class ImmediateScheduler : ImmediateSchedulerType { 15 | 16 | private let _asyncLock = AsyncLock() 17 | 18 | /** 19 | Schedules an action to be executed immediatelly. 20 | 21 | In case `schedule` is called recursively from inside of `action` callback, scheduled `action` will be enqueued 22 | and executed after current `action`. (`AsyncLock` behavior) 23 | 24 | - parameter state: State passed to the action to be executed. 25 | - parameter action: Action to be executed. 26 | - returns: The disposable object used to cancel the scheduled action (best effort). 27 | */ 28 | func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable { 29 | let disposable = SingleAssignmentDisposable() 30 | _asyncLock.invoke(AnonymousInvocable { 31 | if disposable.disposed { 32 | return 33 | } 34 | disposable.disposable = action(state) 35 | }) 36 | 37 | return disposable 38 | } 39 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/AddRef.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AddRef.swift 3 | // Rx 4 | // 5 | // Created by Junior B. on 30/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class AddRefSink : Sink, ObserverType { 12 | typealias Element = O.E 13 | 14 | override init(observer: O) { 15 | super.init(observer: observer) 16 | } 17 | 18 | func on(event: Event) { 19 | switch event { 20 | case .Next(_): 21 | forwardOn(event) 22 | case .Completed, .Error(_): 23 | forwardOn(event) 24 | dispose() 25 | } 26 | } 27 | } 28 | 29 | class AddRef : Producer { 30 | typealias EventHandler = Event throws -> Void 31 | 32 | private let _source: Observable 33 | private let _refCount: RefCountDisposable 34 | 35 | init(source: Observable, refCount: RefCountDisposable) { 36 | _source = source 37 | _refCount = refCount 38 | } 39 | 40 | override func run(observer: O) -> Disposable { 41 | let releaseDisposable = _refCount.retain() 42 | let sink = AddRefSink(observer: observer) 43 | sink.disposable = StableCompositeDisposable.create(releaseDisposable, _source.subscribeSafe(sink)) 44 | 45 | return sink 46 | } 47 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/ObserverType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserverType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Supports push-style iteration over an observable sequence. 13 | */ 14 | public protocol ObserverType { 15 | /** 16 | The type of elements in sequence that observer can observe. 17 | */ 18 | typealias E 19 | 20 | /** 21 | Notify observer about sequence event. 22 | 23 | - parameter event: Event that occured. 24 | */ 25 | func on(event: Event) 26 | } 27 | 28 | /** 29 | Convienence API extensions to provide alternate next, error, completed events 30 | */ 31 | public extension ObserverType { 32 | 33 | /** 34 | Convienence method equivalent to `on(.Next(element: E))` 35 | 36 | - parameter element: Next element to send to observer(s) 37 | */ 38 | final func onNext(element: E) { 39 | on(.Next(element)) 40 | } 41 | 42 | /** 43 | Convienence method equivalent to `on(.Completed)` 44 | */ 45 | final func onCompleted() { 46 | on(.Completed) 47 | } 48 | 49 | /** 50 | Convienence method equivalent to `on(.Error(error: ErrorType))` 51 | - parameter error: ErrorType to send to observer(s) 52 | */ 53 | final func onError(error: ErrorType) { 54 | on(.Error(error)) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Pods/URITemplate/README.md: -------------------------------------------------------------------------------- 1 | URITemplate 2 | =========== 3 | 4 | Swift implementation of URI Template ([RFC6570](https://tools.ietf.org/html/rfc6570)). 5 | 6 | ## Installation 7 | 8 | [CocoaPods](http://cocoapods.org/) is the recommended installation method. 9 | 10 | ```ruby 11 | pod 'URITemplate' 12 | ``` 13 | 14 | ## Example 15 | 16 | ### Expanding a URI Template 17 | 18 | ```swift 19 | let template = URITemplate(template: "https://api.github.com/repos/{owner}/{repo}/") 20 | let url = template.expand(["owner": "kylef", "repo": "URITemplate.swift"]) 21 | => "https://api.github.com/repos/kylef/URITemplate.swift/" 22 | ``` 23 | 24 | ### Determine which variables are in a template 25 | 26 | ```swift 27 | let variables = template.variables 28 | => ["owner", "repo"] 29 | ``` 30 | 31 | ### Extract the variables used in a given URL 32 | 33 | ```swift 34 | let variables = template.extract("https://api.github.com/repos/kylef/PathKit/") 35 | => ["owner":"kylef", "repo":"PathKit"] 36 | ``` 37 | 38 | ## [RFC6570](https://tools.ietf.org/html/rfc6570) 39 | 40 | The URITemplate library follows the [test suite](https://github.com/uri-templates/uritemplate-test). 41 | 42 | We have full support for level 4 of RFC6570 when expanding a template and retrieving the variables in a template. 43 | 44 | For extraction of variables from an already expanded template, level 3 is supported. 45 | 46 | ## License 47 | 48 | URITemplate is licensed under the MIT license. See [LICENSE](LICENSE) for more 49 | info. 50 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/ToArray.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ToArray.swift 3 | // Rx 4 | // 5 | // Created by Junior B. on 20/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class ToArraySink : Sink, ObserverType { 12 | typealias Parent = ToArray 13 | 14 | let _parent: Parent 15 | var _list = Array() 16 | 17 | init(parent: Parent, observer: O) { 18 | _parent = parent 19 | 20 | super.init(observer: observer) 21 | } 22 | 23 | func on(event: Event) { 24 | switch event { 25 | case .Next(let value): 26 | self._list.append(value) 27 | case .Error(let e): 28 | forwardOn(.Error(e)) 29 | self.dispose() 30 | case .Completed: 31 | forwardOn(.Next(_list)) 32 | forwardOn(.Completed) 33 | self.dispose() 34 | } 35 | } 36 | } 37 | 38 | class ToArray : Producer<[SourceType]> { 39 | let _source: Observable 40 | 41 | init(source: Observable) { 42 | _source = source 43 | } 44 | 45 | override func run(observer: O) -> Disposable { 46 | let sink = ToArraySink(parent: self, observer: observer) 47 | sink.disposable = _source.subscribe(sink) 48 | return sink 49 | } 50 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/RxBox.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxBox.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/22/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Creates immutable reference wrapper for any type. 13 | */ 14 | public class RxBox : CustomDebugStringConvertible { 15 | /** 16 | Wrapped value 17 | */ 18 | public let value : T 19 | 20 | /** 21 | Creates reference wrapper for `value`. 22 | 23 | - parameter value: Value to wrap. 24 | */ 25 | public init (_ value: T) { 26 | self.value = value 27 | } 28 | } 29 | 30 | extension RxBox { 31 | /** 32 | - returns: Box description. 33 | */ 34 | public var debugDescription: String { 35 | get { 36 | return "Box(\(self.value))" 37 | } 38 | } 39 | } 40 | 41 | /** 42 | Creates mutable reference wrapper for any type. 43 | */ 44 | public class RxMutableBox : CustomDebugStringConvertible { 45 | /** 46 | Wrapped value 47 | */ 48 | public var value : T 49 | 50 | /** 51 | Creates reference wrapper for `value`. 52 | 53 | - parameter value: Value to wrap. 54 | */ 55 | public init (_ value: T) { 56 | self.value = value 57 | } 58 | } 59 | 60 | extension RxMutableBox { 61 | /** 62 | - returns: Box description. 63 | */ 64 | public var debugDescription: String { 65 | get { 66 | return "MutatingBox(\(self.value))" 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Do.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Do.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/21/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class DoSink : Sink, ObserverType { 12 | typealias Element = O.E 13 | typealias Parent = Do 14 | 15 | private let _parent: Parent 16 | 17 | init(parent: Parent, observer: O) { 18 | _parent = parent 19 | super.init(observer: observer) 20 | } 21 | 22 | func on(event: Event) { 23 | do { 24 | try _parent._eventHandler(event) 25 | forwardOn(event) 26 | if event.isStopEvent { 27 | dispose() 28 | } 29 | } 30 | catch let error { 31 | forwardOn(.Error(error)) 32 | dispose() 33 | } 34 | } 35 | } 36 | 37 | class Do : Producer { 38 | typealias EventHandler = Event throws -> Void 39 | 40 | private let _source: Observable 41 | private let _eventHandler: EventHandler 42 | 43 | init(source: Observable, eventHandler: EventHandler) { 44 | _source = source 45 | _eventHandler = eventHandler 46 | } 47 | 48 | override func run(observer: O) -> Disposable { 49 | let sink = DoSink(parent: self, observer: observer) 50 | sink.disposable = _source.subscribe(sink) 51 | return sink 52 | } 53 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Rx.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/14/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if TRACE_RESOURCES 12 | /** 13 | Counts internal Rx resources (Observables, Observers, Disposables ...). 14 | 15 | It provides a really simple way to detect leaks early during development. 16 | */ 17 | public var resourceCount: Int32 = 0 18 | #endif 19 | 20 | // Swift doesn't have a concept of abstract metods. 21 | // This function is being used as a runtime check that abstract methods aren't being called. 22 | @noreturn func abstractMethod() -> Void { 23 | rxFatalError("Abstract method") 24 | } 25 | 26 | @noreturn func rxFatalError(lastMessage: String) { 27 | // The temptation to comment this line is great, but please don't, it's for your own good. The choice is yours. 28 | fatalError(lastMessage) 29 | } 30 | 31 | func incrementChecked(inout i: Int) throws -> Int { 32 | if i == Int.max { 33 | throw RxError.Overflow 34 | } 35 | let result = i 36 | i += 1 37 | return result 38 | } 39 | 40 | func decrementChecked(inout i: Int) throws -> Int { 41 | if i == Int.min { 42 | throw RxError.Overflow 43 | } 44 | let result = i 45 | i -= 1 46 | return result 47 | } 48 | 49 | extension NSObject { 50 | func rx_synchronized(@noescape action: () -> T) -> T { 51 | objc_sync_enter(self) 52 | let result = action() 53 | objc_sync_exit(self) 54 | return result 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Pods/Representor/Representor/Transition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Transition.swift 3 | // Representor 4 | // 5 | // Created by Kyle Fuller on 04/11/2014. 6 | // Copyright (c) 2014 Apiary. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct InputProperty : Equatable { 12 | public let title:String? 13 | 14 | public let defaultValue:T? 15 | public let value:T? 16 | public let required:Bool? 17 | 18 | // TODO: Define validators 19 | 20 | public init(title:String? = nil, value:T? = nil, defaultValue:T? = nil, required:Bool? = nil) { 21 | self.title = title 22 | self.value = value 23 | self.defaultValue = defaultValue 24 | self.required = required 25 | } 26 | } 27 | 28 | public func ==(lhs:InputProperty, rhs:InputProperty) -> Bool { 29 | return ( 30 | lhs.title == rhs.title && 31 | lhs.defaultValue as? NSObject == rhs.defaultValue as? NSObject && 32 | lhs.value as? NSObject == rhs.value as? NSObject && 33 | lhs.required == rhs.required 34 | ) 35 | } 36 | 37 | public typealias InputProperties = [String:InputProperty] 38 | 39 | /** Transition instances encapsulate information about interacting with links and forms. */ 40 | public protocol TransitionType : Equatable, Hashable { 41 | typealias Builder = TransitionBuilderType 42 | 43 | init(uri:String, attributes:InputProperties?, parameters:InputProperties?) 44 | init(uri:String, _ block:((builder:Builder) -> ())) 45 | 46 | var uri:String { get } 47 | 48 | var attributes:InputProperties { get } 49 | var parameters:InputProperties { get } 50 | } 51 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/ScopedDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScopedDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/2/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension Disposable { 12 | /** 13 | Returns `ScopedDispose` that will dispose `self` when execution exits current block. 14 | 15 | **If the reference to returned instance isn't named, it will be deallocated 16 | immediately and subscription will be immediately disposed.** 17 | 18 | Example usage: 19 | 20 | let disposeOnExit = disposable.scopedDispose() 21 | 22 | - returns: `ScopedDisposable` that will dispose `self` on `deinit`. 23 | */ 24 | public func scopedDispose() -> ScopedDisposable { 25 | return ScopedDisposable(disposable: self) 26 | } 27 | } 28 | 29 | 30 | /** 31 | `ScopedDisposable` will dispose `disposable` on `deinit`. 32 | 33 | This returns ARC (RAII) like resource management to `RxSwift`. 34 | */ 35 | public class ScopedDisposable : DisposeBase { 36 | private var _disposable: Disposable? 37 | 38 | /** 39 | Initializes new instance with a single disposable. 40 | 41 | - parameter disposable: `Disposable` that will be disposed on scope exit. 42 | */ 43 | public init(disposable: Disposable) { 44 | _disposable = disposable 45 | } 46 | 47 | /** 48 | This is intentionally private. 49 | */ 50 | func dispose() { 51 | _disposable?.dispose() 52 | } 53 | 54 | deinit { 55 | dispose() 56 | } 57 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/BinaryDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/12/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents two disposable resources that are disposed together. 13 | */ 14 | public final class BinaryDisposable : DisposeBase, Cancelable { 15 | 16 | private var _disposed: Int32 = 0 17 | 18 | // state 19 | private var _disposable1: Disposable? 20 | private var _disposable2: Disposable? 21 | 22 | /** 23 | - returns: Was resource disposed. 24 | */ 25 | public var disposed: Bool { 26 | get { 27 | return _disposed > 0 28 | } 29 | } 30 | 31 | /** 32 | Constructs new binary disposable from two disposables. 33 | 34 | - parameter disposable1: First disposable 35 | - parameter disposable2: Second disposable 36 | */ 37 | init(_ disposable1: Disposable, _ disposable2: Disposable) { 38 | _disposable1 = disposable1 39 | _disposable2 = disposable2 40 | super.init() 41 | } 42 | 43 | /** 44 | Calls the disposal action if and only if the current instance hasn't been disposed yet. 45 | 46 | After invoking disposal action, disposal action will be dereferenced. 47 | */ 48 | public func dispose() { 49 | if OSAtomicCompareAndSwap32(0, 1, &_disposed) { 50 | _disposable1?.dispose() 51 | _disposable2?.dispose() 52 | _disposable1 = nil 53 | _disposable2 = nil 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/AnonymousDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousDisposable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents an Action-based disposable. 13 | 14 | When dispose method is called, disposal action will be dereferenced. 15 | */ 16 | public final class AnonymousDisposable : DisposeBase, Cancelable { 17 | public typealias DisposeAction = () -> Void 18 | 19 | private var _disposed: Int32 = 0 20 | private var _disposeAction: DisposeAction? 21 | 22 | /** 23 | - returns: Was resource disposed. 24 | */ 25 | public var disposed: Bool { 26 | get { 27 | return _disposed == 1 28 | } 29 | } 30 | 31 | /** 32 | Constructs a new disposable with the given action used for disposal. 33 | 34 | - parameter disposeAction: Disposal action which will be run upon calling `dispose`. 35 | */ 36 | public init(_ disposeAction: DisposeAction) { 37 | _disposeAction = disposeAction 38 | super.init() 39 | } 40 | 41 | /** 42 | Calls the disposal action if and only if the current instance hasn't been disposed yet. 43 | 44 | After invoking disposal action, disposal action will be dereferenced. 45 | */ 46 | public func dispose() { 47 | if OSAtomicCompareAndSwap32(0, 1, &_disposed) { 48 | assert(_disposed == 1) 49 | 50 | if let action = _disposeAction { 51 | _disposeAction = nil 52 | action() 53 | } 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/ImmediateSchedulerType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImmediateSchedulerType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/31/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents an object that immediately schedules units of work. 13 | */ 14 | public protocol ImmediateSchedulerType { 15 | /** 16 | Schedules an action to be executed immediatelly. 17 | 18 | - parameter state: State passed to the action to be executed. 19 | - parameter action: Action to be executed. 20 | - returns: The disposable object used to cancel the scheduled action (best effort). 21 | */ 22 | func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable 23 | } 24 | 25 | extension ImmediateSchedulerType { 26 | /** 27 | Schedules an action to be executed recursively. 28 | 29 | - parameter state: State passed to the action to be executed. 30 | - parameter action: Action to execute recursively. The last parameter passed to the action is used to trigger recursive scheduling of the action, passing in recursive invocation state. 31 | - returns: The disposable object used to cancel the scheduled action (best effort). 32 | */ 33 | public func scheduleRecursive(state: State, action: (state: State, recurse: (State) -> ()) -> ()) -> Disposable { 34 | let recursiveScheduler = RecursiveImmediateScheduler(action: action, scheduler: self) 35 | 36 | recursiveScheduler.schedule(state) 37 | 38 | return AnonymousDisposable { 39 | recursiveScheduler.dispose() 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/DelaySubscription.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DelaySubscription.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/14/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class DelaySubscriptionSink 12 | : Sink 13 | , ObserverType { 14 | typealias Parent = DelaySubscription 15 | typealias E = O.E 16 | 17 | private let _parent: Parent 18 | 19 | init(parent: Parent, observer: O) { 20 | _parent = parent 21 | super.init(observer: observer) 22 | } 23 | 24 | func on(event: Event) { 25 | forwardOn(event) 26 | if event.isStopEvent { 27 | dispose() 28 | } 29 | } 30 | 31 | } 32 | 33 | class DelaySubscription: Producer { 34 | typealias TimeInterval = S.TimeInterval 35 | 36 | private let _source: Observable 37 | private let _dueTime: TimeInterval 38 | private let _scheduler: S 39 | 40 | init(source: Observable, dueTime: TimeInterval, scheduler: S) { 41 | _source = source 42 | _dueTime = dueTime 43 | _scheduler = scheduler 44 | } 45 | 46 | override func run(observer: O) -> Disposable { 47 | let sink = DelaySubscriptionSink(parent: self, observer: observer) 48 | sink.disposable = _scheduler.scheduleRelative((), dueTime: _dueTime) { _ in 49 | return self._source.subscribe(sink) 50 | } 51 | 52 | return sink 53 | } 54 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/AnonymousObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousObservable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Darwin 11 | 12 | class AnonymousObservableSink : Sink, ObserverType { 13 | typealias E = O.E 14 | typealias Parent = AnonymousObservable 15 | 16 | // state 17 | private var _isStopped: Int32 = 0 18 | 19 | override init(observer: O) { 20 | super.init(observer: observer) 21 | } 22 | 23 | func on(event: Event) { 24 | switch event { 25 | case .Next: 26 | if _isStopped == 1 { 27 | return 28 | } 29 | forwardOn(event) 30 | case .Error, .Completed: 31 | if OSAtomicCompareAndSwap32(0, 1, &_isStopped) { 32 | forwardOn(event) 33 | dispose() 34 | } 35 | } 36 | } 37 | 38 | func run(parent: Parent) -> Disposable { 39 | return parent._subscribeHandler(AnyObserver(self)) 40 | } 41 | } 42 | 43 | class AnonymousObservable : Producer { 44 | typealias SubscribeHandler = (AnyObserver) -> Disposable 45 | 46 | let _subscribeHandler: SubscribeHandler 47 | 48 | init(_ subscribeHandler: SubscribeHandler) { 49 | _subscribeHandler = subscribeHandler 50 | } 51 | 52 | override func run(observer: O) -> Disposable { 53 | let sink = AnonymousObservableSink(observer: observer) 54 | sink.disposable = sink.run(self) 55 | return sink 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Hyperdrive (0.2.0): 3 | - Representor (~> 0.7.0) 4 | - Result (~> 0.6-beta.1) 5 | - URITemplate (~> 1.3) 6 | - WebLinking (~> 1.0.0) 7 | - Representor (0.7.0): 8 | - Representor/Core (= 0.7.0) 9 | - Representor/HTTP (= 0.7.0) 10 | - Representor/Core (0.7.0) 11 | - Representor/HTTP (0.7.0): 12 | - Representor/HTTP/Adapters (= 0.7.0) 13 | - Representor/HTTP/Deserialization (= 0.7.0) 14 | - Representor/HTTP/Transition (= 0.7.0) 15 | - Representor/HTTP/Adapters (0.7.0): 16 | - Representor/HTTP/Adapters/APIBlueprint (= 0.7.0) 17 | - Representor/HTTP/Adapters/HAL (= 0.7.0) 18 | - Representor/HTTP/Adapters/Siren (= 0.7.0) 19 | - Representor/HTTP/Adapters/APIBlueprint (0.7.0): 20 | - Representor/HTTP/Transition 21 | - Representor/HTTP/Adapters/HAL (0.7.0): 22 | - Representor/HTTP/Transition 23 | - Representor/HTTP/Adapters/Siren (0.7.0): 24 | - Representor/HTTP/Transition 25 | - Representor/HTTP/Deserialization (0.7.0): 26 | - Representor/HTTP/Adapters/HAL 27 | - Representor/HTTP/Adapters/Siren 28 | - Representor/HTTP/Transition 29 | - Representor/HTTP/Transition (0.7.0): 30 | - Representor/Core 31 | - Result (0.6-beta.1) 32 | - RxSwift (2.0.0-beta.3) 33 | - URITemplate (1.3.0) 34 | - WebLinking (1.0.0) 35 | 36 | DEPENDENCIES: 37 | - Hyperdrive (~> 0.2.0) 38 | - RxSwift (= 2.0.0-beta.3) 39 | 40 | SPEC CHECKSUMS: 41 | Hyperdrive: 7362f6cf0f450db9af34fb5cdf54ef4ff8f06322 42 | Representor: 487b4efb0a39c2c2db258d40846d9915cd69b770 43 | Result: af24e3e57ab81005ec4221a53fd36dc1e7a52869 44 | RxSwift: 19fbe885b404d1d36d42ac8535134739a9b42952 45 | URITemplate: 0ebbec80d1eb59a89e29db9b14c99d5908d3e574 46 | WebLinking: d5b5ab4f7305bcf29821deb5cecd775f6c37efae 47 | 48 | COCOAPODS: 0.39.0 49 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Error.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Error.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/28/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | let RxErrorDomain = "RxErrorDomain" 12 | let RxCompositeFailures = "RxCompositeFailures" 13 | 14 | /** 15 | Generic Rx error codes. 16 | */ 17 | public enum RxError 18 | : ErrorType 19 | , CustomDebugStringConvertible { 20 | /** 21 | Unknown error occured. 22 | */ 23 | case Unknown 24 | /** 25 | Performing an action on disposed object. 26 | */ 27 | case Disposed(object: AnyObject) 28 | /** 29 | Aritmetic overflow error. 30 | */ 31 | case Overflow 32 | /** 33 | Argument out of range error. 34 | */ 35 | case ArgumentOutOfRange 36 | /** 37 | Sequence doesn't contain any element. 38 | */ 39 | case NoElements 40 | /** 41 | Sequence contains more then one element. 42 | */ 43 | case MoreThanOneElement 44 | } 45 | 46 | public extension RxError { 47 | /** 48 | A textual representation of `self`, suitable for debugging. 49 | */ 50 | public var debugDescription: String { 51 | switch self { 52 | case .Unknown: 53 | return "Unknown error occured." 54 | case .Disposed(let object): 55 | return "Object `\(object)` was already disposed." 56 | case .Overflow: 57 | return "Arithmetic overflow occured." 58 | case .ArgumentOutOfRange: 59 | return "Argument out of range." 60 | case .NoElements: 61 | return "Sequence doesn't contain any element." 62 | case .MoreThanOneElement: 63 | return "Sequence contains more then one element." 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Hyperdrive (0.2.0): 3 | - Representor (~> 0.7.0) 4 | - Result (~> 0.6-beta.1) 5 | - URITemplate (~> 1.3) 6 | - WebLinking (~> 1.0.0) 7 | - Representor (0.7.0): 8 | - Representor/Core (= 0.7.0) 9 | - Representor/HTTP (= 0.7.0) 10 | - Representor/Core (0.7.0) 11 | - Representor/HTTP (0.7.0): 12 | - Representor/HTTP/Adapters (= 0.7.0) 13 | - Representor/HTTP/Deserialization (= 0.7.0) 14 | - Representor/HTTP/Transition (= 0.7.0) 15 | - Representor/HTTP/Adapters (0.7.0): 16 | - Representor/HTTP/Adapters/APIBlueprint (= 0.7.0) 17 | - Representor/HTTP/Adapters/HAL (= 0.7.0) 18 | - Representor/HTTP/Adapters/Siren (= 0.7.0) 19 | - Representor/HTTP/Adapters/APIBlueprint (0.7.0): 20 | - Representor/HTTP/Transition 21 | - Representor/HTTP/Adapters/HAL (0.7.0): 22 | - Representor/HTTP/Transition 23 | - Representor/HTTP/Adapters/Siren (0.7.0): 24 | - Representor/HTTP/Transition 25 | - Representor/HTTP/Deserialization (0.7.0): 26 | - Representor/HTTP/Adapters/HAL 27 | - Representor/HTTP/Adapters/Siren 28 | - Representor/HTTP/Transition 29 | - Representor/HTTP/Transition (0.7.0): 30 | - Representor/Core 31 | - Result (0.6-beta.1) 32 | - RxSwift (2.0.0-beta.3) 33 | - URITemplate (1.3.0) 34 | - WebLinking (1.0.0) 35 | 36 | DEPENDENCIES: 37 | - Hyperdrive (~> 0.2.0) 38 | - RxSwift (= 2.0.0-beta.3) 39 | 40 | SPEC CHECKSUMS: 41 | Hyperdrive: 7362f6cf0f450db9af34fb5cdf54ef4ff8f06322 42 | Representor: 487b4efb0a39c2c2db258d40846d9915cd69b770 43 | Result: af24e3e57ab81005ec4221a53fd36dc1e7a52869 44 | RxSwift: 19fbe885b404d1d36d42ac8535134739a9b42952 45 | URITemplate: 0ebbec80d1eb59a89e29db9b14c99d5908d3e574 46 | WebLinking: d5b5ab4f7305bcf29821deb5cecd775f6c37efae 47 | 48 | COCOAPODS: 0.39.0 49 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Debug.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Debug.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/2/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Debug_ : Sink, ObserverType { 12 | typealias Element = O.E 13 | typealias Parent = Debug 14 | 15 | private let _parent: Parent 16 | 17 | init(parent: Parent, observer: O) { 18 | _parent = parent 19 | super.init(observer: observer) 20 | } 21 | 22 | func on(event: Event) { 23 | let maxEventTextLength = 40 24 | let eventText = "\(event)" 25 | let eventNormalized = eventText.characters.count > maxEventTextLength 26 | ? String(eventText.characters.prefix(maxEventTextLength / 2)) + "..." + String(eventText.characters.suffix(maxEventTextLength / 2)) 27 | : eventText 28 | print("[\(_parent._identifier)] -> Event \(eventNormalized)") 29 | forwardOn(event) 30 | } 31 | 32 | override func dispose() { 33 | print("[\(_parent._identifier)] dispose") 34 | super.dispose() 35 | } 36 | } 37 | 38 | class Debug : Producer { 39 | private let _identifier: String 40 | 41 | private let _source: Observable 42 | 43 | init(source: Observable, identifier: String) { 44 | _identifier = identifier 45 | _source = source 46 | } 47 | 48 | override func run(observer: O) -> Disposable { 49 | print("[\(_identifier)] subscribed") 50 | let sink = Debug_(parent: self, observer: observer) 51 | sink.disposable = _source.subscribe(sink) 52 | return sink 53 | } 54 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Sequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Sequence.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 11/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class SequenceSink : Sink { 12 | typealias Parent = Sequence 13 | 14 | private let _parent: Parent 15 | 16 | init(parent: Parent, observer: O) { 17 | _parent = parent 18 | super.init(observer: observer) 19 | } 20 | 21 | func run() -> Disposable { 22 | return _parent._scheduler!.scheduleRecursive((0, _parent._elements)) { (state, recurse) in 23 | if state.0 < state.1.count { 24 | self.forwardOn(.Next(state.1[state.0])) 25 | recurse((state.0 + 1, state.1)) 26 | } 27 | else { 28 | self.forwardOn(.Completed) 29 | } 30 | } 31 | } 32 | } 33 | 34 | class Sequence : Producer { 35 | private let _elements: [E] 36 | private let _scheduler: ImmediateSchedulerType? 37 | 38 | init(elements: [E], scheduler: ImmediateSchedulerType?) { 39 | _elements = elements 40 | _scheduler = scheduler 41 | } 42 | 43 | override func subscribe(observer: O) -> Disposable { 44 | // optimized version without scheduler 45 | guard _scheduler != nil else { 46 | for element in _elements { 47 | observer.on(.Next(element)) 48 | } 49 | 50 | observer.on(.Completed) 51 | return NopDisposable.instance 52 | } 53 | 54 | let sink = SequenceSink(parent: self, observer: observer) 55 | sink.disposable = sink.run() 56 | return sink 57 | } 58 | } -------------------------------------------------------------------------------- /RxHyperdrive/RxHyperdrive.swift: -------------------------------------------------------------------------------- 1 | import RxSwift 2 | import Hyperdrive 3 | import Representor 4 | 5 | extension Hyperdrive { 6 | public func enter(uri:String) -> Observable> { 7 | return create { observer in 8 | self.enter(uri) { result in 9 | switch result { 10 | case .Success(let representor): 11 | observer.on(.Next(representor)) 12 | observer.on(.Completed) 13 | case .Failure(let error): 14 | observer.on(.Error(error)) 15 | } 16 | } 17 | 18 | return AnonymousDisposable {} 19 | } 20 | } 21 | 22 | public func request(transition:HTTPTransition, parameters:[String:AnyObject]? = nil, attributes:[String:AnyObject]? = nil) -> Observable> { 23 | return create { observer in 24 | self.request(transition, parameters: parameters, attributes: attributes) { result in 25 | switch result { 26 | case .Success(let representor): 27 | observer.on(.Next(representor)) 28 | observer.on(.Completed) 29 | case .Failure(let error): 30 | observer.on(.Error(error)) 31 | } 32 | } 33 | 34 | return AnonymousDisposable {} 35 | } 36 | } 37 | 38 | public func request(transition:HTTPTransition?, parameters:[String:AnyObject]? = nil, attributes:[String:AnyObject]? = nil) -> Observable> { 39 | if let transition = transition { 40 | return request(transition, parameters: parameters, attributes: attributes) 41 | } 42 | 43 | return create { observer in 44 | let error = NSError(domain: Hyperdrive.errorDomain, code: 0, userInfo: [NSLocalizedFailureReasonErrorKey: "Given transition was nil."]) 45 | observer.on(.Error(error)) 46 | return AnonymousDisposable {} 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Range.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Range.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 9/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class RangeProducer<_CompilerWorkaround> : Producer { 12 | private let _start: Int 13 | private let _count: Int 14 | private let _scheduler: ImmediateSchedulerType 15 | 16 | init(start: Int, count: Int, scheduler: ImmediateSchedulerType) { 17 | if count < 0 { 18 | rxFatalError("count can't be negative") 19 | } 20 | 21 | if start &+ (count - 1) < start { 22 | rxFatalError("overflow of count") 23 | } 24 | 25 | _start = start 26 | _count = count 27 | _scheduler = scheduler 28 | } 29 | 30 | override func run(observer: O) -> Disposable { 31 | let sink = RangeSink(parent: self, observer: observer) 32 | sink.disposable = sink.run() 33 | return sink 34 | } 35 | } 36 | 37 | class RangeSink<_CompilerWorkaround, O: ObserverType where O.E == Int> : Sink { 38 | typealias Parent = RangeProducer<_CompilerWorkaround> 39 | 40 | private let _parent: Parent 41 | 42 | init(parent: Parent, observer: O) { 43 | _parent = parent 44 | super.init(observer: observer) 45 | } 46 | 47 | func run() -> Disposable { 48 | return _parent._scheduler.scheduleRecursive(0) { i, recurse in 49 | if i < self._parent._count { 50 | self.forwardOn(.Next(self._parent._start + i)) 51 | recurse(i + 1) 52 | } 53 | else { 54 | self.forwardOn(.Completed) 55 | self.dispose() 56 | } 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Deferred.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Deferred.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/19/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class DeferredSink : Sink, ObserverType { 12 | typealias E = O.E 13 | typealias Parent = Deferred 14 | 15 | private let _parent: Parent 16 | 17 | init(parent: Parent, observer: O) { 18 | _parent = parent 19 | super.init(observer: observer) 20 | } 21 | 22 | func run() -> Disposable { 23 | do { 24 | let result = try _parent.eval() 25 | return result.subscribe(self) 26 | } 27 | catch let e { 28 | forwardOn(.Error(e)) 29 | dispose() 30 | return NopDisposable.instance 31 | } 32 | } 33 | 34 | func on(event: Event) { 35 | forwardOn(event) 36 | 37 | switch event { 38 | case .Next: 39 | break 40 | case .Error: 41 | dispose() 42 | case .Completed: 43 | dispose() 44 | } 45 | } 46 | } 47 | 48 | class Deferred : Producer { 49 | typealias Factory = () throws -> Observable 50 | 51 | private let _observableFactory : Factory 52 | 53 | init(observableFactory: Factory) { 54 | _observableFactory = observableFactory 55 | } 56 | 57 | override func run(observer: O) -> Disposable { 58 | let sink = DeferredSink(parent: self, observer: observer) 59 | sink.disposable = sink.run() 60 | return sink 61 | } 62 | 63 | func eval() throws -> Observable { 64 | return try _observableFactory() 65 | } 66 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Concat.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Concat.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/21/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | class ConcatSink 13 | : TailRecursiveSink 14 | , ObserverType { 15 | typealias Element = O.E 16 | 17 | override init(observer: O) { 18 | super.init(observer: observer) 19 | } 20 | 21 | func on(event: Event){ 22 | switch event { 23 | case .Next: 24 | forwardOn(event) 25 | case .Error: 26 | forwardOn(event) 27 | dispose() 28 | case .Completed: 29 | schedule(.MoveNext) 30 | } 31 | } 32 | 33 | override func subscribeToNext(source: Observable) -> Disposable { 34 | return source.subscribe(self) 35 | } 36 | 37 | override func extract(observable: Observable) -> S.Generator? { 38 | if let source = observable as? Concat { 39 | return source._sources.generate() 40 | } 41 | else { 42 | return nil 43 | } 44 | } 45 | } 46 | 47 | class Concat : Producer { 48 | typealias Element = S.Generator.Element.E 49 | 50 | private let _sources: S 51 | 52 | init(sources: S) { 53 | _sources = sources 54 | } 55 | 56 | override func run(observer: O) -> Disposable { 57 | let sink = ConcatSink(observer: observer) 58 | sink.disposable = sink.run(_sources.generate()) 59 | return sink 60 | } 61 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/ScheduledDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ScheduledDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | private let disposeScheduledDisposable: ScheduledDisposable -> Disposable = { sd in 12 | sd.disposeInner() 13 | return NopDisposable.instance 14 | } 15 | 16 | /** 17 | Represents a disposable resource whose disposal invocation will be scheduled on the specified scheduler. 18 | */ 19 | public class ScheduledDisposable : Cancelable { 20 | public let scheduler: ImmediateSchedulerType 21 | 22 | private var _disposed: Int32 = 0 23 | 24 | // state 25 | private var _disposable: Disposable? 26 | 27 | /** 28 | - returns: Was resource disposed. 29 | */ 30 | public var disposed: Bool { 31 | get { 32 | return _disposed == 1 33 | } 34 | } 35 | 36 | /** 37 | Initializes a new instance of the `ScheduledDisposable` that uses a `scheduler` on which to dispose the `disposable`. 38 | 39 | - parameter scheduler: Scheduler where the disposable resource will be disposed on. 40 | - parameter disposable: Disposable resource to dispose on the given scheduler. 41 | */ 42 | init(scheduler: ImmediateSchedulerType, disposable: Disposable) { 43 | self.scheduler = scheduler 44 | _disposable = disposable 45 | } 46 | 47 | /** 48 | Disposes the wrapped disposable on the provided scheduler. 49 | */ 50 | public func dispose() { 51 | scheduler.schedule(self, action: disposeScheduledDisposable) 52 | } 53 | 54 | func disposeInner() { 55 | if OSAtomicCompareAndSwap32(0, 1, &_disposed) { 56 | _disposable!.dispose() 57 | _disposable = nil 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Just.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Just.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 8/30/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class JustScheduledSink : Sink { 12 | typealias Parent = JustScheduled 13 | 14 | private let _parent: Parent 15 | 16 | init(parent: Parent, observer: O) { 17 | _parent = parent 18 | super.init(observer: observer) 19 | } 20 | 21 | func run() -> Disposable { 22 | let scheduler = _parent._scheduler 23 | return scheduler.schedule(_parent._element) { element in 24 | self.forwardOn(.Next(element)) 25 | return scheduler.schedule(()) { _ in 26 | self.forwardOn(.Completed) 27 | return NopDisposable.instance 28 | } 29 | } 30 | } 31 | } 32 | 33 | class JustScheduled : Producer { 34 | private let _scheduler: ImmediateSchedulerType 35 | private let _element: Element 36 | 37 | init(element: Element, scheduler: ImmediateSchedulerType) { 38 | _scheduler = scheduler 39 | _element = element 40 | } 41 | 42 | override func subscribe(observer: O) -> Disposable { 43 | let sink = JustScheduledSink(parent: self, observer: observer) 44 | sink.disposable = sink.run() 45 | return sink 46 | } 47 | } 48 | 49 | class Just : Producer { 50 | private let _element: Element 51 | 52 | init(element: Element) { 53 | _element = element 54 | } 55 | 56 | override func subscribe(observer: O) -> Disposable { 57 | observer.on(.Next(_element)) 58 | observer.on(.Completed) 59 | return NopDisposable.instance 60 | } 61 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Filter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Filter.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/17/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class FilterSink: Sink, ObserverType { 12 | typealias Predicate = (Element) throws -> Bool 13 | typealias Element = O.E 14 | 15 | typealias Parent = Filter 16 | 17 | private let _predicate: Predicate 18 | 19 | init(predicate: Predicate, observer: O) { 20 | _predicate = predicate 21 | super.init(observer: observer) 22 | } 23 | 24 | func on(event: Event) { 25 | switch event { 26 | case .Next(let value): 27 | do { 28 | let satisfies = try _predicate(value) 29 | if satisfies { 30 | forwardOn(.Next(value)) 31 | } 32 | } 33 | catch let e { 34 | forwardOn(.Error(e)) 35 | dispose() 36 | } 37 | case .Completed, .Error: 38 | forwardOn(event) 39 | dispose() 40 | } 41 | } 42 | } 43 | 44 | class Filter : Producer { 45 | typealias Predicate = (Element) throws -> Bool 46 | 47 | private let _source: Observable 48 | private let _predicate: Predicate 49 | 50 | init(source: Observable, predicate: Predicate) { 51 | _source = source 52 | _predicate = predicate 53 | } 54 | 55 | override func run(observer: O) -> Disposable { 56 | let sink = FilterSink(predicate: _predicate, observer: observer) 57 | sink.disposable = _source.subscribe(sink) 58 | return sink 59 | } 60 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/ObservableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableType.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/8/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents a push style sequence. 13 | */ 14 | public protocol ObservableType : ObservableConvertibleType { 15 | /** 16 | Type of elements in sequence. 17 | */ 18 | typealias E 19 | 20 | /** 21 | Subscribes `observer` to receive events for this sequence. 22 | 23 | ### Grammar 24 | 25 | **Next\* (Error | Completed)** 26 | 27 | * sequences can produce zero or more elements so zero or more `Next` events can be sent to `observer` 28 | * once an `Error` or `Completed` event is sent, the sequence terminates and can't produce any other element 29 | 30 | It is possible that events are sent from different threads, but no two events can be sent concurrently to 31 | `observer`. 32 | 33 | ### Resource Management 34 | 35 | When sequence sends `Complete` or `Error` event all internal resources that compute sequence elements 36 | will be freed. 37 | 38 | To cancel production of sequence elements and free resources immediatelly, call `dispose` on returned 39 | subscription. 40 | 41 | - returns: Subscription for `observer` that can be used to cancel production of sequence elements and free resources. 42 | */ 43 | @warn_unused_result(message="http://git.io/rxs.ud") 44 | func subscribe(observer: O) -> Disposable 45 | 46 | } 47 | 48 | extension ObservableType { 49 | 50 | /** 51 | Default implementation of converting `ObservableType` to `Observable`. 52 | */ 53 | @warn_unused_result(message="http://git.io/rxs.uo") 54 | public func asObservable() -> Observable { 55 | return create(self.subscribe) 56 | } 57 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/TakeLast.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TakeLast.swift 3 | // Rx 4 | // 5 | // Created by Tomi Koskinen on 25/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | class TakeLastSink : Sink, ObserverType { 13 | typealias Parent = TakeLast 14 | typealias E = ElementType 15 | 16 | private let _parent: Parent 17 | 18 | private var _elements: Queue 19 | 20 | init(parent: Parent, observer: O) { 21 | _parent = parent 22 | _elements = Queue(capacity: parent._count + 1) 23 | super.init(observer: observer) 24 | } 25 | 26 | func on(event: Event) { 27 | switch event { 28 | case .Next(let value): 29 | _elements.enqueue(value) 30 | if _elements.count > self._parent._count { 31 | _elements.dequeue() 32 | } 33 | case .Error: 34 | forwardOn(event) 35 | dispose() 36 | case .Completed: 37 | for e in _elements { 38 | forwardOn(.Next(e)) 39 | } 40 | forwardOn(.Completed) 41 | dispose() 42 | } 43 | } 44 | } 45 | 46 | class TakeLast: Producer { 47 | private let _source: Observable 48 | private let _count: Int 49 | 50 | init(source: Observable, count: Int) { 51 | if count < 0 { 52 | rxFatalError("count can't be negative") 53 | } 54 | _source = source 55 | _count = count 56 | } 57 | 58 | override func run(observer: O) -> Disposable { 59 | let sink = TakeLastSink(parent: self, observer: observer) 60 | sink.disposable = _source.subscribe(sink) 61 | return sink 62 | } 63 | } -------------------------------------------------------------------------------- /Pods/Representor/Representor/HTTP/HTTPTransition.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HTTPTransition.swift 3 | // Representor 4 | // 5 | // Created by Kyle Fuller on 23/01/2015. 6 | // Copyright (c) 2015 Apiary. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** An implementation of the Transition protocol for HTTP. */ 12 | public struct HTTPTransition : TransitionType { 13 | public typealias Builder = HTTPTransitionBuilder 14 | 15 | public let uri:String 16 | 17 | /// The HTTP Method that should be used to make the request 18 | public let method:String 19 | /// The suggested contentType that should be used to make the request 20 | public let suggestedContentTypes:[String] 21 | 22 | public let attributes:InputProperties 23 | public let parameters:InputProperties 24 | 25 | public init(uri:String, attributes:InputProperties? = nil, parameters:InputProperties? = nil) { 26 | self.uri = uri 27 | self.attributes = attributes ?? [:] 28 | self.parameters = parameters ?? [:] 29 | self.method = "GET" 30 | self.suggestedContentTypes = [String]() 31 | } 32 | 33 | public init(uri:String, _ block:((builder:Builder) -> ())) { 34 | let builder = Builder() 35 | 36 | block(builder: builder) 37 | 38 | self.uri = uri 39 | self.attributes = builder.attributes 40 | self.parameters = builder.parameters 41 | self.method = builder.method 42 | self.suggestedContentTypes = builder.suggestedContentTypes 43 | } 44 | 45 | public var hashValue:Int { 46 | return uri.hashValue 47 | } 48 | } 49 | 50 | public func ==(lhs:HTTPTransition, rhs:HTTPTransition) -> Bool { 51 | return ( 52 | lhs.uri == rhs.uri && 53 | lhs.attributes == rhs.attributes && 54 | lhs.parameters == rhs.parameters && 55 | lhs.method == rhs.method && 56 | lhs.suggestedContentTypes == rhs.suggestedContentTypes 57 | ) 58 | } 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Hyperdrive Logo 2 | 3 | # RxHyperdrive 4 | 5 | [![Build Status](https://travis-ci.org/kylef/RxHyperdrive.svg?branch=master)](https://travis-ci.org/kylef/RxHyperdrive) 6 | 7 | RxSwift extensions for [Hyperdrive](https://github.com/the-hypermedia-project/Hyperdrive), the generic Swift Web API client. 8 | 9 | ## Usage 10 | 11 | ```swift 12 | let hyperdrive = Hyperdrive() 13 | ``` 14 | 15 | RxHyperdrive adds extensions to Hyperdrive to provide an `enter` and 16 | `request` function that returns an observable. 17 | 18 | ```swift 19 | hyperdrive.enter("https://polls.apiblueprint.org/") 20 | .subscribeNext { representor in 21 | // We've successfully connected and we have a representor 22 | // representing the APIs "root" resource. 23 | 24 | print(representor) 25 | } 26 | ``` 27 | 28 | Once we've got a representor representing the root resource, we can follow 29 | any available transitions such as a transition to the `questions` 30 | collection resource. 31 | 32 | ```swift 33 | let questions = representor.transitions["questions"] 34 | 35 | hyperdrive.request(questions) 36 | .subscribeNext { representor in 37 | print(representor) 38 | } 39 | ``` 40 | 41 | Using `flatMap` we can chain both of these operations together producing 42 | an observer of the questions resource. 43 | 44 | ```swift 45 | hyperdrive.enter("https://polls.apiblueprint.org/") 46 | .flatMap { representor in 47 | hyperdrive.request(representor.transitions["questions"]) 48 | } 49 | .subscribeNext { representor in 50 | print(representor) 51 | } 52 | ``` 53 | 54 | ## Installation 55 | 56 | [CocoaPods](http://cocoapods.org) is the recommended way to add RxHyperdrive 57 | to your project. 58 | 59 | ```ruby 60 | pod 'RxHyperdrive' 61 | ``` 62 | 63 | ## License 64 | 65 | RxHyperdrive is released under the MIT license. See [LICENSE](LICENSE). 66 | 67 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/SubscribeOn.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubscribeOn.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/14/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class SubscribeOnSink : Sink, ObserverType { 12 | typealias Element = O.E 13 | typealias Parent = SubscribeOn 14 | 15 | let parent: Parent 16 | 17 | init(parent: Parent, observer: O) { 18 | self.parent = parent 19 | super.init(observer: observer) 20 | } 21 | 22 | func on(event: Event) { 23 | forwardOn(event) 24 | 25 | if event.isStopEvent { 26 | self.dispose() 27 | } 28 | } 29 | 30 | func run() -> Disposable { 31 | let disposeEverything = SerialDisposable() 32 | let cancelSchedule = SingleAssignmentDisposable() 33 | 34 | disposeEverything.disposable = cancelSchedule 35 | 36 | cancelSchedule.disposable = parent.scheduler.schedule(()) { (_) -> Disposable in 37 | let subscription = self.parent.source.subscribe(self) 38 | disposeEverything.disposable = ScheduledDisposable(scheduler: self.parent.scheduler, disposable: subscription) 39 | return NopDisposable.instance 40 | } 41 | 42 | return disposeEverything 43 | } 44 | } 45 | 46 | class SubscribeOn : Producer { 47 | let source: Ob 48 | let scheduler: ImmediateSchedulerType 49 | 50 | init(source: Ob, scheduler: ImmediateSchedulerType) { 51 | self.source = source 52 | self.scheduler = scheduler 53 | } 54 | 55 | override func run(observer: O) -> Disposable { 56 | let sink = SubscribeOnSink(parent: self, observer: observer) 57 | sink.disposable = sink.run() 58 | return sink 59 | } 60 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Scan.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Scan.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/14/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class ScanSink : Sink, ObserverType { 12 | typealias Parent = Scan 13 | typealias E = ElementType 14 | 15 | private let _parent: Parent 16 | private var _accumulate: Accumulate 17 | 18 | init(parent: Parent, observer: O) { 19 | _parent = parent 20 | _accumulate = parent._seed 21 | super.init(observer: observer) 22 | } 23 | 24 | func on(event: Event) { 25 | switch event { 26 | case .Next(let element): 27 | do { 28 | _accumulate = try _parent._accumulator(_accumulate, element) 29 | forwardOn(.Next(_accumulate)) 30 | } 31 | catch let error { 32 | forwardOn(.Error(error)) 33 | dispose() 34 | } 35 | case .Error(let error): 36 | forwardOn(.Error(error)) 37 | dispose() 38 | case .Completed: 39 | forwardOn(.Completed) 40 | dispose() 41 | } 42 | } 43 | 44 | } 45 | 46 | class Scan: Producer { 47 | typealias Accumulator = (Accumulate, Element) throws -> Accumulate 48 | 49 | private let _source: Observable 50 | private let _seed: Accumulate 51 | private let _accumulator: Accumulator 52 | 53 | init(source: Observable, seed: Accumulate, accumulator: Accumulator) { 54 | _source = source 55 | _seed = seed 56 | _accumulator = accumulator 57 | } 58 | 59 | override func run(observer: O) -> Disposable { 60 | let sink = ScanSink(parent: self, observer: observer) 61 | sink.disposable = _source.subscribe(sink) 62 | return sink 63 | } 64 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/AnyObserver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnyObserver.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/28/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | A type-erased `ObserverType`. 13 | 14 | Forwards operations to an arbitrary underlying observer with the same `Element` type, hiding the specifics of the underlying observer type. 15 | */ 16 | public struct AnyObserver : ObserverType { 17 | /** 18 | The type of elements in sequence that observer can observe. 19 | */ 20 | public typealias E = Element 21 | 22 | /** 23 | Anonymous event handler type. 24 | */ 25 | public typealias EventHandler = (Event) -> Void 26 | 27 | public let observer: EventHandler 28 | 29 | /** 30 | Construct an instance whose `on(event)` calls `eventHandler(event)` 31 | 32 | - parameter eventHandler: Event handler that observes sequences events. 33 | */ 34 | public init(eventHandler: EventHandler) { 35 | self.observer = eventHandler 36 | } 37 | 38 | /** 39 | Construct an instance whose `on(event)` calls `observer.on(event)` 40 | 41 | - parameter observer: Observer that receives sequence events. 42 | */ 43 | public init(_ observer: O) { 44 | self.observer = observer.on 45 | } 46 | 47 | /** 48 | Send `event` to this observer. 49 | 50 | - parameter event: Event instance. 51 | */ 52 | public func on(event: Event) { 53 | return self.observer(event) 54 | } 55 | 56 | /** 57 | Erases type of observer and returns canonical observer. 58 | 59 | - returns: type erased observer. 60 | */ 61 | func asObserver() -> AnyObserver { 62 | return self 63 | } 64 | } 65 | 66 | extension ObserverType { 67 | /** 68 | Erases type of observer and returns canonical observer. 69 | 70 | - returns: type erased observer. 71 | */ 72 | func asObserver() -> AnyObserver { 73 | return AnyObserver(self) 74 | } 75 | } -------------------------------------------------------------------------------- /Pods/Representor/Representor/HTTP/HTTPDeserialization.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HTTPDeserialization.swift 3 | // Representor 4 | // 5 | // Created by Kyle Fuller on 23/01/2015. 6 | // Copyright (c) 2015 Apiary. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func jsonDeserializer(closure:([String:AnyObject] -> Representor?)) -> ((response:NSHTTPURLResponse, body:NSData) -> Representor?) { 12 | return { (response, body) in 13 | let object: AnyObject? = try? NSJSONSerialization.JSONObjectWithData(body, options: NSJSONReadingOptions(rawValue: 0)) 14 | 15 | if let object = object as? [String:AnyObject] { 16 | return closure(object) 17 | } 18 | 19 | return nil 20 | } 21 | } 22 | 23 | public struct HTTPDeserialization { 24 | public typealias Deserializer = (response:NSHTTPURLResponse, body:NSData) -> (Representor?) 25 | 26 | /// A dictionary storing the registered HTTP deserializer's and their corresponding content type. 27 | public static var deserializers:[String:Deserializer] = [ 28 | "application/hal+json": jsonDeserializer { payload in 29 | return deserializeHAL(payload) 30 | }, 31 | 32 | "application/vnd.siren+json": jsonDeserializer { payload in 33 | return deserializeSiren(payload) 34 | }, 35 | ] 36 | 37 | /// An array of the supported content types in order of preference 38 | public static var preferredContentTypes:[String] = [ 39 | "application/vnd.siren+json", 40 | "application/hal+json", 41 | ] 42 | 43 | /** Deserialize an NSHTTPURLResponse and body into a Representor. 44 | Uses the deserializers defined in HTTPDeserializers. 45 | - parameter response: The response to deserialize 46 | - parameter body: The HTTP Body 47 | :return: representor 48 | */ 49 | public static func deserialize(response:NSHTTPURLResponse, body:NSData) -> Representor? { 50 | if let contentType = response.MIMEType { 51 | if let deserializer = HTTPDeserialization.deserializers[contentType] { 52 | return deserializer(response: response, body: body) 53 | } 54 | } 55 | 56 | return nil 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Subjects/Variable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Variable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/28/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Variable is a wrapper for `BehaviorSubject`. 13 | 14 | Unlike `BehaviorSubject` it can't terminate with error. 15 | */ 16 | public class Variable : ObservableType { 17 | public typealias E = Element 18 | 19 | private let _subject: BehaviorSubject 20 | 21 | private var _lock = SpinLock() 22 | 23 | // state 24 | private var _value: E 25 | 26 | /** 27 | Gets or sets current value of variable. 28 | 29 | If case new value is set, all observers are notified of that change. 30 | 31 | Even is case equal value is set, observers will still be notified. 32 | */ 33 | public var value: E { 34 | get { 35 | _lock.lock(); defer { _lock.unlock() } 36 | return _value 37 | } 38 | set(newValue) { 39 | _lock.lock() 40 | _value = newValue 41 | _lock.unlock() 42 | 43 | _subject.on(.Next(newValue)) 44 | } 45 | } 46 | 47 | /** 48 | Initializes variable with initial value. 49 | 50 | - parameter value: Initial variable value. 51 | */ 52 | public init(_ value: Element) { 53 | _value = value 54 | _subject = BehaviorSubject(value: value) 55 | } 56 | 57 | /** 58 | Subscribes an observer to sequence of variable values. 59 | 60 | Immediately upon subscription current value is sent to the observer. 61 | 62 | - parameter observer: Observer to subscribe to variable values. 63 | - returns: Disposable object that can be used to unsubscribe the observer from the variable. 64 | */ 65 | public func subscribe(observer: O) -> Disposable { 66 | return _subject.subscribe(observer) 67 | } 68 | 69 | /** 70 | - returns: Canonical interface for push style sequence 71 | */ 72 | public func asObservable() -> Observable { 73 | return _subject 74 | } 75 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Observable+Concurrency.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable+Concurrency.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/15/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | // MARK: observeOn 12 | 13 | extension ObservableType { 14 | 15 | /** 16 | Wraps the source sequence in order to run its observer callbacks on the specified scheduler. 17 | 18 | This only invokes observer callbacks on a `scheduler`. In case the subscription and/or unsubscription 19 | actions have side-effects that require to be run on a scheduler, use `subscribeOn`. 20 | 21 | - parameter scheduler: Scheduler to notify observers on. 22 | - returns: The source sequence whose observations happen on the specified scheduler. 23 | */ 24 | @warn_unused_result(message="http://git.io/rxs.uo") 25 | public func observeOn(scheduler: ImmediateSchedulerType) 26 | -> Observable { 27 | if let scheduler = scheduler as? SerialDispatchQueueScheduler { 28 | return ObserveOnSerialDispatchQueue(source: self.asObservable(), scheduler: scheduler) 29 | } 30 | else { 31 | return ObserveOn(source: self.asObservable(), scheduler: scheduler) 32 | } 33 | } 34 | } 35 | 36 | // MARK: subscribeOn 37 | 38 | extension ObservableType { 39 | 40 | /** 41 | Wraps the source sequence in order to run its subscription and unsubscription logic on the specified 42 | scheduler. 43 | 44 | This operation is not commonly used. 45 | 46 | This only performs the side-effects of subscription and unsubscription on the specified scheduler. 47 | 48 | In order to invoke observer callbacks on a `scheduler`, use `observeOn`. 49 | 50 | - parameter scheduler: Scheduler to perform subscription and unsubscription actions on. 51 | - returns: The source sequence whose subscriptions and unsubscriptions happen on the specified scheduler. 52 | */ 53 | @warn_unused_result(message="http://git.io/rxs.uo") 54 | public func subscribeOn(scheduler: ImmediateSchedulerType) 55 | -> Observable { 56 | return SubscribeOn(source: self, scheduler: scheduler) 57 | } 58 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/OperationQueueScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // OperationQueueScheduler.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 4/4/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Abstracts the work that needs to be performed on a specific `NSOperationQueue`. 13 | 14 | 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`. 15 | */ 16 | public class OperationQueueScheduler: ImmediateSchedulerType { 17 | public let operationQueue: NSOperationQueue 18 | 19 | /** 20 | Constructs new instance of `OperationQueueScheduler` that performs work on `operationQueue`. 21 | 22 | - parameter operationQueue: Operation queue targeted to perform work on. 23 | */ 24 | public init(operationQueue: NSOperationQueue) { 25 | self.operationQueue = operationQueue 26 | } 27 | 28 | /** 29 | Schedules an action to be executed recursively. 30 | 31 | - parameter state: State passed to the action to be executed. 32 | - 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. 33 | - returns: The disposable object used to cancel the scheduled action (best effort). 34 | */ 35 | public func schedule(state: StateType, action: (StateType) -> Disposable) -> Disposable { 36 | 37 | let compositeDisposable = CompositeDisposable() 38 | 39 | weak var compositeDisposableWeak = compositeDisposable 40 | 41 | let operation = NSBlockOperation { 42 | if compositeDisposableWeak?.disposed ?? false { 43 | return 44 | } 45 | 46 | let disposable = action(state) 47 | compositeDisposableWeak?.addDisposable(disposable) 48 | } 49 | 50 | self.operationQueue.addOperation(operation) 51 | 52 | compositeDisposable.addDisposable(AnonymousDisposable { 53 | operation.cancel() 54 | }) 55 | 56 | return compositeDisposable 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/ElementAt.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ElementAt.swift 3 | // Rx 4 | // 5 | // Created by Junior B. on 21/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | class ElementAtSink : Sink, ObserverType { 13 | typealias Parent = ElementAt 14 | 15 | let _parent: Parent 16 | var _i: Int 17 | 18 | init(parent: Parent, observer: O) { 19 | _parent = parent 20 | _i = parent._index 21 | 22 | super.init(observer: observer) 23 | } 24 | 25 | func on(event: Event) { 26 | switch event { 27 | case .Next(_): 28 | 29 | if (_i == 0) { 30 | forwardOn(event) 31 | forwardOn(.Completed) 32 | self.dispose() 33 | } 34 | 35 | do { 36 | try decrementChecked(&_i) 37 | } catch(let e) { 38 | forwardOn(.Error(e)) 39 | dispose() 40 | return 41 | } 42 | 43 | case .Error(let e): 44 | forwardOn(.Error(e)) 45 | self.dispose() 46 | case .Completed: 47 | if (_parent._throwOnEmpty) { 48 | forwardOn(.Error(RxError.ArgumentOutOfRange)) 49 | } else { 50 | forwardOn(.Completed) 51 | } 52 | 53 | self.dispose() 54 | } 55 | } 56 | } 57 | 58 | class ElementAt : Producer { 59 | 60 | let _source: Observable 61 | let _throwOnEmpty: Bool 62 | let _index: Int 63 | 64 | init(source: Observable, index: Int, throwOnEmpty: Bool) { 65 | if index < 0 { 66 | rxFatalError("index can't be negative") 67 | } 68 | 69 | self._source = source 70 | self._index = index 71 | self._throwOnEmpty = throwOnEmpty 72 | } 73 | 74 | override func run(observer: O) -> Disposable { 75 | let sink = ElementAtSink(parent: self, observer: observer) 76 | sink.disposable = _source.subscribeSafe(sink) 77 | return sink 78 | } 79 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/DistinctUntilChanged.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DistinctUntilChanged.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/15/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class DistinctUntilChangedSink: Sink, ObserverType { 12 | typealias E = O.E 13 | 14 | private let _parent: DistinctUntilChanged 15 | private var _currentKey: Key? = nil 16 | 17 | init(parent: DistinctUntilChanged, observer: O) { 18 | _parent = parent 19 | super.init(observer: observer) 20 | } 21 | 22 | func on(event: Event) { 23 | switch event { 24 | case .Next(let value): 25 | do { 26 | let key = try _parent._selector(value) 27 | var areEqual = false 28 | if let currentKey = _currentKey { 29 | areEqual = try _parent._comparer(currentKey, key) 30 | } 31 | 32 | if areEqual { 33 | return 34 | } 35 | 36 | _currentKey = key 37 | 38 | forwardOn(event) 39 | } 40 | catch let error { 41 | forwardOn(.Error(error)) 42 | dispose() 43 | } 44 | case .Error, .Completed: 45 | forwardOn(event) 46 | dispose() 47 | } 48 | } 49 | } 50 | 51 | class DistinctUntilChanged: Producer { 52 | typealias KeySelector = (Element) throws -> Key 53 | typealias EqualityComparer = (Key, Key) throws -> Bool 54 | 55 | private let _source: Observable 56 | private let _selector: KeySelector 57 | private let _comparer: EqualityComparer 58 | 59 | init(source: Observable, selector: KeySelector, comparer: EqualityComparer) { 60 | _source = source 61 | _selector = selector 62 | _comparer = comparer 63 | } 64 | 65 | override func run(observer: O) -> Disposable { 66 | let sink = DistinctUntilChangedSink(parent: self, observer: observer) 67 | sink.disposable = _source.subscribe(sink) 68 | return sink 69 | } 70 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Timer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Timer.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/7/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class TimerSink : Sink { 12 | typealias Parent = Timer 13 | 14 | private let _parent: Parent 15 | 16 | init(parent: Parent, observer: O) { 17 | _parent = parent 18 | super.init(observer: observer) 19 | } 20 | 21 | func run() -> Disposable { 22 | return _parent._scheduler.schedulePeriodic(0 as Int64, startAfter: _parent._dueTime, period: _parent._period!) { state in 23 | self.forwardOn(.Next(state)) 24 | return state &+ 1 25 | } 26 | } 27 | } 28 | 29 | class TimerOneOffSink : Sink { 30 | typealias Parent = Timer 31 | 32 | private let _parent: Parent 33 | 34 | init(parent: Parent, observer: O) { 35 | _parent = parent 36 | super.init(observer: observer) 37 | } 38 | 39 | func run() -> Disposable { 40 | return _parent._scheduler.scheduleRelative((), dueTime: _parent._dueTime) { (_) -> Disposable in 41 | self.forwardOn(.Next(0)) 42 | self.forwardOn(.Completed) 43 | 44 | return NopDisposable.instance 45 | } 46 | } 47 | } 48 | 49 | class Timer: Producer { 50 | typealias TimeInterval = S.TimeInterval 51 | 52 | private let _scheduler: S 53 | private let _dueTime: TimeInterval 54 | private let _period: TimeInterval? 55 | 56 | init(dueTime: TimeInterval, period: TimeInterval?, scheduler: S) { 57 | _scheduler = scheduler 58 | _dueTime = dueTime 59 | _period = period 60 | } 61 | 62 | override func run(observer: O) -> Disposable { 63 | if let _ = _period { 64 | let sink = TimerSink(parent: self, observer: observer) 65 | sink.disposable = sink.run() 66 | return sink 67 | } 68 | else { 69 | let sink = TimerOneOffSink(parent: self, observer: observer) 70 | sink.disposable = sink.run() 71 | return sink 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/ConnectableObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectableObservable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class Connection : Disposable { 12 | 13 | // state 14 | private weak var _parent: ConnectableObservable? 15 | private var _subscription : Disposable? 16 | 17 | init(parent: ConnectableObservable, subscription: Disposable) { 18 | _parent = parent 19 | _subscription = subscription 20 | } 21 | 22 | func dispose() { 23 | guard let parent = _parent else { return } 24 | 25 | parent._lock.performLocked { 26 | guard let oldSubscription = _subscription else { 27 | return 28 | } 29 | 30 | _subscription = nil 31 | if _parent?._connection === self { 32 | parent._connection = nil 33 | } 34 | _parent = nil 35 | 36 | oldSubscription.dispose() 37 | } 38 | } 39 | } 40 | 41 | public class ConnectableObservable : Observable, ConnectableObservableType { 42 | typealias ConnectionType = Connection 43 | 44 | private let _subject: S 45 | private let _source: Observable 46 | 47 | private let _lock = NSRecursiveLock() 48 | 49 | // state 50 | private var _connection: ConnectionType? 51 | 52 | public init(source: Observable, subject: S) { 53 | _source = source 54 | _subject = subject 55 | _connection = nil 56 | } 57 | 58 | public func connect() -> Disposable { 59 | return _lock.calculateLocked { 60 | if let connection = _connection { 61 | return connection 62 | } 63 | 64 | let disposable = _source.subscribe(_subject.asObserver()) 65 | let connection = Connection(parent: self, subscription: disposable) 66 | _connection = connection 67 | return connection 68 | } 69 | } 70 | 71 | public override func subscribe(observer: O) -> Disposable { 72 | return _subject.subscribe(observer) 73 | } 74 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/SingleAsync.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SingleAsync.swift 3 | // Rx 4 | // 5 | // Created by Junior B. on 09/11/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class SingleAsyncSink : Sink, ObserverType { 12 | typealias Parent = SingleAsync 13 | typealias E = ElementType 14 | 15 | private let _parent: Parent 16 | private var _seenValue: Bool = false 17 | 18 | init(parent: Parent, observer: O) { 19 | _parent = parent 20 | super.init(observer: observer) 21 | } 22 | 23 | func on(event: Event) { 24 | switch event { 25 | case .Next(let value): 26 | do { 27 | let forward = try _parent._predicate?(value) ?? true 28 | if !forward { 29 | return 30 | } 31 | } 32 | catch let error { 33 | forwardOn(.Error(error as ErrorType)) 34 | dispose() 35 | return 36 | } 37 | 38 | if _seenValue == false { 39 | forwardOn(.Next(value)) 40 | _seenValue = true 41 | } else { 42 | forwardOn(.Error(RxError.MoreThanOneElement)) 43 | dispose() 44 | } 45 | 46 | case .Error: 47 | forwardOn(event) 48 | dispose() 49 | case .Completed: 50 | if (!_seenValue) { 51 | forwardOn(.Error(RxError.NoElements)) 52 | } else { 53 | forwardOn(.Completed) 54 | } 55 | dispose() 56 | } 57 | } 58 | } 59 | 60 | class SingleAsync: Producer { 61 | typealias Predicate = (Element) throws -> Bool 62 | 63 | private let _source: Observable 64 | private let _predicate: Predicate? 65 | 66 | init(source: Observable, predicate: Predicate? = nil) { 67 | _source = source 68 | _predicate = predicate 69 | } 70 | 71 | override func run(observer: O) -> Disposable { 72 | let sink = SingleAsyncSink(parent: self, observer: observer) 73 | sink.disposable = _source.subscribe(sink) 74 | return sink 75 | } 76 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/MainScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainScheduler.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | 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. 13 | 14 | This scheduler is usually used to perform UI work. 15 | 16 | Main scheduler is a specialization of `SerialDispatchQueueScheduler`. 17 | 18 | This scheduler is optimized for `observeOn` operator. To ensure observable sequence is subscribed on main thread using `subscribeOn` 19 | operator please use `ConcurrentMainScheduler` because it is more optimized for that purpose. 20 | */ 21 | public final class MainScheduler : SerialDispatchQueueScheduler { 22 | 23 | private let _mainQueue: dispatch_queue_t 24 | 25 | var numberEnqueued: Int32 = 0 26 | 27 | private init() { 28 | _mainQueue = dispatch_get_main_queue() 29 | super.init(serialQueue: _mainQueue) 30 | } 31 | 32 | /** 33 | Singleton instance of `MainScheduler` 34 | */ 35 | public static let sharedInstance = MainScheduler() 36 | 37 | /** 38 | In case this method is called on a background thread it will throw an exception. 39 | */ 40 | public class func ensureExecutingOnScheduler() { 41 | if !NSThread.currentThread().isMainThread { 42 | rxFatalError("Executing on backgound thread. Please use `MainScheduler.sharedInstance.schedule` to schedule work on main thread.") 43 | } 44 | } 45 | 46 | override func scheduleInternal(state: StateType, action: StateType -> Disposable) -> Disposable { 47 | let currentNumberEnqueued = OSAtomicIncrement32(&numberEnqueued) 48 | 49 | if NSThread.currentThread().isMainThread && currentNumberEnqueued == 1 { 50 | let disposable = action(state) 51 | OSAtomicDecrement32(&numberEnqueued) 52 | return disposable 53 | } 54 | 55 | let cancel = SingleAssignmentDisposable() 56 | 57 | dispatch_async(_mainQueue) { 58 | if !cancel.disposed { 59 | action(state) 60 | } 61 | 62 | OSAtomicDecrement32(&self.numberEnqueued) 63 | } 64 | 65 | return cancel 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Generate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generate.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 9/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class GenerateSink : Sink { 12 | typealias Parent = Generate 13 | 14 | private let _parent: Parent 15 | 16 | private var _state: S 17 | 18 | init(parent: Parent, observer: O) { 19 | _parent = parent 20 | _state = parent._initialState 21 | super.init(observer: observer) 22 | } 23 | 24 | func run() -> Disposable { 25 | return _parent._scheduler.scheduleRecursive(true) { (isFirst, recurse) -> Void in 26 | do { 27 | if !isFirst { 28 | self._state = try self._parent._iterate(self._state) 29 | } 30 | 31 | if try self._parent._condition(self._state) { 32 | let result = try self._parent._resultSelector(self._state) 33 | self.forwardOn(.Next(result)) 34 | 35 | recurse(false) 36 | } 37 | else { 38 | self.forwardOn(.Completed) 39 | self.dispose() 40 | } 41 | } 42 | catch let error { 43 | self.forwardOn(.Error(error)) 44 | self.dispose() 45 | } 46 | } 47 | } 48 | } 49 | 50 | class Generate : Producer { 51 | private let _initialState: S 52 | private let _condition: S throws -> Bool 53 | private let _iterate: S throws -> S 54 | private let _resultSelector: S throws -> E 55 | private let _scheduler: ImmediateSchedulerType 56 | 57 | init(initialState: S, condition: S throws -> Bool, iterate: S throws -> S, resultSelector: S throws -> E, scheduler: ImmediateSchedulerType) { 58 | _initialState = initialState 59 | _condition = condition 60 | _iterate = iterate 61 | _resultSelector = resultSelector 62 | _scheduler = scheduler 63 | super.init() 64 | } 65 | 66 | override func run(observer: O) -> Disposable { 67 | let sink = GenerateSink(parent: self, observer: observer) 68 | sink.disposable = sink.run() 69 | return sink 70 | } 71 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Multicast.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Multicast.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/27/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class MulticastSink: Sink, ObserverType { 12 | typealias Element = O.E 13 | typealias ResultType = Element 14 | typealias MutlicastType = Multicast 15 | 16 | private let _parent: MutlicastType 17 | 18 | init(parent: MutlicastType, observer: O) { 19 | _parent = parent 20 | super.init(observer: observer) 21 | } 22 | 23 | func run() -> Disposable { 24 | do { 25 | let subject = try _parent._subjectSelector() 26 | let connectable = ConnectableObservable(source: _parent._source, subject: subject) 27 | 28 | let observable = try _parent._selector(connectable) 29 | 30 | let subscription = observable.subscribe(self) 31 | let connection = connectable.connect() 32 | 33 | return BinaryDisposable(subscription, connection) 34 | } 35 | catch let e { 36 | forwardOn(.Error(e)) 37 | dispose() 38 | return NopDisposable.instance 39 | } 40 | } 41 | 42 | func on(event: Event) { 43 | forwardOn(event) 44 | switch event { 45 | case .Next: break 46 | case .Error, .Completed: 47 | dispose() 48 | } 49 | } 50 | } 51 | 52 | class Multicast: Producer { 53 | typealias SubjectSelectorType = () throws -> S 54 | typealias SelectorType = (Observable) throws -> Observable 55 | 56 | private let _source: Observable 57 | private let _subjectSelector: SubjectSelectorType 58 | private let _selector: SelectorType 59 | 60 | init(source: Observable, subjectSelector: SubjectSelectorType, selector: SelectorType) { 61 | _source = source 62 | _subjectSelector = subjectSelector 63 | _selector = selector 64 | } 65 | 66 | override func run(observer: O) -> Disposable { 67 | let sink = MulticastSink(parent: self, observer: observer) 68 | sink.disposable = sink.run() 69 | return sink 70 | } 71 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/DisposeBag.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisposeBag.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/25/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension Disposable { 12 | /** 13 | Adds `self` to `bag`. 14 | 15 | - parameter bag: `DisposeBag` to add `self` to. 16 | */ 17 | public func addDisposableTo(bag: DisposeBag) { 18 | bag.addDisposable(self) 19 | } 20 | } 21 | 22 | /** 23 | Thread safe bag that disposes added disposables on `deinit`. 24 | 25 | This returns ARC (RAII) like resource management to `RxSwift`. 26 | 27 | In case contained disposables need to be disposed, just deference dispose bag 28 | or create new one in it's place. 29 | 30 | self.existingDisposeBag = DisposeBag() 31 | 32 | In case explicit disposal is necessary, there is also `CompositeDisposable`. 33 | */ 34 | public class DisposeBag: DisposeBase { 35 | 36 | private var _lock = SpinLock() 37 | 38 | // state 39 | private var _disposables = [Disposable]() 40 | private var _disposed = false 41 | 42 | /** 43 | Constructs new empty dispose bag. 44 | */ 45 | public override init() { 46 | super.init() 47 | } 48 | 49 | /** 50 | Adds `disposable` to be disposed when dispose bag is being deinited. 51 | 52 | - parameter disposable: Disposable to add. 53 | */ 54 | public func addDisposable(disposable: Disposable) { 55 | _addDisposable(disposable)?.dispose() 56 | } 57 | 58 | private func _addDisposable(disposable: Disposable) -> Disposable? { 59 | _lock.lock(); defer { _lock.unlock() } 60 | if _disposed { 61 | return disposable 62 | } 63 | 64 | _disposables.append(disposable) 65 | 66 | return nil 67 | } 68 | 69 | /** 70 | This is internal on purpose, take a look at `CompositeDisposable` instead. 71 | */ 72 | private func dispose() { 73 | let oldDisposables = _dispose() 74 | 75 | for disposable in oldDisposables { 76 | disposable.dispose() 77 | } 78 | } 79 | 80 | private func _dispose() -> [Disposable] { 81 | _lock.lock(); defer { _lock.unlock() } 82 | 83 | let disposables = _disposables 84 | 85 | _disposables.removeAll(keepCapacity: false) 86 | _disposed = true 87 | 88 | return disposables 89 | } 90 | 91 | deinit { 92 | dispose() 93 | } 94 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserveOnSerialDispatchQueue.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/31/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if TRACE_RESOURCES 12 | /** 13 | Counts number of `SerialDispatchQueueObservables`. 14 | 15 | Purposed for unit tests. 16 | */ 17 | public var numberOfSerialDispatchQueueObservables: Int32 = 0 18 | #endif 19 | 20 | class ObserveOnSerialDispatchQueueSink : ObserverBase { 21 | let scheduler: SerialDispatchQueueScheduler 22 | let observer: O 23 | 24 | let subscription = SingleAssignmentDisposable() 25 | 26 | var cachedScheduleLambda: ((ObserveOnSerialDispatchQueueSink, Event) -> Disposable)! 27 | 28 | init(scheduler: SerialDispatchQueueScheduler, observer: O) { 29 | self.scheduler = scheduler 30 | self.observer = observer 31 | super.init() 32 | 33 | cachedScheduleLambda = { sink, event in 34 | sink.observer.on(event) 35 | 36 | if event.isStopEvent { 37 | sink.dispose() 38 | } 39 | 40 | return NopDisposable.instance 41 | } 42 | } 43 | 44 | override func onCore(event: Event) { 45 | self.scheduler.schedule((self, event), action: cachedScheduleLambda) 46 | } 47 | 48 | override func dispose() { 49 | super.dispose() 50 | 51 | subscription.dispose() 52 | } 53 | } 54 | 55 | class ObserveOnSerialDispatchQueue : Producer { 56 | let scheduler: SerialDispatchQueueScheduler 57 | let source: Observable 58 | 59 | init(source: Observable, scheduler: SerialDispatchQueueScheduler) { 60 | self.scheduler = scheduler 61 | self.source = source 62 | 63 | #if TRACE_RESOURCES 64 | OSAtomicIncrement32(&resourceCount) 65 | OSAtomicIncrement32(&numberOfSerialDispatchQueueObservables) 66 | #endif 67 | } 68 | 69 | override func run(observer: O) -> Disposable { 70 | let sink = ObserveOnSerialDispatchQueueSink(scheduler: scheduler, observer: observer) 71 | sink.subscription.disposable = source.subscribe(sink) 72 | return sink 73 | } 74 | 75 | #if TRACE_RESOURCES 76 | deinit { 77 | OSAtomicDecrement32(&resourceCount) 78 | OSAtomicDecrement32(&numberOfSerialDispatchQueueObservables) 79 | } 80 | #endif 81 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Using.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Using.swift 3 | // Rx 4 | // 5 | // Created by Yury Korolev on 10/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class UsingSink : Sink, ObserverType { 12 | 13 | typealias Parent = Using 14 | typealias E = O.E 15 | 16 | private let _parent: Parent 17 | 18 | init(parent: Parent, observer: O) { 19 | _parent = parent 20 | super.init(observer: observer) 21 | } 22 | 23 | func run() -> Disposable { 24 | var disposable = NopDisposable.instance 25 | 26 | do { 27 | let resource = try _parent._resourceFactory() 28 | disposable = resource 29 | let source = try _parent._observableFactory(resource) 30 | 31 | return StableCompositeDisposable.create( 32 | source.subscribe(self), 33 | disposable 34 | ) 35 | } catch let error { 36 | return StableCompositeDisposable.create( 37 | failWith(error).subscribe(self), 38 | disposable 39 | ) 40 | } 41 | } 42 | 43 | func on(event: Event) { 44 | switch event { 45 | case let .Next(value): 46 | forwardOn(.Next(value)) 47 | case let .Error(error): 48 | forwardOn(.Error(error)) 49 | dispose() 50 | case .Completed: 51 | forwardOn(.Completed) 52 | dispose() 53 | } 54 | } 55 | } 56 | 57 | class Using: Producer { 58 | 59 | typealias E = SourceType 60 | 61 | typealias ResourceFactory = () throws -> ResourceType 62 | typealias ObservableFactory = ResourceType throws -> Observable 63 | 64 | private let _resourceFactory: ResourceFactory 65 | private let _observableFactory: ObservableFactory 66 | 67 | 68 | init(resourceFactory: ResourceFactory, observableFactory: ObservableFactory) { 69 | _resourceFactory = resourceFactory 70 | _observableFactory = observableFactory 71 | } 72 | 73 | override func run(observer: O) -> Disposable { 74 | let sink = UsingSink(parent: self, observer: observer) 75 | sink.disposable = sink.run() 76 | return sink 77 | } 78 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Reduce.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Reduce.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 4/1/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class ReduceSink : Sink, ObserverType { 12 | typealias ResultType = O.E 13 | typealias Parent = Reduce 14 | 15 | private let _parent: Parent 16 | private var _accumulation: AccumulateType 17 | 18 | init(parent: Parent, observer: O) { 19 | _parent = parent 20 | _accumulation = parent._seed 21 | 22 | super.init(observer: observer) 23 | } 24 | 25 | func on(event: Event) { 26 | switch event { 27 | case .Next(let value): 28 | do { 29 | _accumulation = try _parent._accumulator(_accumulation, value) 30 | } 31 | catch let e { 32 | forwardOn(.Error(e)) 33 | dispose() 34 | } 35 | case .Error(let e): 36 | forwardOn(.Error(e)) 37 | dispose() 38 | case .Completed: 39 | do { 40 | let result = try _parent._mapResult(_accumulation) 41 | forwardOn(.Next(result)) 42 | forwardOn(.Completed) 43 | dispose() 44 | } 45 | catch let e { 46 | forwardOn(.Error(e)) 47 | dispose() 48 | } 49 | } 50 | } 51 | } 52 | 53 | class Reduce : Producer { 54 | typealias AccumulatorType = (AccumulateType, SourceType) throws -> AccumulateType 55 | typealias ResultSelectorType = (AccumulateType) throws -> ResultType 56 | 57 | private let _source: Observable 58 | private let _seed: AccumulateType 59 | private let _accumulator: AccumulatorType 60 | private let _mapResult: ResultSelectorType 61 | 62 | init(source: Observable, seed: AccumulateType, accumulator: AccumulatorType, mapResult: ResultSelectorType) { 63 | _source = source 64 | _seed = seed 65 | _accumulator = accumulator 66 | _mapResult = mapResult 67 | } 68 | 69 | override func run(observer: O) -> Disposable { 70 | let sink = ReduceSink(parent: self, observer: observer) 71 | sink.disposable = _source.subscribe(sink) 72 | return sink 73 | } 74 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/SingleAssignmentDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SingleAssignmentDisposable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents a disposable resource which only allows a single assignment of its underlying disposable resource. 13 | 14 | If an underlying disposable resource has already been set, future attempts to set the underlying disposable resource will throw an exception. 15 | */ 16 | public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable { 17 | private var _lock = SpinLock() 18 | 19 | // state 20 | private var _disposed = false 21 | private var _disposableSet = false 22 | private var _disposable = nil as Disposable? 23 | 24 | /** 25 | - returns: A value that indicates whether the object is disposed. 26 | */ 27 | public var disposed: Bool { 28 | get { 29 | return _disposed 30 | } 31 | } 32 | 33 | /** 34 | Initializes a new instance of the `SingleAssignmentDisposable`. 35 | */ 36 | public override init() { 37 | super.init() 38 | } 39 | 40 | /** 41 | Gets or sets the underlying disposable. After disposal, the result of getting this property is undefined. 42 | 43 | **Throws exception if the `SingleAssignmentDisposable` has already been assigned to.** 44 | */ 45 | public var disposable: Disposable { 46 | get { 47 | _lock.lock(); defer { _lock.unlock() } 48 | return _disposable ?? NopDisposable.instance 49 | } 50 | set { 51 | _setDisposable(newValue)?.dispose() 52 | } 53 | } 54 | 55 | private func _setDisposable(newValue: Disposable) -> Disposable? { 56 | if _disposableSet { 57 | rxFatalError("oldState.disposable != nil") 58 | } 59 | 60 | _disposableSet = true 61 | 62 | if _disposed { 63 | return newValue 64 | } 65 | 66 | _disposable = newValue 67 | 68 | return nil 69 | } 70 | 71 | /** 72 | Disposes the underlying disposable. 73 | */ 74 | public func dispose() { 75 | if _disposed { 76 | return 77 | } 78 | _dispose()?.dispose() 79 | } 80 | 81 | private func _dispose() -> Disposable? { 82 | _lock.lock(); defer { _lock.unlock() } 83 | 84 | _disposed = true 85 | let disposable = _disposable 86 | _disposable = nil 87 | 88 | return disposable 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Pods/Representor/Representor/HTTP/HTTPTransitionBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HTTPTransitionBuilder.swift 3 | // Representor 4 | // 5 | // Created by Kyle Fuller on 23/01/2015. 6 | // Copyright (c) 2015 Apiary. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// An implementation of TransitionBuilder used by the HTTPTransition 12 | public class HTTPTransitionBuilder : TransitionBuilderType { 13 | var attributes = InputProperties() 14 | var parameters = InputProperties() 15 | 16 | /// The suggested contentType that should be used to make the request 17 | public var method = "POST" 18 | /// The suggested contentType that should be used to make the request 19 | public var suggestedContentTypes = [String]() 20 | 21 | init() { 22 | 23 | } 24 | 25 | // MARK: Attributes 26 | 27 | /// Adds an attribute with a value or default value 28 | /// 29 | /// - parameter name: The name of the attribute 30 | /// - parameter title: The human readable title of the attribute 31 | /// - parameter value: The value of the attribute 32 | /// - parameter defaultValue: The default value of the attribute 33 | public func addAttribute(name:String, title:String? = nil, value:T? = nil, defaultValue:T? = nil, required:Bool? = nil) { 34 | let property = InputProperty(title:title, value:value, defaultValue:defaultValue, required:required) 35 | attributes[name] = property 36 | } 37 | 38 | /// Adds an attribute 39 | /// 40 | /// - parameter name: The name of the attribute 41 | /// - parameter title: The human readable title of the attribute 42 | public func addAttribute(name:String, title:String? = nil, required:Bool? = nil) { 43 | let property = InputProperty(title:title, required:required) 44 | attributes[name] = property 45 | } 46 | 47 | // MARK: Parameters 48 | 49 | /// Adds a parameter without a value or default value 50 | /// 51 | /// - parameter name: The name of the attribute 52 | public func addParameter(name:String) { 53 | let property = InputProperty(value:nil, defaultValue:nil) 54 | parameters[name] = property 55 | } 56 | 57 | /// Adds a parameter with a value or default value 58 | /// 59 | /// - parameter name: The name of the attribute 60 | /// - parameter value: The value of the attribute 61 | /// - parameter value: The default value of the attribute 62 | public func addParameter(name:String, value:T?, defaultValue:T?, required:Bool? = nil) { 63 | let property = InputProperty(value:value, defaultValue:defaultValue, required:required) 64 | parameters[name] = property 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Disposables/SerialDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SerialDisposable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/12/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource. 13 | */ 14 | public class SerialDisposable : DisposeBase, Cancelable { 15 | private var _lock = SpinLock() 16 | 17 | // state 18 | private var _current = nil as Disposable? 19 | private var _disposed = false 20 | 21 | /** 22 | - returns: Was resource disposed. 23 | */ 24 | public var disposed: Bool { 25 | get { 26 | return _disposed 27 | } 28 | } 29 | 30 | /** 31 | Initializes a new instance of the `SerialDisposable`. 32 | */ 33 | override public init() { 34 | super.init() 35 | } 36 | 37 | /** 38 | Gets or sets the underlying disposable. 39 | 40 | Assigning this property disposes the previous disposable object. 41 | 42 | If the `SerialDisposable` has already been disposed, assignment to this property causes immediate disposal of the given disposable object. 43 | */ 44 | public var disposable: Disposable { 45 | get { 46 | return _lock.calculateLocked { 47 | return self.disposable 48 | } 49 | } 50 | set (newDisposable) { 51 | let disposable: Disposable? = _lock.calculateLocked { 52 | if _disposed { 53 | return newDisposable 54 | } 55 | else { 56 | let toDispose = _current 57 | _current = newDisposable 58 | return toDispose 59 | } 60 | } 61 | 62 | if let disposable = disposable { 63 | disposable.dispose() 64 | } 65 | } 66 | } 67 | 68 | /** 69 | Disposes the underlying disposable as well as all future replacements. 70 | */ 71 | public func dispose() { 72 | _dispose()?.dispose() 73 | } 74 | 75 | private func _dispose() -> Disposable? { 76 | _lock.lock(); defer { _lock.unlock() } 77 | if _disposed { 78 | return nil 79 | } 80 | else { 81 | _disposed = true 82 | let current = _current 83 | _current = nil 84 | return current 85 | } 86 | } 87 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Schedulers/SchedulerServices+Emulation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SchedulerServices+Emulation.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/6/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum SchedulePeriodicRecursiveCommand { 12 | case Tick 13 | case DispatchStart 14 | } 15 | 16 | class SchedulePeriodicRecursive { 17 | typealias RecursiveAction = State -> State 18 | typealias TimeInterval = S.TimeInterval 19 | typealias RecursiveScheduler = AnyRecursiveScheduler 20 | 21 | private let _scheduler: S 22 | private let _startAfter: TimeInterval 23 | private let _period: TimeInterval 24 | private let _action: RecursiveAction 25 | 26 | private var _state: State 27 | private var _pendingTickCount: Int32 = 0 28 | 29 | init(scheduler: S, startAfter: TimeInterval, period: TimeInterval, action: RecursiveAction, state: State) { 30 | _scheduler = scheduler 31 | _startAfter = startAfter 32 | _period = period 33 | _action = action 34 | _state = state 35 | } 36 | 37 | func start() -> Disposable { 38 | return _scheduler.scheduleRecursive(SchedulePeriodicRecursiveCommand.Tick, dueTime: _startAfter, action: self.tick) 39 | } 40 | 41 | func tick(command: SchedulePeriodicRecursiveCommand, scheduler: RecursiveScheduler) -> Void { 42 | // Tries to emulate periodic scheduling as best as possible. 43 | // The problem that could arise is if handling periodic ticks take too long, or 44 | // tick interval is short. 45 | switch command { 46 | case .Tick: 47 | scheduler.schedule(.Tick, dueTime: _period) 48 | 49 | // The idea is that if on tick there wasn't any item enqueued, schedule to perform work immediatelly. 50 | // Else work will be scheduled after previous enqueued work completes. 51 | if OSAtomicIncrement32(&_pendingTickCount) == 1 { 52 | self.tick(.DispatchStart, scheduler: scheduler) 53 | } 54 | 55 | case .DispatchStart: 56 | _state = _action(_state) 57 | // Start work and schedule check is this last batch of work 58 | if OSAtomicDecrement32(&_pendingTickCount) > 0 { 59 | // This gives priority to scheduler emulation, it's not perfect, but helps 60 | scheduler.schedule(SchedulePeriodicRecursiveCommand.DispatchStart) 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Observable+Aggregate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable+Aggregate.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/22/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | // MARK: reduce 12 | 13 | extension ObservableType { 14 | 15 | /** 16 | 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. 17 | 18 | For aggregation behavior with incremental intermediate results, see `scan`. 19 | 20 | - parameter seed: The initial accumulator value. 21 | - parameter accumulator: A accumulator function to be invoked on each element. 22 | - parameter mapResult: A function to transform the final accumulator value into the result value. 23 | - returns: An observable sequence containing a single element with the final accumulator value. 24 | */ 25 | @warn_unused_result(message="http://git.io/rxs.uo") 26 | public func reduce(seed: A, _ accumulator: (A, E) throws -> A, mapResult: (A) throws -> R) 27 | -> Observable { 28 | return Reduce(source: self.asObservable(), seed: seed, accumulator: accumulator, mapResult: mapResult) 29 | } 30 | 31 | /** 32 | 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. 33 | 34 | For aggregation behavior with incremental intermediate results, see `scan`. 35 | 36 | - parameter seed: The initial accumulator value. 37 | - parameter accumulator: A accumulator function to be invoked on each element. 38 | - returns: An observable sequence containing a single element with the final accumulator value. 39 | */ 40 | @warn_unused_result(message="http://git.io/rxs.uo") 41 | public func reduce(seed: A, _ accumulator: (A, E) throws -> A) 42 | -> Observable { 43 | return Reduce(source: self.asObservable(), seed: seed, accumulator: accumulator, mapResult: { $0 }) 44 | } 45 | 46 | /** 47 | Converts an Observable into another Observable that emits the whole sequence as a single array and then terminates. 48 | 49 | For aggregation behavior see `reduce`. 50 | 51 | - returns: An observable sequence containing all the emitted elements as array. 52 | */ 53 | @warn_unused_result(message="http://git.io/rxs.uo") 54 | public func toArray() 55 | -> Observable<[E]> { 56 | return ToArray(source: self.asObservable()) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/RefCount.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RefCount.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/5/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class RefCountSink 12 | : Sink 13 | , ObserverType { 14 | typealias Element = O.E 15 | typealias Parent = RefCount 16 | 17 | private let _parent: Parent 18 | 19 | init(parent: Parent, observer: O) { 20 | _parent = parent 21 | super.init(observer: observer) 22 | } 23 | 24 | func run() -> Disposable { 25 | let subscription = _parent._source.subscribeSafe(self) 26 | 27 | _parent._lock.lock(); defer { _parent._lock.unlock() } // { 28 | if _parent._count == 0 { 29 | _parent._count = 1 30 | _parent._connectableSubscription = _parent._source.connect() 31 | } 32 | else { 33 | _parent._count = _parent._count + 1 34 | } 35 | // } 36 | 37 | return AnonymousDisposable { 38 | subscription.dispose() 39 | self._parent._lock.lock(); defer { self._parent._lock.unlock() } // { 40 | if self._parent._count == 1 { 41 | self._parent._connectableSubscription!.dispose() 42 | self._parent._count = 0 43 | self._parent._connectableSubscription = nil 44 | } 45 | else if self._parent._count > 1 { 46 | self._parent._count = self._parent._count - 1 47 | } 48 | else { 49 | rxFatalError("Something went wrong with RefCount disposing mechanism") 50 | } 51 | // } 52 | } 53 | } 54 | 55 | func on(event: Event) { 56 | switch event { 57 | case .Next: 58 | forwardOn(event) 59 | case .Error, .Completed: 60 | forwardOn(event) 61 | dispose() 62 | } 63 | } 64 | } 65 | 66 | class RefCount: Producer { 67 | private let _lock = NSRecursiveLock() 68 | 69 | // state 70 | private var _count = 0 71 | private var _connectableSubscription = nil as Disposable? 72 | 73 | private let _source: CO 74 | 75 | init(source: CO) { 76 | _source = source 77 | } 78 | 79 | override func run(observer: O) -> Disposable { 80 | let sink = RefCountSink(parent: self, observer: observer) 81 | sink.disposable = sink.run() 82 | return sink 83 | } 84 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Concurrency/Lock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Lock.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/31/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | protocol Lock { 12 | func lock() 13 | func unlock() 14 | } 15 | 16 | /** 17 | Simple wrapper for spin lock. 18 | */ 19 | struct SpinLock { 20 | private var _lock = OS_SPINLOCK_INIT 21 | 22 | init() { 23 | 24 | } 25 | 26 | mutating func lock() { 27 | OSSpinLockLock(&_lock) 28 | } 29 | 30 | mutating func unlock() { 31 | OSSpinLockUnlock(&_lock) 32 | } 33 | 34 | mutating func performLocked(@noescape action: () -> Void) { 35 | OSSpinLockLock(&_lock) 36 | action() 37 | OSSpinLockUnlock(&_lock) 38 | } 39 | 40 | mutating func calculateLocked(@noescape action: () -> T) -> T { 41 | OSSpinLockLock(&_lock) 42 | let result = action() 43 | OSSpinLockUnlock(&_lock) 44 | return result 45 | } 46 | 47 | mutating func calculateLockedOrFail(@noescape action: () throws -> T) throws -> T { 48 | OSSpinLockLock(&_lock) 49 | defer { 50 | OSSpinLockUnlock(&_lock) 51 | } 52 | let result = try action() 53 | return result 54 | } 55 | } 56 | 57 | extension NSRecursiveLock : Lock { 58 | func performLocked(@noescape action: () -> Void) { 59 | self.lock() 60 | action() 61 | self.unlock() 62 | } 63 | 64 | func calculateLocked(@noescape action: () -> T) -> T { 65 | self.lock() 66 | let result = action() 67 | self.unlock() 68 | return result 69 | } 70 | 71 | func calculateLockedOrFail(@noescape action: () throws -> T) throws -> T { 72 | self.lock() 73 | defer { 74 | self.unlock() 75 | } 76 | let result = try action() 77 | return result 78 | } 79 | } 80 | 81 | /* 82 | let RECURSIVE_MUTEX = _initializeRecursiveMutex() 83 | 84 | func _initializeRecursiveMutex() -> pthread_mutex_t { 85 | var mutex: pthread_mutex_t = pthread_mutex_t() 86 | var mta: pthread_mutexattr_t = pthread_mutexattr_t() 87 | 88 | pthread_mutex_init(&mutex, nil) 89 | pthread_mutexattr_init(&mta) 90 | pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE) 91 | pthread_mutex_init(&mutex, &mta) 92 | 93 | return mutex 94 | } 95 | 96 | extension pthread_mutex_t { 97 | mutating func lock() { 98 | pthread_mutex_lock(&self) 99 | } 100 | 101 | mutating func unlock() { 102 | pthread_mutex_unlock(&self) 103 | } 104 | } 105 | */ -------------------------------------------------------------------------------- /Pods/Representor/Representor/HTTP/Adapters/HTTPHALAdapter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HTTPHALAdapter.swift 3 | // Representor 4 | // 5 | // Created by Kyle Fuller on 08/11/2014. 6 | // Copyright (c) 2014 Apiary. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func parseHALLinks(halLinks:[String:[String:AnyObject]]) -> [String:HTTPTransition] { 12 | var links = [String:HTTPTransition]() 13 | 14 | for (link, options) in halLinks { 15 | if let href = options["href"] as? String { 16 | links[link] = HTTPTransition(uri: href) 17 | } 18 | } 19 | 20 | return links 21 | } 22 | 23 | 24 | func parseEmbeddedHALs(embeddedHALs:[String:AnyObject]) -> [String:[Representor]] { 25 | var representors = [String:[Representor]]() 26 | 27 | func parseEmbedded(embedded:[String:AnyObject]) -> Representor { 28 | return deserializeHAL(embedded) 29 | } 30 | 31 | for (name, embedded) in embeddedHALs { 32 | if let embedded = embedded as? [[String:AnyObject]] { 33 | representors[name] = embedded.map(deserializeHAL) 34 | } else if let embedded = embedded as? [String:AnyObject] { 35 | representors[name] = [deserializeHAL(embedded)] 36 | } 37 | } 38 | 39 | return representors 40 | } 41 | 42 | /// A function to deserialize a HAL structure into a HTTP Transition. 43 | public func deserializeHAL(hal:[String:AnyObject]) -> Representor { 44 | var hal = hal 45 | 46 | var links = [String:HTTPTransition]() 47 | if let halLinks = hal.removeValueForKey("_links") as? [String:[String:AnyObject]] { 48 | links = parseHALLinks(halLinks) 49 | } 50 | 51 | var representors = [String:[Representor]]() 52 | if let embedded = hal.removeValueForKey("_embedded") as? [String:AnyObject] { 53 | representors = parseEmbeddedHALs(embedded) 54 | } 55 | 56 | return Representor(transitions: links, representors: representors, attributes: hal) 57 | } 58 | 59 | /// A function to serialize a HTTP Representor into a Siren structure 60 | public func serializeHAL(representor:Representor) -> [String:AnyObject] { 61 | var representation = representor.attributes 62 | 63 | if representor.transitions.count > 0 { 64 | var links = [String:[String:String]]() 65 | 66 | for (relation, transition) in representor.transitions { 67 | links[relation] = ["href": transition.uri] 68 | } 69 | 70 | representation["_links"] = links 71 | } 72 | 73 | if representor.representors.count > 0 { 74 | var embeddedHALs = [String:[[String:AnyObject]]]() 75 | 76 | for (name, representorSet) in representor.representors { 77 | embeddedHALs[name] = representorSet.map(serializeHAL) 78 | } 79 | 80 | representation["_embedded"] = embeddedHALs 81 | } 82 | 83 | return representation 84 | } 85 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Concurrency/AsyncLock.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AsyncLock.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/21/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | In case nobody holds this lock, the work will be queued and executed immediately 13 | on thread that is requesting lock. 14 | 15 | In case there is somebody currently holding that lock, action will be enqueued. 16 | When owned of the lock finishes with it's processing, it will also execute 17 | and pending work. 18 | 19 | That means that enqueued work could possibly be executed later on a different thread. 20 | */ 21 | class AsyncLock 22 | : Disposable 23 | , Lock 24 | , SynchronizedDisposeType { 25 | typealias Action = () -> Void 26 | 27 | var _lock = SpinLock() 28 | 29 | private var _queue: Queue = Queue(capacity: 0) 30 | 31 | private var _isExecuting: Bool = false 32 | private var _hasFaulted: Bool = false 33 | 34 | // lock { 35 | func lock() { 36 | _lock.lock() 37 | } 38 | 39 | func unlock() { 40 | _lock.unlock() 41 | } 42 | // } 43 | 44 | private func enqueue(action: I) -> I? { 45 | _lock.lock(); defer { _lock.unlock() } // { 46 | if _hasFaulted { 47 | return nil 48 | } 49 | 50 | if _isExecuting { 51 | _queue.enqueue(action) 52 | return nil 53 | } 54 | 55 | _isExecuting = true 56 | 57 | return action 58 | // } 59 | } 60 | 61 | private func dequeue() -> I? { 62 | _lock.lock(); defer { _lock.unlock() } // { 63 | if _queue.count > 0 { 64 | return _queue.dequeue() 65 | } 66 | else { 67 | _isExecuting = false 68 | return nil 69 | } 70 | // } 71 | } 72 | 73 | func invoke(action: I) { 74 | let firstEnqueuedAction = enqueue(action) 75 | 76 | if let firstEnqueuedAction = firstEnqueuedAction { 77 | firstEnqueuedAction.invoke() 78 | } 79 | else { 80 | // action is enqueued, it's somebody else's concern now 81 | return 82 | } 83 | 84 | while true { 85 | let nextAction = dequeue() 86 | 87 | if let nextAction = nextAction { 88 | nextAction.invoke() 89 | } 90 | else { 91 | return 92 | } 93 | } 94 | } 95 | 96 | func dispose() { 97 | synchronizedDispose() 98 | } 99 | 100 | func _synchronized_dispose() { 101 | _queue = Queue(capacity: 0) 102 | _hasFaulted = true 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Event.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Event.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | /** 13 | Represents sequence event 14 | 15 | Sequence grammar: 16 | Next\* (Error | Completed) 17 | */ 18 | public enum Event : CustomDebugStringConvertible { 19 | /** 20 | Next element is produced 21 | */ 22 | case Next(Element) 23 | 24 | /** 25 | Sequence terminates with error 26 | */ 27 | case Error(ErrorType) 28 | 29 | /** 30 | Sequence completes sucessfully 31 | */ 32 | case Completed 33 | } 34 | 35 | extension Event { 36 | /** 37 | - returns: Description of event 38 | */ 39 | public var debugDescription: String { 40 | get { 41 | switch self { 42 | case .Next(let value): 43 | return "Next(\(value))" 44 | case .Error(let error): 45 | return "Error(\(error))" 46 | case .Completed: 47 | return "Completed" 48 | } 49 | } 50 | } 51 | } 52 | 53 | /** 54 | Compares two events. They are equal if they are both the same member of `Event` enumeration. 55 | 56 | In case `Error` events are being compared, they are equal in case their `NSError` representations are equal (domain and code). 57 | */ 58 | public func == (lhs: Event, rhs: Event) -> Bool { 59 | switch (lhs, rhs) { 60 | case (.Completed, .Completed): return true 61 | case (.Error(let e1), .Error(let e2)): 62 | let error1 = e1 as NSError 63 | let error2 = e2 as NSError 64 | 65 | return error1.domain == error2.domain 66 | && error1.code == error2.code 67 | case (.Next(let v1), .Next(let v2)): return v1 == v2 68 | default: return false 69 | } 70 | } 71 | 72 | extension Event { 73 | /** 74 | - returns: Is `Completed` or `Error` event 75 | */ 76 | public var isStopEvent: Bool { 77 | get { 78 | switch self { 79 | case .Next: return false 80 | case .Error, .Completed: return true 81 | } 82 | } 83 | } 84 | 85 | /** 86 | - returns: If `Next` event, returns element value. 87 | */ 88 | public var element: Element? { 89 | get { 90 | if case .Next(let value) = self { 91 | return value 92 | } 93 | return nil 94 | } 95 | } 96 | 97 | /** 98 | - returns: If `Error` event, returns error. 99 | */ 100 | public var error: ErrorType? { 101 | get { 102 | if case .Error(let error) = self { 103 | return error 104 | } 105 | return nil 106 | } 107 | } 108 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/SchedulerType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SchedulerType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Represents an object that schedules units of work. 13 | */ 14 | public protocol SchedulerType: ImmediateSchedulerType { 15 | /** 16 | Type that represents time interval in the context of this scheduler. 17 | */ 18 | typealias TimeInterval 19 | 20 | /** 21 | Type that represents absolute time in the context of this scheduler. 22 | */ 23 | typealias Time 24 | 25 | /** 26 | - returns: Current time. 27 | */ 28 | var now : Time { 29 | get 30 | } 31 | 32 | /** 33 | Schedules an action to be executed. 34 | 35 | - parameter state: State passed to the action to be executed. 36 | - parameter dueTime: Relative time after which to execute the action. 37 | - parameter action: Action to be executed. 38 | - returns: The disposable object used to cancel the scheduled action (best effort). 39 | */ 40 | func scheduleRelative(state: StateType, dueTime: TimeInterval, action: (StateType) -> Disposable) -> Disposable 41 | 42 | /** 43 | Schedules a periodic piece of work. 44 | 45 | - parameter state: State passed to the action to be executed. 46 | - parameter startAfter: Period after which initial work should be run. 47 | - parameter period: Period for running the work periodically. 48 | - parameter action: Action to be executed. 49 | - returns: The disposable object used to cancel the scheduled action (best effort). 50 | */ 51 | func schedulePeriodic(state: StateType, startAfter: TimeInterval, period: TimeInterval, action: (StateType) -> StateType) -> Disposable 52 | } 53 | 54 | extension SchedulerType { 55 | 56 | /** 57 | Periodic task will be emulated using recursive scheduling. 58 | 59 | - parameter state: Initial state passed to the action upon the first iteration. 60 | - parameter startAfter: Period after which initial work should be run. 61 | - parameter period: Period for running the work periodically. 62 | - returns: The disposable object used to cancel the scheduled recurring action (best effort). 63 | */ 64 | public func schedulePeriodic(state: StateType, startAfter: TimeInterval, period: TimeInterval, action: (StateType) -> StateType) -> Disposable { 65 | let schedule = SchedulePeriodicRecursive(scheduler: self, startAfter: startAfter, period: period, action: action, state: state) 66 | 67 | return schedule.start() 68 | } 69 | 70 | func scheduleRecursive(state: State, dueTime: TimeInterval, action: (state: State, scheduler: AnyRecursiveScheduler) -> ()) -> Disposable { 71 | let scheduler = RecursiveScheduler(scheduler: self, action: action) 72 | 73 | scheduler.schedule(state, dueTime: dueTime) 74 | 75 | return AnonymousDisposable { 76 | scheduler.dispose() 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /Pods/Representor/Representor/Representor.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Representor.swift 3 | // Representor 4 | // 5 | // Created by Zdenek Nemec on 8/17/14. 6 | // 7 | // 8 | 9 | import Foundation 10 | 11 | public struct Representor : Equatable, Hashable { 12 | public typealias Builder = RepresentorBuilder 13 | 14 | /// The transitions available for the representor 15 | public let transitions:[String:Transition] 16 | 17 | /// The separate representors embedded in the current representor. 18 | public let representors:[String:[Representor]] 19 | 20 | public let metadata:[String:String] 21 | 22 | /// The attributes of the representor 23 | public let attributes:[String:AnyObject] 24 | 25 | public init(transitions:[String:Transition]? = nil, representors:[String:[Representor]]? = nil, attributes:[String:AnyObject]? = nil, metadata:[String:String]? = nil) { 26 | self.transitions = transitions ?? [:] 27 | self.representors = representors ?? [:] 28 | self.attributes = attributes ?? [:] 29 | self.metadata = metadata ?? [:] 30 | } 31 | 32 | public var hashValue:Int { 33 | return transitions.count + representors.count + metadata.count + attributes.count 34 | } 35 | 36 | /// An extension to Representor to provide a builder interface for creating a Representor. 37 | public init(_ block:((builder:Builder) -> ())) { 38 | // This should belong in an extension, but due to a bug in the symbol 39 | // mangler in the Swift compiler it results in the symbol being incorrectly 40 | // mangled when being used from an extension. 41 | // 42 | // Swift ¯\_(ツ)_/¯ 43 | let builder = Builder() 44 | 45 | block(builder:builder) 46 | 47 | self.transitions = builder.transitions 48 | self.representors = builder.representors 49 | self.attributes = builder.attributes 50 | self.metadata = builder.metadata 51 | } 52 | } 53 | 54 | public func ==(lhs:[String:[Representor]], rhs:[String:[Representor]]) -> Bool { 55 | // There is a strange Swift bug where you cannot compare a 56 | // dictionary which has an array of objects which conform to Equatable. 57 | // So to be clear, that's comparing the following: 58 | // 59 | // [Equatable: [Equatable]] 60 | // 61 | // If one day this problem is solved in a newer version of Swift, 62 | // this method can be removed and the default == implementation can be used. 63 | // 64 | // Swift ¯\_(ツ)_/¯ 65 | 66 | if lhs.count != rhs.count { 67 | return false 68 | } 69 | 70 | for (key, value) in lhs { 71 | if let rhsValue = rhs[key] { 72 | if (value != rhsValue) { 73 | return false 74 | } 75 | } else { 76 | return false 77 | } 78 | } 79 | 80 | return true 81 | } 82 | 83 | public func ==(lhs:Representor, rhs:Representor) -> Bool { 84 | return ( 85 | lhs.transitions == rhs.transitions && 86 | lhs.representors == rhs.representors && 87 | lhs.metadata == rhs.metadata && 88 | (lhs.attributes as NSObject) == (rhs.attributes as NSObject) 89 | ) 90 | } 91 | -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/ShareReplay1.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ShareReplay1.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/10/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | // optimized version of share replay for most common case 12 | final class ShareReplay1 13 | : Observable 14 | , ObserverType 15 | , SynchronizedUnsubscribeType { 16 | 17 | typealias DisposeKey = Bag>.KeyType 18 | 19 | private let _source: Observable 20 | 21 | private var _lock = NSRecursiveLock() 22 | 23 | private var _connection: SingleAssignmentDisposable? 24 | private var _element: Element? 25 | private var _stopped = false 26 | private var _stopEvent = nil as Event? 27 | private var _observers = Bag>() 28 | 29 | init(source: Observable) { 30 | self._source = source 31 | } 32 | 33 | override func subscribe(observer: O) -> Disposable { 34 | _lock.lock(); defer { _lock.unlock() } 35 | return _synchronized_subscribe(observer) 36 | } 37 | 38 | func _synchronized_subscribe(observer: O) -> Disposable { 39 | if let element = self._element { 40 | observer.on(.Next(element)) 41 | } 42 | 43 | if let stopEvent = self._stopEvent { 44 | observer.on(stopEvent) 45 | return NopDisposable.instance 46 | } 47 | 48 | let initialCount = self._observers.count 49 | 50 | let disposeKey = self._observers.insert(AnyObserver(observer)) 51 | 52 | if initialCount == 0 { 53 | let connection = SingleAssignmentDisposable() 54 | _connection = connection 55 | 56 | connection.disposable = self._source.subscribe(self) 57 | } 58 | 59 | return SubscriptionDisposable(owner: self, key: disposeKey) 60 | } 61 | 62 | func synchronizedUnsubscribe(disposeKey: DisposeKey) { 63 | _lock.lock(); defer { _lock.unlock() } 64 | _synchronized_unsubscribe(disposeKey) 65 | } 66 | 67 | func _synchronized_unsubscribe(disposeKey: DisposeKey) { 68 | // if already unsubscribed, just return 69 | if self._observers.removeKey(disposeKey) == nil { 70 | return 71 | } 72 | 73 | if _observers.count == 0 { 74 | _connection?.dispose() 75 | _connection = nil 76 | } 77 | } 78 | 79 | func on(event: Event) { 80 | _lock.lock(); defer { _lock.unlock() } 81 | _synchronized_on(event) 82 | } 83 | 84 | func _synchronized_on(event: Event) { 85 | if _stopped { 86 | return 87 | } 88 | 89 | switch event { 90 | case .Next(let element): 91 | _element = element 92 | case .Error, .Completed: 93 | _stopEvent = event 94 | _stopped = true 95 | _connection?.dispose() 96 | _connection = nil 97 | } 98 | 99 | _observers.on(event) 100 | } 101 | } -------------------------------------------------------------------------------- /Pods/RxSwift/RxSwift/Observables/Implementations/Throttle.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Throttle.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/22/15. 6 | // Copyright (c) 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | class ThrottleSink 12 | : Sink 13 | , ObserverType 14 | , LockOwnerType 15 | , SynchronizedOnType { 16 | typealias Element = O.E 17 | typealias ParentType = Throttle 18 | 19 | private let _parent: ParentType 20 | 21 | let _lock = NSRecursiveLock() 22 | 23 | // state 24 | private var _id = 0 as UInt64 25 | private var _value: Element? = nil 26 | 27 | let cancellable = SerialDisposable() 28 | 29 | init(parent: ParentType, observer: O) { 30 | _parent = parent 31 | 32 | super.init(observer: observer) 33 | } 34 | 35 | func run() -> Disposable { 36 | let subscription = _parent._source.subscribe(self) 37 | 38 | return StableCompositeDisposable.create(subscription, cancellable) 39 | } 40 | 41 | func on(event: Event) { 42 | synchronizedOn(event) 43 | } 44 | 45 | func _synchronized_on(event: Event) { 46 | switch event { 47 | case .Next(let element): 48 | _id = _id &+ 1 49 | let currentId = _id 50 | _value = element 51 | 52 | 53 | let scheduler = _parent._scheduler 54 | let dueTime = _parent._dueTime 55 | 56 | let d = SingleAssignmentDisposable() 57 | self.cancellable.disposable = d 58 | d.disposable = scheduler.scheduleRelative(currentId, dueTime: dueTime, action: self.propagate) 59 | case .Error: 60 | _value = nil 61 | forwardOn(event) 62 | dispose() 63 | case .Completed: 64 | if let value = _value { 65 | _value = nil 66 | forwardOn(.Next(value)) 67 | } 68 | forwardOn(.Completed) 69 | dispose() 70 | } 71 | } 72 | 73 | func propagate(currentId: UInt64) -> Disposable { 74 | _lock.lock(); defer { _lock.unlock() } // { 75 | let originalValue = _value 76 | 77 | if let value = originalValue where _id == currentId { 78 | _value = nil 79 | forwardOn(.Next(value)) 80 | } 81 | // } 82 | return NopDisposable.instance 83 | } 84 | } 85 | 86 | class Throttle : Producer { 87 | 88 | private let _source: Observable 89 | private let _dueTime: Scheduler.TimeInterval 90 | private let _scheduler: Scheduler 91 | 92 | init(source: Observable, dueTime: Scheduler.TimeInterval, scheduler: Scheduler) { 93 | _source = source 94 | _dueTime = dueTime 95 | _scheduler = scheduler 96 | } 97 | 98 | override func run(observer: O) -> Disposable { 99 | let sink = ThrottleSink(parent: self, observer: observer) 100 | sink.disposable = sink.run() 101 | return sink 102 | } 103 | 104 | } -------------------------------------------------------------------------------- /Pods/Representor/Representor/Builder/RepresentorBuilder.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RepresentorBuilder.swift 3 | // Representor 4 | // 5 | // Created by Kyle Fuller on 05/11/2014. 6 | // Copyright (c) 2014 Apiary. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// A class used to build a representor using a builder pattern 12 | public class RepresentorBuilder { 13 | /// The added transitions 14 | private(set) public var transitions = [String:Transition]() 15 | 16 | /// The added representors 17 | private(set) public var representors = [String:[Representor]]() 18 | 19 | /// The added attributes 20 | private(set) public var attributes = [String:AnyObject]() 21 | 22 | /// The added metadata 23 | private(set) public var metadata = [String:String]() 24 | 25 | /// Adds an attribute 26 | /// 27 | /// - parameter name: The name of the attribute 28 | /// - parameter value: The value of the attribute 29 | public func addAttribute(name:String, value:AnyObject) { 30 | attributes[name] = value 31 | } 32 | 33 | // MARK: Representors 34 | 35 | /// Adds an embedded representor 36 | /// 37 | /// - parameter name: The name of the representor 38 | /// - parameter representor: The representor 39 | public func addRepresentor(name:String, representor:Representor) { 40 | if var representorSet = representors[name] { 41 | representorSet.append(representor) 42 | representors[name] = representorSet 43 | } else{ 44 | representors[name] = [representor] 45 | } 46 | } 47 | 48 | /// Adds an embedded representor using the builder pattern 49 | /// 50 | /// - parameter name: The name of the representor 51 | /// - parameter builder: A builder to build the representor 52 | public func addRepresentor(name:String, block:((builder:RepresentorBuilder) -> ())) { 53 | addRepresentor(name, representor:Representor(block)) 54 | } 55 | 56 | // MARK: Transition 57 | 58 | /// Adds a transition 59 | /// 60 | /// - parameter name: The name (or relation) for the transition 61 | /// - parameter transition: The transition 62 | public func addTransition(name:String, _ transition:Transition) { 63 | transitions[name] = transition 64 | } 65 | 66 | /// Adds a transition with a URI 67 | /// 68 | /// - parameter name: The name (or relation) for the transition 69 | /// - parameter uri: The URI of the transition 70 | public func addTransition(name:String, uri:String) { 71 | let transition = Transition(uri: uri, attributes:[:], parameters:[:]) 72 | transitions[name] = transition 73 | } 74 | 75 | /// Adds a transition with a URI using a builder 76 | /// 77 | /// - parameter name: The name (or relation) for the transition 78 | /// - parameter uri: The URI of the transition 79 | /// - parameter builder: The builder used to create the transition 80 | public func addTransition(name:String, uri:String, builder:((Transition.Builder) -> ())) { 81 | let transition = Transition(uri: uri, builder) 82 | transitions[name] = transition 83 | } 84 | 85 | // MARK: Metadata 86 | 87 | /// Adds an piece of metadata 88 | /// 89 | /// - parameter key: The key for the metadata 90 | /// - parameter value: The value of the key 91 | public func addMetaData(key:String, value:String) { 92 | metadata[key] = value 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Pods/Representor/README.md: -------------------------------------------------------------------------------- 1 | # Representor in Swift 2 | 3 | Swift library for building and consuming Hypermedia messages. See [The Hypermedia Project Charter](https://github.com/the-hypermedia-project/charter) for details. 4 | 5 | ## Installation 6 | 7 | Installation with CocoaPods is recommended using CocoaPods 0.36. 8 | 9 | ```ruby 10 | pod 'Representor' 11 | ``` 12 | 13 | ### Sub-projects 14 | 15 | Alternatively, you can clone Representor via git or as a submodule and 16 | include Representor.xcodeproj inside your project and add 17 | Representor.framework as a target dependency. 18 | 19 | ## Usage 20 | 21 | ### Using the builder pattern to build a representor 22 | 23 | ```swift 24 | import Representor 25 | 26 | let representor = Representor { builder in 27 | builder.addTransition("self", uri:"/notes/2/") 28 | builder.addTransition("previous", uri:"/notes/1/") 29 | builder.addTransition("next", uri:"/notes/3/") 30 | 31 | builder.addMetaData("title", "Customer Details") 32 | 33 | builder.addTransition("create", uri:"/notes/") { transitionBuilder in 34 | transitionBuilder.method = "POST" 35 | transitionBuilder.addAttribute("title") 36 | transitionBuilder.addAttribute("note") 37 | } 38 | } 39 | ``` 40 | 41 | ### Consuming a representor 42 | 43 | ```swift 44 | if let create = representor.transitions["create"] { 45 | println("You can create with the URI: \(create.uri).") 46 | } 47 | 48 | if let next = representor.transitions["next"] { 49 | println("The next representor can be found at: \(next).") 50 | } 51 | 52 | if let prev = representor.transitions["previous"] { 53 | println("The previous representor can be found at: \(prev).") 54 | } 55 | ``` 56 | 57 | ### Adapters 58 | 59 | The representor includes adapters to convert between other hypermedia types. 60 | 61 | #### NSHTTPURLResponse 62 | 63 | You can initialise a representor using a `NSHTTPURLResponse` and the body (`NSData`). It will use the content-type from the response and deserialise the body payload into a format. For unsupported/unknown types, nil will returned. 64 | 65 | ```swift 66 | let representor = HTTPDeserialization.deserialize(response, body: body) 67 | ``` 68 | 69 | You can register your own, or overide an existing HTTP deserializer for a 70 | specific content type. 71 | 72 | ```swift 73 | HTTPDeserialization.deserializers["application/json"] = { response, body in 74 | return Representor(...) 75 | } 76 | ``` 77 | 78 | ##### Supported Media Types 79 | 80 | - [HAL](http://stateless.co/hal_specification.html) JSON (application/hal+json) 81 | - [Siren](https://github.com/kevinswiber/siren) JSON (application/vnd.siren+json) 82 | 83 | #### HAL 84 | 85 | You can explicitly convert to and from a [HAL](http://stateless.co/hal_specification.html) representation using the following. 86 | 87 | ```swift 88 | let representor = deserializeHAL(representation) 89 | ``` 90 | 91 | ```swift 92 | let representation = serializeHAL(representor) 93 | ``` 94 | 95 | #### Siren 96 | 97 | Conversion to and from a [Siren](https://github.com/kevinswiber/siren) representation can also be done using the following. 98 | 99 | ```swift 100 | let representor = deserializeSiren(representation) 101 | ``` 102 | 103 | ```swift 104 | let representation = serializeSiren(representor) 105 | ``` 106 | 107 | ## License 108 | 109 | Representor is released under the MIT license. See [LICENSE](LICENSE). 110 | 111 | --------------------------------------------------------------------------------