├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CONTRIBUTING.md ├── DescribeOperators.playground ├── Pages │ ├── Index.xcplaygroundpage │ │ └── Contents.swift │ ├── amb.xcplaygroundpage │ │ └── Contents.swift │ ├── asObservable.xcplaygroundpage │ │ └── Contents.swift │ ├── buffer.xcplaygroundpage │ │ └── Contents.swift │ ├── catchError.xcplaygroundpage │ │ └── Contents.swift │ ├── catchErrorJustReturn.xcplaygroundpage │ │ └── Contents.swift │ ├── combineLatest.xcplaygroundpage │ │ └── Contents.swift │ ├── concat.xcplaygroundpage │ │ └── Contents.swift │ ├── create.xcplaygroundpage │ │ └── Contents.swift │ ├── debug.xcplaygroundpage │ │ └── Contents.swift │ ├── deferred.xcplaygroundpage │ │ └── Contents.swift │ ├── delaySubscription.xcplaygroundpage │ │ └── Contents.swift │ ├── distinctUntilChanged.xcplaygroundpage │ │ └── Contents.swift │ ├── doOn.xcplaygroundpage │ │ └── Contents.swift │ ├── elementAt.xcplaygroundpage │ │ └── Contents.swift │ ├── empty.xcplaygroundpage │ │ └── Contents.swift │ ├── error.xcplaygroundpage │ │ └── Contents.swift │ ├── filter.xcplaygroundpage │ │ └── Contents.swift │ ├── flatMap.xcplaygroundpage │ │ └── Contents.swift │ ├── flatMapFirst.xcplaygroundpage │ │ └── Contents.swift │ ├── flatMapLatest.xcplaygroundpage │ │ └── Contents.swift │ ├── flatMapWithIndex.xcplaygroundpage │ │ └── Contents.swift │ ├── ignoreElements.xcplaygroundpage │ │ └── Contents.swift │ ├── interval.xcplaygroundpage │ │ └── Contents.swift │ ├── just.xcplaygroundpage │ │ └── Contents.swift │ ├── map.xcplaygroundpage │ │ └── Contents.swift │ ├── mapWithIndex.xcplaygroundpage │ │ └── Contents.swift │ ├── merge.xcplaygroundpage │ │ └── Contents.swift │ ├── multicast.xcplaygroundpage │ │ └── Contents.swift │ ├── never.xcplaygroundpage │ │ └── Contents.swift │ ├── observeOn.xcplaygroundpage │ │ └── Contents.swift │ ├── of.xcplaygroundpage │ │ └── Contents.swift │ ├── publish.xcplaygroundpage │ │ └── Contents.swift │ ├── range.xcplaygroundpage │ │ └── Contents.swift │ ├── reduce.xcplaygroundpage │ │ └── Contents.swift │ ├── refCount.xcplaygroundpage │ │ └── Contents.swift │ ├── repeatElement.xcplaygroundpage │ │ └── Contents.swift │ ├── replay.xcplaygroundpage │ │ └── Contents.swift │ ├── replayAll.xcplaygroundpage │ │ └── Contents.swift │ ├── retry.xcplaygroundpage │ │ └── Contents.swift │ ├── retryWhen.xcplaygroundpage │ │ └── Contents.swift │ ├── sample.xcplaygroundpage │ │ └── Contents.swift │ ├── scan.xcplaygroundpage │ │ └── Contents.swift │ ├── shareReplay.xcplaygroundpage │ │ └── Contents.swift │ ├── single.xcplaygroundpage │ │ └── Contents.swift │ ├── skip.xcplaygroundpage │ │ └── Contents.swift │ ├── skipDuration.xcplaygroundpage │ │ └── Contents.swift │ ├── skipUntil.xcplaygroundpage │ │ └── Contents.swift │ ├── skipWhile.xcplaygroundpage │ │ └── Contents.swift │ ├── skipWhileWithIndex.xcplaygroundpage │ │ └── Contents.swift │ ├── startWith.xcplaygroundpage │ │ └── Contents.swift │ ├── subscribe.xcplaygroundpage │ │ └── Contents.swift │ ├── subscribeOn.xcplaygroundpage │ │ └── Contents.swift │ ├── switchLatest.xcplaygroundpage │ │ └── Contents.swift │ ├── take.xcplaygroundpage │ │ └── Contents.swift │ ├── takeDuration.xcplaygroundpage │ │ └── Contents.swift │ ├── takeLast.xcplaygroundpage │ │ └── Contents.swift │ ├── takeUntil.xcplaygroundpage │ │ └── Contents.swift │ ├── takeWhile.xcplaygroundpage │ │ └── Contents.swift │ ├── takeWhileWithIndex.xcplaygroundpage │ │ └── Contents.swift │ ├── throttle.xcplaygroundpage │ │ └── Contents.swift │ ├── timeout.xcplaygroundpage │ │ └── Contents.swift │ ├── timer.xcplaygroundpage │ │ └── Contents.swift │ ├── toArray.xcplaygroundpage │ │ └── Contents.swift │ ├── toObservable.xcplaygroundpage │ │ └── Contents.swift │ ├── using.xcplaygroundpage │ │ └── Contents.swift │ ├── window.xcplaygroundpage │ │ └── Contents.swift │ ├── withLatestFrom.xcplaygroundpage │ │ └── Contents.swift │ └── zip.xcplaygroundpage │ │ └── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ └── contents.xcworkspacedata ├── Documentation ├── API.md ├── ComparisonWithOtherLibraries.md ├── DesignRationale.md ├── ExampleApp.md ├── Examples.md ├── GettingStarted.md ├── HotAndColdObservables.md ├── Installation.md ├── IssueTemplate.md ├── Linux.md ├── MathBehindRx.md ├── Migration.md ├── NewFeatureRequestTemplate.md ├── Playgrounds.md ├── Schedulers.md ├── Subjects.md ├── Tips.md ├── UnitTests.md ├── Units.md ├── Warnings.md └── Why.md ├── LICENSE.md ├── Package.swift ├── Preprocessor ├── Preprocessor.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── Preprocessor │ └── main.swift └── README.md ├── README.md ├── RXSwift operators.pdf ├── Rx.playground ├── Pages │ ├── Combining_Observables.xcplaygroundpage │ │ └── Contents.swift │ ├── Conditional_and_Boolean_Operators.xcplaygroundpage │ │ └── Contents.swift │ ├── Connectable_Observable_Operators.xcplaygroundpage │ │ └── Contents.swift │ ├── Error_Handling_Operators.xcplaygroundpage │ │ └── Contents.swift │ ├── Filtering_Observables.xcplaygroundpage │ │ └── Contents.swift │ ├── Index.xcplaygroundpage │ │ └── Contents.swift │ ├── Introduction.xcplaygroundpage │ │ └── Contents.swift │ ├── Mathematical_and_Aggregate_Operators.xcplaygroundpage │ │ └── Contents.swift │ ├── Observable_Utility_Operators.xcplaygroundpage │ │ └── Contents.swift │ ├── Subjects.xcplaygroundpage │ │ └── Contents.swift │ └── Transforming_Observables.xcplaygroundpage │ │ └── Contents.swift ├── Sources │ └── SupportCode.swift ├── contents.xcplayground └── playground.xcworkspace │ └── contents.xcworkspacedata ├── Rx.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ ├── RxBlocking-OSX.xcscheme │ ├── RxBlocking-iOS.xcscheme │ ├── RxBlocking-tvOS.xcscheme │ ├── RxBlocking-watchOS.xcscheme │ ├── RxCocoa-OSX.xcscheme │ ├── RxCocoa-iOS.xcscheme │ ├── RxCocoa-tvOS.xcscheme │ ├── RxCocoa-watchOS.xcscheme │ ├── RxSwift-OSX.xcscheme │ ├── RxSwift-iOS.xcscheme │ ├── RxSwift-tvOS.xcscheme │ ├── RxSwift-watchOS.xcscheme │ ├── RxTests-OSX.xcscheme │ ├── RxTests-iOS.xcscheme │ └── RxTests-tvOS.xcscheme ├── Rx.xcworkspace └── contents.xcworkspacedata ├── RxBlocking.podspec ├── RxBlocking ├── BlockingObservable+Operators.swift ├── BlockingObservable.swift ├── Info.plist ├── ObservableConvertibleType+Blocking.swift ├── README.md └── RunLoopLock.swift ├── RxCocoa.podspec ├── RxCocoa ├── Common │ ├── CLLocationManager+Rx.swift │ ├── CocoaUnits │ │ ├── ControlEvent.swift │ │ ├── ControlProperty.swift │ │ ├── Driver │ │ │ ├── ControlEvent+Driver.swift │ │ │ ├── ControlProperty+Driver.swift │ │ │ ├── Driver+Operators+arity.swift │ │ │ ├── Driver+Operators+arity.tt │ │ │ ├── Driver+Operators.swift │ │ │ ├── Driver+Subscription.swift │ │ │ ├── Driver.swift │ │ │ ├── ObservableConvertibleType+Driver.swift │ │ │ └── Variable+Driver.swift │ │ └── UIBindingObserver.swift │ ├── DelegateProxy.swift │ ├── DelegateProxyType.swift │ ├── KVORepresentable+CoreGraphics.swift │ ├── KVORepresentable+Swift.swift │ ├── KVORepresentable.swift │ ├── Logging.swift │ ├── NSLayoutConstraint+Rx.swift │ ├── Observable+Bind.swift │ ├── Observables │ │ ├── Implementations │ │ │ ├── ControlTarget.swift │ │ │ ├── DeallocObservable.swift │ │ │ ├── KVOObservable.swift │ │ │ ├── KVOObserver.swift │ │ │ └── MessageSentObserver.swift │ │ ├── NSNotificationCenter+Rx.swift │ │ ├── NSObject+Rx+KVORepresentable.swift │ │ ├── NSObject+Rx+RawRepresentable.swift │ │ ├── NSObject+Rx.swift │ │ └── NSURLSession+Rx.swift │ ├── Proxies │ │ └── RxCLLocationManagerDelegateProxy.swift │ ├── RxCocoa.swift │ ├── RxTarget.swift │ ├── SectionedViewDataSourceType.swift │ ├── _RX.h │ ├── _RX.m │ ├── _RXDelegateProxy.h │ ├── _RXDelegateProxy.m │ ├── _RXKVOObserver.h │ ├── _RXKVOObserver.m │ ├── _RXObjCRuntime.h │ └── _RXObjCRuntime.m ├── Info.plist ├── OSX │ ├── NSButton+Rx.swift │ ├── NSControl+Rx.swift │ ├── NSImageView+Rx.swift │ ├── NSSlider+Rx.swift │ ├── NSTextField+Rx.swift │ └── NSView+Rx.swift ├── RxCocoa.h └── iOS │ ├── DataSources │ ├── RxCollectionViewReactiveArrayDataSource.swift │ └── RxTableViewReactiveArrayDataSource.swift │ ├── Events │ └── ItemEvents.swift │ ├── NSTextStorage+Rx.swift │ ├── Protocols │ ├── RxCollectionViewDataSourceType.swift │ └── RxTableViewDataSourceType.swift │ ├── Proxies │ ├── RxCollectionViewDataSourceProxy.swift │ ├── RxCollectionViewDelegateProxy.swift │ ├── RxImagePickerDelegateProxy.swift │ ├── RxScrollViewDelegateProxy.swift │ ├── RxSearchBarDelegateProxy.swift │ ├── RxSearchControllerDelegateProxy.swift │ ├── RxTableViewDataSourceProxy.swift │ ├── RxTableViewDelegateProxy.swift │ ├── RxTextStorageDelegateProxy.swift │ └── RxTextViewDelegateProxy.swift │ ├── UIActivityIndicatorView+Rx.swift │ ├── UIApplication+Rx.swift │ ├── UIBarButtonItem+Rx.swift │ ├── UIButton+Rx.swift │ ├── UICollectionView+Rx.swift │ ├── UIControl+Rx.swift │ ├── UIDatePicker+Rx.swift │ ├── UIGestureRecognizer+Rx.swift │ ├── UIImagePickerController+Rx.swift │ ├── UIImageView+Rx.swift │ ├── UILabel+Rx.swift │ ├── UIProgressView+Rx.swift │ ├── UIRefreshControl+Rx.swift │ ├── UIScrollView+Rx.swift │ ├── UISearchBar+Rx.swift │ ├── UISearchController+Rx.swift │ ├── UISegmentedControl+Rx.swift │ ├── UISlider+Rx.swift │ ├── UIStepper+Rx.swift │ ├── UISwitch+Rx.swift │ ├── UITabBarItem+Rx.swift │ ├── UITableView+Rx.swift │ ├── UITextField+Rx.swift │ ├── UITextView+Rx.swift │ └── UIView+Rx.swift ├── RxExample ├── RxDataSources │ ├── DataSources+Rx │ │ ├── ObservableConvertibleType+Differentiator.swift │ │ ├── RxCollectionViewSectionedAnimatedDataSource.swift │ │ ├── RxCollectionViewSectionedReloadDataSource.swift │ │ ├── RxTableViewSectionedAnimatedDataSource.swift │ │ ├── RxTableViewSectionedReloadDataSource.swift │ │ └── UISectionedViewType+RxAnimatedDataSource.swift │ ├── DataSources │ │ ├── AnimatableSectionModel.swift │ │ ├── AnimatableSectionModelType+ItemPath.swift │ │ ├── AnimatableSectionModelType.swift │ │ ├── AnimationConfiguration.swift │ │ ├── Changeset.swift │ │ ├── CollectionViewSectionedDataSource.swift │ │ ├── DataSources.swift │ │ ├── Differentiator.swift │ │ ├── IdentifiableType.swift │ │ ├── IdentifiableValue.swift │ │ ├── ItemPath.swift │ │ ├── Optional+Extensions.swift │ │ ├── SectionModel.swift │ │ ├── SectionModelType.swift │ │ ├── TableViewSectionedDataSource.swift │ │ └── UI+SectionedViewType.swift │ └── README.md ├── RxExample-iOSTests │ ├── Info.plist │ ├── Mocks │ │ ├── MockGitHubAPI.swift │ │ ├── MockWireframe.swift │ │ ├── NotImplementedStubs.swift │ │ └── ValidationResult+Equatable.swift │ ├── RxExample_iOSTests.swift │ └── TestScheduler+MarbleTests.swift ├── RxExample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── xcshareddata │ │ └── xcschemes │ │ ├── RxExample-OSX.xcscheme │ │ ├── RxExample-iOS-no-module.xcscheme │ │ └── RxExample-iOS.xcscheme └── RxExample │ ├── Example.swift │ ├── Examples │ ├── APIWrappers │ │ └── APIWrappersViewController.swift │ ├── Calculator │ │ ├── CalculatorAction.swift │ │ ├── CalculatorState.swift │ │ ├── CalculatorViewController.swift │ │ └── Operation.swift │ ├── Dependencies.swift │ ├── GeolocationExample │ │ └── GeolocationViewController.swift │ ├── GitHubSearchRepositories │ │ ├── GitHubSearchRepositoriesAPI.swift │ │ ├── GitHubSearchRepositoriesViewController.swift │ │ └── UINavigationController+Extensions.swift │ ├── GitHubSignup │ │ ├── BindingExtensions.swift │ │ ├── DefaultImplementations.swift │ │ ├── Protocols.swift │ │ ├── UsingDriver │ │ │ ├── GitHubSignupViewController2.swift │ │ │ └── GithubSignupViewModel2.swift │ │ └── UsingVanillaObservables │ │ │ ├── GitHubSignupViewController1.swift │ │ │ └── GithubSignupViewModel1.swift │ ├── ImagePicker │ │ ├── ImagePickerController.swift │ │ └── UIImagePickerController+RxCreate.swift │ ├── Numbers │ │ └── NumbersViewController.swift │ ├── OSX simple example │ │ └── IntroductionExampleViewController.swift │ ├── SimpleTableViewExample │ │ └── SimpleTableViewExampleViewController.swift │ ├── SimpleTableViewExampleSectioned │ │ └── SimpleTableViewExampleSectionedViewController.swift │ ├── SimpleValidation │ │ └── SimpleValidationViewController.swift │ ├── TablViewEditPartialUpdate │ │ └── TableViewControllerEditPartialUpdate.swift │ ├── TableViewPartialUpdates │ │ ├── NumberCell.swift │ │ ├── NumberSectionView.swift │ │ └── PartialUpdatesViewController.swift │ ├── TableViewWithEditingCommands │ │ ├── DetailViewController.swift │ │ ├── RandomUserAPI.swift │ │ ├── String+extensions.swift │ │ ├── TableViewWithEditingCommandsViewController.swift │ │ ├── UIImageView+Extensions.swift │ │ └── User.swift │ └── WikipediaImageSearch │ │ ├── ViewModels │ │ └── SearchResultViewModel.swift │ │ ├── Views │ │ ├── CollectionViewImageCell.swift │ │ ├── WikipediaImageCell.xib │ │ ├── WikipediaSearchCell.swift │ │ ├── WikipediaSearchCell.xib │ │ └── WikipediaSearchViewController.swift │ │ └── WikipediaAPI │ │ ├── WikipediaAPI.swift │ │ ├── WikipediaPage.swift │ │ └── WikipediaSearchResult.swift │ ├── Images.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-40.png │ │ ├── Icon-40@2x-1.png │ │ ├── Icon-40@2x.png │ │ ├── Icon-60@2x-1.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── Icon-76.png │ │ ├── Icon-76@2x.png │ │ ├── Icon-Small.png │ │ ├── Icon-Small@2x-1.png │ │ ├── Icon-Small@3x.png │ │ └── Rx_Logo_M.png │ └── ReactiveExtensionsLogo.imageset │ │ ├── Contents.json │ │ ├── ReactiveExtensionsLogo-2.png │ │ └── ReactiveExtensionsLogo.png │ ├── Info-OSX.plist │ ├── Info-iOS.plist │ ├── OSX │ ├── AppDelegate.swift │ └── Main.storyboard │ ├── Operators.swift │ ├── RxExample.xcdatamodeld │ ├── .xccurrentversion │ └── RxExample.xcdatamodel │ │ └── contents │ ├── Services │ ├── ActivityIndicator.swift │ ├── DownloadableImage.swift │ ├── GeolocationService.swift │ ├── HtmlParsing.swift │ ├── ImageService.swift │ ├── PseudoRandomGenerator.swift │ ├── Randomizer.swift │ ├── Reachability.swift │ ├── ReachabilityService.swift │ ├── UIImage+Extensions.swift │ ├── UIImageView+DownloadableImage.swift │ └── Wireframe.swift │ ├── String+URL.swift │ ├── ViewController.swift │ └── iOS │ ├── AppDelegate.swift │ ├── LaunchScreen.xib │ ├── Main.storyboard │ └── RootViewController.swift ├── RxSwift.podspec ├── RxSwift ├── AnyObserver.swift ├── Cancelable.swift ├── Concurrency │ ├── AsyncLock.swift │ ├── Lock.swift │ ├── LockOwnerType.swift │ ├── SynchronizedDisposeType.swift │ ├── SynchronizedOnType.swift │ ├── SynchronizedSubscribeType.swift │ └── SynchronizedUnsubscribeType.swift ├── ConnectableObservableType.swift ├── DataStructures │ ├── Bag.swift │ ├── InfiniteSequence.swift │ ├── PriorityQueue.swift │ └── Queue.swift ├── Disposable.swift ├── Disposables │ ├── AnonymousDisposable.swift │ ├── BinaryDisposable.swift │ ├── BooleanDisposable.swift │ ├── CompositeDisposable.swift │ ├── DisposeBag.swift │ ├── DisposeBase.swift │ ├── NAryDisposable.swift │ ├── NAryDisposable.tt │ ├── NopDisposable.swift │ ├── RefCountDisposable.swift │ ├── ScheduledDisposable.swift │ ├── SerialDisposable.swift │ ├── SingleAssignmentDisposable.swift │ ├── StableCompositeDisposable.swift │ └── SubscriptionDisposable.swift ├── Errors.swift ├── Event.swift ├── Extensions │ └── String+Rx.swift ├── HelpfulFunctions.swift ├── ImmediateSchedulerType.swift ├── Info.plist ├── Observable+Extensions.swift ├── Observable.swift ├── ObservableConvertibleType.swift ├── ObservableType.swift ├── Observables │ ├── Implementations │ │ ├── AddRef.swift │ │ ├── Amb.swift │ │ ├── AnonymousObservable.swift │ │ ├── Buffer.swift │ │ ├── Catch.swift │ │ ├── CombineLatest+CollectionType.swift │ │ ├── CombineLatest+arity.swift │ │ ├── CombineLatest+arity.tt │ │ ├── CombineLatest.swift │ │ ├── Concat.swift │ │ ├── ConnectableObservable.swift │ │ ├── Debug.swift │ │ ├── Deferred.swift │ │ ├── DelaySubscription.swift │ │ ├── DistinctUntilChanged.swift │ │ ├── Do.swift │ │ ├── ElementAt.swift │ │ ├── Empty.swift │ │ ├── Error.swift │ │ ├── Filter.swift │ │ ├── Generate.swift │ │ ├── Just.swift │ │ ├── Map.swift │ │ ├── Merge.swift │ │ ├── Multicast.swift │ │ ├── Never.swift │ │ ├── ObserveOn.swift │ │ ├── ObserveOnSerialDispatchQueue.swift │ │ ├── Producer.swift │ │ ├── Range.swift │ │ ├── Reduce.swift │ │ ├── RefCount.swift │ │ ├── Repeat.swift │ │ ├── RetryWhen.swift │ │ ├── Sample.swift │ │ ├── Scan.swift │ │ ├── Sequence.swift │ │ ├── ShareReplay1.swift │ │ ├── ShareReplay1WhileConnected.swift │ │ ├── SingleAsync.swift │ │ ├── Sink.swift │ │ ├── Skip.swift │ │ ├── SkipUntil.swift │ │ ├── SkipWhile.swift │ │ ├── StartWith.swift │ │ ├── SubscribeOn.swift │ │ ├── Switch.swift │ │ ├── Take.swift │ │ ├── TakeLast.swift │ │ ├── TakeUntil.swift │ │ ├── TakeWhile.swift │ │ ├── Throttle.swift │ │ ├── Timeout.swift │ │ ├── Timer.swift │ │ ├── ToArray.swift │ │ ├── Using.swift │ │ ├── Window.swift │ │ ├── WithLatestFrom.swift │ │ ├── Zip+CollectionType.swift │ │ ├── Zip+arity.swift │ │ ├── Zip+arity.tt │ │ └── Zip.swift │ ├── Observable+Aggregate.swift │ ├── Observable+Binding.swift │ ├── Observable+Concurrency.swift │ ├── Observable+Creation.swift │ ├── Observable+Debug.swift │ ├── Observable+Multiple.swift │ ├── Observable+Single.swift │ ├── Observable+StandardSequenceOperators.swift │ └── Observable+Time.swift ├── ObserverType.swift ├── Observers │ ├── AnonymousObserver.swift │ ├── ObserverBase.swift │ └── TailRecursiveSink.swift ├── Platform │ ├── Platform.Darwin.swift │ └── Platform.Linux.swift ├── Rx.swift ├── RxMutableBox.swift ├── SchedulerType.swift ├── Schedulers │ ├── ConcurrentDispatchQueueScheduler.swift │ ├── ConcurrentMainScheduler.swift │ ├── CurrentThreadScheduler.swift │ ├── DispatchQueueSchedulerQOS.swift │ ├── HistoricalScheduler.swift │ ├── HistoricalSchedulerTimeConverter.swift │ ├── ImmediateScheduler.swift │ ├── Internal │ │ ├── AnonymousInvocable.swift │ │ ├── InvocableScheduledItem.swift │ │ ├── InvocableType.swift │ │ ├── ScheduledItem.swift │ │ └── ScheduledItemType.swift │ ├── MainScheduler.swift │ ├── OperationQueueScheduler.swift │ ├── RecursiveScheduler.swift │ ├── SchedulerServices+Emulation.swift │ ├── SerialDispatchQueueScheduler.swift │ ├── VirtualTimeConverterType.swift │ └── VirtualTimeScheduler.swift └── Subjects │ ├── BehaviorSubject.swift │ ├── PublishSubject.swift │ ├── ReplaySubject.swift │ ├── SubjectType.swift │ └── Variable.swift ├── RxTests.podspec ├── RxTests ├── Any+Equatable.swift ├── ColdObservable.swift ├── Event+Equatable.swift ├── HotObservable.swift ├── Info.plist ├── Recorded.swift ├── RxTests.swift ├── Schedulers │ ├── TestScheduler.swift │ └── TestSchedulerVirtualTimeConverter.swift ├── Subscription.swift ├── TestableObservable.swift ├── TestableObserver.swift └── XCTest+Rx.swift ├── Sources ├── AllTests │ ├── AnonymousObservable+Test.swift │ ├── AssumptionsTest.swift │ ├── BackgroundThreadPrimitiveHotObservable.swift │ ├── BagTest.swift │ ├── BehaviorSubjectTest.swift │ ├── CurrentThreadSchedulerTest.swift │ ├── DisposableTest.swift │ ├── ElementIndexPair.swift │ ├── EquatableArray.swift │ ├── Foundation+Extensions.swift │ ├── MainSchedulerTests.swift │ ├── MainThreadPrimitiveHotObservable.swift │ ├── MockDisposable.swift │ ├── MySubject.swift │ ├── Observable+AggregateTest.swift │ ├── Observable+BindingTest.swift │ ├── Observable+BlockingTest.swift │ ├── Observable+ConcurrencyTest.swift │ ├── Observable+CreationTest.swift │ ├── Observable+Extensions.swift │ ├── Observable+MultipleTest+CombineLatest.swift │ ├── Observable+MultipleTest+Zip.swift │ ├── Observable+MultipleTest.swift │ ├── Observable+SingleTest.swift │ ├── Observable+StandardSequenceOperatorsTest.swift │ ├── Observable+SubscriptionTest.swift │ ├── Observable+TimeTest.swift │ ├── Observable.Extensions.swift │ ├── ObserverTests.swift │ ├── PrimitiveHotObservable.swift │ ├── PrimitiveMockObserver.swift │ ├── QueueTests.swift │ ├── Recorded+Timeless.swift │ ├── RxMutableBox.swift │ ├── RxTest.swift │ ├── SubjectConcurrencyTest.swift │ ├── TestConnectableObservable.swift │ ├── TestErrors.swift │ ├── TestVirtualScheduler.swift │ ├── VariableTest.swift │ ├── XCTest+AllTests.swift │ └── main.swift ├── RxBlocking │ ├── BlockingObservable+Operators.swift │ ├── BlockingObservable.swift │ ├── ObservableConvertibleType+Blocking.swift │ └── RunLoopLock.swift ├── RxCocoa │ └── RxCocoa.h ├── RxSwift │ ├── AddRef.swift │ ├── Amb.swift │ ├── AnonymousDisposable.swift │ ├── AnonymousInvocable.swift │ ├── AnonymousObservable.swift │ ├── AnonymousObserver.swift │ ├── AnyObserver.swift │ ├── AsyncLock.swift │ ├── Bag.swift │ ├── BehaviorSubject.swift │ ├── BinaryDisposable.swift │ ├── BooleanDisposable.swift │ ├── Buffer.swift │ ├── Cancelable.swift │ ├── Catch.swift │ ├── CombineLatest+CollectionType.swift │ ├── CombineLatest+arity.swift │ ├── CombineLatest.swift │ ├── CompositeDisposable.swift │ ├── Concat.swift │ ├── ConcurrentDispatchQueueScheduler.swift │ ├── ConcurrentMainScheduler.swift │ ├── ConnectableObservable.swift │ ├── ConnectableObservableType.swift │ ├── CurrentThreadScheduler.swift │ ├── Debug.swift │ ├── Deferred.swift │ ├── DelaySubscription.swift │ ├── DispatchQueueSchedulerQOS.swift │ ├── Disposable.swift │ ├── DisposeBag.swift │ ├── DisposeBase.swift │ ├── DistinctUntilChanged.swift │ ├── Do.swift │ ├── ElementAt.swift │ ├── Empty.swift │ ├── Error.swift │ ├── Errors.swift │ ├── Event.swift │ ├── Filter.swift │ ├── Generate.swift │ ├── HistoricalScheduler.swift │ ├── HistoricalSchedulerTimeConverter.swift │ ├── ImmediateScheduler.swift │ ├── ImmediateSchedulerType.swift │ ├── InfiniteSequence.swift │ ├── InvocableScheduledItem.swift │ ├── InvocableType.swift │ ├── Just.swift │ ├── Lock.swift │ ├── LockOwnerType.swift │ ├── MainScheduler.swift │ ├── Map.swift │ ├── Merge.swift │ ├── Multicast.swift │ ├── NAryDisposable.swift │ ├── Never.swift │ ├── NopDisposable.swift │ ├── Observable+Aggregate.swift │ ├── Observable+Binding.swift │ ├── Observable+Concurrency.swift │ ├── Observable+Creation.swift │ ├── Observable+Debug.swift │ ├── Observable+Extensions.swift │ ├── Observable+Multiple.swift │ ├── Observable+Single.swift │ ├── Observable+StandardSequenceOperators.swift │ ├── Observable+Time.swift │ ├── Observable.swift │ ├── ObservableConvertibleType.swift │ ├── ObservableType.swift │ ├── ObserveOn.swift │ ├── ObserveOnSerialDispatchQueue.swift │ ├── ObserverBase.swift │ ├── ObserverType.swift │ ├── OperationQueueScheduler.swift │ ├── Platform.Darwin.swift │ ├── Platform.Linux.swift │ ├── PriorityQueue.swift │ ├── Producer.swift │ ├── PublishSubject.swift │ ├── Queue.swift │ ├── Range.swift │ ├── RecursiveScheduler.swift │ ├── Reduce.swift │ ├── RefCount.swift │ ├── RefCountDisposable.swift │ ├── Repeat.swift │ ├── ReplaySubject.swift │ ├── RetryWhen.swift │ ├── Rx.swift │ ├── RxMutableBox.swift │ ├── Sample.swift │ ├── Scan.swift │ ├── ScheduledDisposable.swift │ ├── ScheduledItem.swift │ ├── ScheduledItemType.swift │ ├── SchedulerServices+Emulation.swift │ ├── SchedulerType.swift │ ├── Sequence.swift │ ├── SerialDispatchQueueScheduler.swift │ ├── SerialDisposable.swift │ ├── ShareReplay1.swift │ ├── ShareReplay1WhileConnected.swift │ ├── SingleAssignmentDisposable.swift │ ├── SingleAsync.swift │ ├── Sink.swift │ ├── Skip.swift │ ├── SkipUntil.swift │ ├── SkipWhile.swift │ ├── StableCompositeDisposable.swift │ ├── StartWith.swift │ ├── String+Rx.swift │ ├── SubjectType.swift │ ├── SubscribeOn.swift │ ├── SubscriptionDisposable.swift │ ├── Switch.swift │ ├── SynchronizedDisposeType.swift │ ├── SynchronizedOnType.swift │ ├── SynchronizedSubscribeType.swift │ ├── SynchronizedUnsubscribeType.swift │ ├── TailRecursiveSink.swift │ ├── Take.swift │ ├── TakeLast.swift │ ├── TakeUntil.swift │ ├── TakeWhile.swift │ ├── Throttle.swift │ ├── Timeout.swift │ ├── Timer.swift │ ├── ToArray.swift │ ├── Using.swift │ ├── Variable.swift │ ├── VirtualTimeConverterType.swift │ ├── VirtualTimeScheduler.swift │ ├── Window.swift │ ├── WithLatestFrom.swift │ ├── Zip+CollectionType.swift │ ├── Zip+arity.swift │ └── Zip.swift └── RxTests │ ├── Any+Equatable.swift │ ├── ColdObservable.swift │ ├── Event+Equatable.swift │ ├── HotObservable.swift │ ├── Recorded.swift │ ├── RxTests.swift │ ├── Subscription.swift │ ├── TestScheduler.swift │ ├── TestSchedulerVirtualTimeConverter.swift │ ├── TestableObservable.swift │ ├── TestableObserver.swift │ └── XCTest+Rx.swift ├── Tests ├── PerformanceTests │ ├── Info.plist │ ├── PerformanceTools.swift │ └── main.swift ├── RxCocoaTests │ ├── CLLocationManager+RxTests.swift │ ├── Control+RxTests+Cocoa.swift │ ├── Control+RxTests+UIKit.swift │ ├── Control+RxTests.swift │ ├── ControlEventTests.swift │ ├── ControlPropertyTests.swift │ ├── DelegateProxyTest+Cocoa.swift │ ├── DelegateProxyTest+UIKit.swift │ ├── DelegateProxyTest.swift │ ├── Driver+Extensions.swift │ ├── Driver+Test.swift │ ├── KVOObservableTests.swift │ ├── NSControl+RxTests.swift │ ├── NSLayoutConstraint+RxTests.swift │ ├── NSNotificationCenterTests.swift │ ├── NSObject+RxTests.swift │ ├── NSView+RxTests.swift │ ├── RXObjCRuntime+Testing.h │ ├── RXObjCRuntime+Testing.m │ ├── RuntimeStateSnapshot.swift │ ├── RxObjCRuntimeState.swift │ ├── RxTest+Controls.swift │ ├── RxTests-OSX-Bridging-Header.h │ ├── RxTests-iOS-Bridging-Header.h │ ├── RxTests-tvOS-Bridging-Header.h │ ├── SentMessageTest.swift │ ├── TestImplementations │ │ └── SectionedViewDataSourceMock.swift │ ├── UICollectionView+RxTests.swift │ ├── UIImagePickerController+RxTests.swift │ ├── UIRefreshControl+RxTests.swift │ ├── UISearchBar+RxTests.swift │ ├── UISearchController+RxTests.swift │ ├── UITabBarItem+RxTests.swift │ ├── UITableView+RxTests.swift │ └── UIView+RxTests.swift ├── RxSwiftTests │ ├── TestImplementations │ │ ├── ElementIndexPair.swift │ │ ├── EquatableArray.swift │ │ ├── Mocks │ │ │ ├── BackgroundThreadPrimitiveHotObservable.swift │ │ │ ├── MainThreadPrimitiveHotObservable.swift │ │ │ ├── MockDisposable.swift │ │ │ ├── MySubject.swift │ │ │ ├── Observable.Extensions.swift │ │ │ ├── PrimitiveHotObservable.swift │ │ │ ├── PrimitiveMockObserver.swift │ │ │ └── TestConnectableObservable.swift │ │ ├── Observable+Extensions.swift │ │ └── TestVirtualScheduler.swift │ └── Tests │ │ ├── AnonymousObservable+Test.swift │ │ ├── AssumptionsTest.swift │ │ ├── BagTest.swift │ │ ├── BehaviorSubjectTest.swift │ │ ├── CurrentThreadSchedulerTest.swift │ │ ├── DisposableTest.swift │ │ ├── HistoricalSchedulerTest.swift │ │ ├── MainSchedulerTests.swift │ │ ├── Observable+AggregateTest.swift │ │ ├── Observable+BindingTest.swift │ │ ├── Observable+BlockingTest.swift │ │ ├── Observable+ConcurrencyTest.swift │ │ ├── Observable+CreationTest.swift │ │ ├── Observable+MultipleTest+CombineLatest.swift │ │ ├── Observable+MultipleTest+CombineLatest.tt │ │ ├── Observable+MultipleTest+Zip.swift │ │ ├── Observable+MultipleTest+Zip.tt │ │ ├── Observable+MultipleTest.swift │ │ ├── Observable+SingleTest.swift │ │ ├── Observable+StandardSequenceOperatorsTest.swift │ │ ├── Observable+SubscriptionTest.swift │ │ ├── Observable+TimeTest.swift │ │ ├── ObserverTests.swift │ │ ├── QueueTests.swift │ │ ├── SubjectConcurrencyTest.swift │ │ ├── VariableTest.swift │ │ └── VirtualSchedulerTest.swift ├── RxTest.swift └── Tests │ ├── Foundation+Extensions.swift │ ├── Info.plist │ ├── Recorded+Timeless.swift │ ├── TestErrors.swift │ └── XCTest+AllTests.swift ├── UIExplanation.playground ├── Pages │ ├── From Main Thread.xcplaygroundpage │ │ └── Contents.swift │ ├── From Queue.xcplaygroundpage │ │ └── Contents.swift │ ├── SubjectTests.xcplaygroundpage │ │ └── Contents.swift │ ├── With ShareReplay.xcplaygroundpage │ │ └── Contents.swift │ ├── Without ShareRelay.xcplaygroundpage │ │ └── Contents.swift │ ├── structTest.xcplaygroundpage │ │ └── Contents.swift │ └── test.xcplaygroundpage │ │ └── Contents.swift ├── Sources │ └── SupportCode.swift └── contents.xcplayground ├── assets ├── CNAME.txt ├── LICENSE.txt └── Rx_Logo_M.png └── scripts ├── automation-tests.sh ├── automation-tests ├── 01_githubSignUp.js ├── 02_searchWikipedia.js ├── 03_masterDetail.js ├── 04_controlsTests.js ├── 05_reactivePartialUpdates.js ├── common.js └── main.js ├── common.sh ├── package-spm.swift ├── pre-release-tests.sh ├── test-linux.sh ├── validate-headers.swift ├── validate-markdown.sh ├── validate-playgrounds.sh └── validate-podspec.sh /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | 3 | osx_image: xcode7.3 4 | 5 | notifications: 6 | slack: rxswift:3ykt2Z61f8GkdvhCZTYPduOL 7 | email: false 8 | 9 | script: ./scripts/pre-release-tests.sh 10 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/amb.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | import RxSwift 3 | import XCPlayground 4 | //: [Next asObservable](@next) 5 | 6 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 7 | example("amb") { 8 | let subjectA = PublishSubject() 9 | let subjectB = PublishSubject() 10 | let subjectC = PublishSubject() 11 | let subjectD = PublishSubject() 12 | 13 | let ambSequence = [subjectA, subjectB, subjectC, subjectD].amb() 14 | ambSequence.subscribe { e in 15 | print(e) 16 | } 17 | 18 | subjectC.onNext(0) 19 | subjectA.onNext(3) 20 | subjectB.onNext(102) 21 | subjectC.onNext(1) 22 | subjectD.onNext(45) 23 | } 24 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/asObservable.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | //: [Next buffer](@next) 7 | 8 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 9 | 10 | example("as Observable") { 11 | let variable = Variable(0) 12 | 13 | variable.asObservable().subscribe { e in 14 | print(e) 15 | } 16 | variable.value = 1 17 | } 18 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/buffer.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next catchError](@next) 9 | example("buffer") { 10 | let varA = Variable(0) 11 | 12 | let bufferSequence = varA.asObservable() 13 | .buffer(timeSpan: 3, count: 3, scheduler: MainScheduler.instance) 14 | bufferSequence.subscribe { e in 15 | print("\(NSDate()) - \(e)") 16 | } 17 | varA.value = 1 18 | varA.value = 2 19 | varA.value = 3 20 | delay(3) { 21 | varA.value = 4 22 | varA.value = 5 23 | delay(5) { 24 | varA.value = 6 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/catchErrorJustReturn.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next combineLatest](@next) 9 | example("without catchErrorJustReturn") { 10 | let sequenceWithError = Observable.of(1, 2, 3, 4) 11 | .concat(Observable.error(RxError.Unknown)) 12 | .concat(Observable.just(5)) 13 | sequenceWithError.subscribe { e in 14 | print(e) 15 | } 16 | } 17 | 18 | example("with catchErrorJustReturn") { 19 | let sequenceWithError = Observable.of(1, 2, 3, 4) 20 | .concat(Observable.error(RxError.Unknown)) 21 | .concat(Observable.just(5)) 22 | let sequenceIgnoreError = sequenceWithError.catchErrorJustReturn(-1) 23 | sequenceIgnoreError.subscribe { e in 24 | print(e) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/combineLatest.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | 9 | 10 | //: [Next concat](@next)0 11 | 12 | example("combineLatest") { 13 | let firstSequence = createSequenceWithWait([1,2,3], waitTime: 2) { element in 14 | "\(element)" 15 | }.debug("firstSequence") 16 | let secondSequence = createSequenceWithWait(["A", "B", "C"], waitTime: 1) { element in 17 | "\(element)" 18 | } 19 | .delaySubscription(3, scheduler: MainScheduler.instance) 20 | .debug("secondSequence") 21 | 22 | let concatSequence = Observable.combineLatest(firstSequence, secondSequence) { 23 | first, second -> String in 24 | "\(first) - \(second)" 25 | } 26 | concatSequence.subscribe { e in 27 | print(e) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/concat.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | 9 | //: [Next create](@next) 10 | example("concat object method") { 11 | let firstSequence = Observable.of(1, 2, 3) 12 | let secondSequence = Observable.of("A", "B", "C") 13 | let concatSequence = firstSequence.concat(secondSequence) 14 | concatSequence.subscribe { e in 15 | print(e) 16 | } 17 | } 18 | 19 | example("concat from array") { 20 | let firstSequence = Observable.of(1,2,3) 21 | let secondSequence = Observable.of(4,5,6) 22 | let concatSequence = Observable.of(firstSequence, secondSequence) 23 | .concat() 24 | 25 | concatSequence.subscribe { e in 26 | print(e) 27 | } 28 | } 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/create.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next debug](@next) 7 | example("create") { 8 | let firstSequence = Observable.of(1, 2, 3) 9 | let secondSequence = Observable.of("A", "B", "C") 10 | 11 | let multipleSequence = Observable>.create { observer in 12 | observer.on(.Next(firstSequence)) 13 | observer.on(.Next(secondSequence)) 14 | return NopDisposable.instance 15 | } 16 | let concatSequence = multipleSequence.concat() 17 | concatSequence.subscribe { e in 18 | print(e) 19 | } 20 | } 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/debug.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next deferred](@next) 7 | example("debug") { 8 | let sequence = Observable.of(1, 2, 3) 9 | .debug("sequence") 10 | .subscribe{} 11 | } 12 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/deferred.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | 9 | //: [Next delaySubscription](@next) 10 | 11 | example("without deferred") { 12 | var i = 1 13 | let justObservable = Observable.just(i) 14 | i = 2 15 | _ = justObservable.subscribeNext{ print ("i = \($0)") } 16 | } 17 | 18 | example("with deferred") { 19 | var i = 1 20 | let deferredJustObservable = Observable.deferred{ 21 | Observable.just(i) 22 | } 23 | i = 2 24 | _ = deferredJustObservable.subscribeNext{ print ("i = \($0)") } 25 | } 26 | 27 | 28 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/delaySubscription.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next distinctUntilChanged](@next) 9 | example("delaySubscription") { 10 | let sequence = Observable.of(1, 2, 3).debug("sequence") 11 | .delaySubscription(3, scheduler: MainScheduler.instance).debug("delayed sequence") 12 | 13 | 14 | sequence.subscribe { e in 15 | print(e) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/distinctUntilChanged.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next doOn](@next) 9 | example("distinctUntilChanged") { 10 | let sequence = Observable.of(1, 2, 2, 3, 4, 4, 4, 1).distinctUntilChanged() 11 | sequence.subscribe { e in 12 | print(e) 13 | } 14 | } -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/doOn.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | 7 | //: [Next elementAt](@next) 8 | example("simple doOn") { 9 | let firstSequence = Observable.of(1,2).doOn{e in 10 | print(e) 11 | } 12 | 13 | firstSequence.subscribeNext{ e in 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/elementAt.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next empty](@next) 9 | example("elementAt") { 10 | let sequence = Observable.of(0, 10, 20, 30, 40) 11 | .elementAt(2) 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/empty.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next error](@next) 7 | example("empty") { 8 | let sequence = Observable.empty() 9 | sequence.subscribe { e in 10 | print(e) 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/error.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next filter](@next) 7 | example("error") { 8 | let sequence = Observable 9 | .error(RxError.Unknown) 10 | sequence.subscribe { e in 11 | print(e) 12 | } 13 | } -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/filter.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next flatMap](@next) 9 | example("filter") { 10 | let sequence = Observable.of(1, 20, 3, 40) 11 | .filter{ $0 > 10} 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/flatMap.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next flatMapFirst](@next) 9 | 10 | example("flatMap with wait") { 11 | let sequence:Observable = createSequenceWithWait([0,1,2], waitTime: 1) { $0 } 12 | let flatMapSequence:Observable = sequence.flatMap{val in 13 | createSequenceWithWait([10,11,12], waitTime: 2) { element in 14 | "\(element) - \(val)" 15 | } 16 | } 17 | flatMapSequence.subscribe { e in 18 | print(e) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/ignoreElements.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next interval](@next) 9 | example("ignoreElements") { 10 | let sequence = Observable.of(1, 2, 3, 4) 11 | .ignoreElements() 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/interval.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next just](@next) 9 | example("interval") { 10 | let sequence = Observable.interval(1, scheduler: MainScheduler.instance) 11 | sequence.subscribe { e in 12 | print(e) 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/just.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next map](@next) 7 | example("just") { 8 | let sequence = Observable.just(100) 9 | sequence.subscribe { e in 10 | print(e) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/map.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next mapWithIndex](@next) 7 | example("map") { 8 | let sequence = Observable.of(1, 2, 3) 9 | .map{ "\($0 * 5)" } 10 | sequence.subscribe { e in 11 | print(e) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/mapWithIndex.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next merge](@next) 7 | example("mapWithIndex") { 8 | let sequence = Observable.of("A", "B", "C") 9 | .mapWithIndex({ "\($0) / \($1)" }) 10 | sequence.subscribe { e in 11 | print(e) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/multicast.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | 9 | 10 | //: [Next never](@next) 11 | 12 | example("multicast") { 13 | let subject = PublishSubject() 14 | let firstSequence = createSequenceWithWait([0,1,2,3,4,5]) { $0 } 15 | .multicast(subject) 16 | delay(2) { 17 | _ = subject.subscribe { e in 18 | print("first: \(e)") 19 | } 20 | } 21 | delay(3) { 22 | _ = subject.subscribe { e in 23 | print("second: \(e)") 24 | } 25 | } 26 | firstSequence.connect() 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/never.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next observeOn ](@next) 7 | example("never") { 8 | let sequence = Observable.never() 9 | sequence.subscribe { e in 10 | print(e) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/observeOn.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next of](@next) 7 | 8 | example("without observeOn") { 9 | let sequence = Observable.of(1, 2, 3) 10 | 11 | sequence.subscribe { e in 12 | print("\(NSThread.currentThread())\(e)") 13 | } 14 | } 15 | 16 | example("with observeOn") { 17 | let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) 18 | let sequence = Observable.of(1, 2, 3) 19 | 20 | sequence.observeOn(ConcurrentDispatchQueueScheduler.init(queue: queue)) 21 | .subscribe { e in 22 | print("\(NSThread.currentThread())\(e)") 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/of.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | 7 | //: [Next publish](@next) 8 | example("simple of") { 9 | let sequence = Observable.of(1, 2) 10 | 11 | sequence.subscribe { e in 12 | print(e) 13 | } 14 | } 15 | 16 | example("of for Observables") { 17 | let firstSequence = Observable.of(1, 2, 3) 18 | let secondSequence = Observable.of("A", "B", "C") 19 | 20 | let bothSequence = Observable.of(firstSequence, secondSequence) 21 | let mergedSequence = bothSequence.merge() 22 | 23 | mergedSequence.subscribe { e in 24 | print(e) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/range.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next reduce](@next) 9 | example("range") { 10 | let sequence = Observable.range(start: 5, count: 3) 11 | sequence.subscribe { e in 12 | print(e) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/reduce.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next refCount](@next) 7 | example("reduce") { 8 | let sequence = Observable.of(1, 2, 3, 4) 9 | .reduce(1) { $0 * $1 } 10 | sequence.subscribe { e in 11 | print(e) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/repeatElement.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | //XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | 9 | //: [Next replay](@next) 10 | example("repeatElement") { 11 | let sequence = Observable.repeatElement(1, scheduler: MainScheduler.instance) 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/replay.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | import XCPlayground 7 | 8 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 9 | //: [Next replayAll](@next) 10 | example("replay") { 11 | let firstSequence = Observable.interval(1, scheduler: MainScheduler.instance).replay(2) 12 | 13 | let firstDisposable = firstSequence.subscribe { e in 14 | print("first: \(e)") 15 | } 16 | 17 | firstSequence.connect() 18 | 19 | var secondDisposable: Disposable! 20 | delay(3) { 21 | secondDisposable = firstSequence.subscribe { e in 22 | print("second: \(e)") 23 | } 24 | } 25 | 26 | delay(4) { 27 | firstDisposable.dispose() 28 | } 29 | delay(5) { 30 | secondDisposable.dispose() 31 | } 32 | 33 | delay(7) { 34 | firstSequence.subscribe { e in 35 | print("third: \(e)") 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/replayAll.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | import XCPlayground 7 | 8 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 9 | //: [Next retry](@next) 10 | example("replayAll") { 11 | let firstSequence = Observable.interval(1, scheduler: MainScheduler.instance).replayAll() 12 | 13 | let firstDisposable = firstSequence.subscribe { e in 14 | print("first: \(e)") 15 | } 16 | 17 | firstSequence.connect() 18 | 19 | var secondDisposable: Disposable! 20 | delay(3) { 21 | secondDisposable = firstSequence.subscribe { e in 22 | print("second: \(e)") 23 | } 24 | } 25 | 26 | delay(4) { 27 | firstDisposable.dispose() 28 | } 29 | delay(5) { 30 | secondDisposable.dispose() 31 | } 32 | 33 | delay(7) { 34 | firstSequence.subscribe { e in 35 | print("third: \(e)") 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/retry.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next retryWhen](@next) 9 | example("retry full sequence") { 10 | let sequenceWithError = Observable.of(1, 2, 3, 4).concat(Observable.error(RxError.Unknown)) 11 | let wholeSequenceWithErrorRetry = sequenceWithError.retry(2) 12 | 13 | wholeSequenceWithErrorRetry.subscribe { e in 14 | print(e) 15 | } 16 | } 17 | 18 | example("retry only error") { 19 | let sequenceWithRetryError = Observable.of(1, 2, 3, 4).concat( 20 | Observable.error(RxError.Unknown).retry(2) 21 | ) 22 | 23 | sequenceWithRetryError.subscribe { e in 24 | print(e) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/sample.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next scan](@next) 9 | 10 | example("sampler") { 11 | let sampler = Observable.interval(2, scheduler: MainScheduler.instance).debug("sampler") 12 | 13 | let sequence:Observable = createSequenceWithWait([1,2,3,4,5,6], waitTime: 1).sample(sampler) 14 | sequence.subscribe { e in 15 | print(e) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/scan.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next shareReplay](@next) 7 | example("scan") { 8 | let sequence = Observable.of(1, 2, 3).scan(10) { result, element in 9 | return result + element 10 | } 11 | sequence.subscribe { e in 12 | print(e) 13 | } 14 | } 15 | 16 | example("scan multiply") { 17 | let sequence = Observable.of(2, 3, 5).scan(10) { result, element in 18 | return result * element 19 | } 20 | sequence.subscribe { e in 21 | print(e) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/single.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next skip](@next) 7 | example("single generate error") { 8 | let sequence = Observable.of(1, 2, 3, 4).single() 9 | sequence.subscribe { e in 10 | print(e) 11 | } 12 | } 13 | 14 | example("single") { 15 | let sequence = Observable.of(1, 2, 3, 5).single { 16 | $0 % 2 == 0 17 | } 18 | sequence.subscribe { e in 19 | print(e) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/skip.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next skipDuration](@next) 7 | example("skip") { 8 | let sequence = Observable.of(1, 2, 3, 4).skip(2) 9 | sequence.subscribe { e in 10 | print(e) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/skipDuration.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next skipUntil](@next) 9 | 10 | example("skip duration with wait") { 11 | let sequence = createSequenceWithWait([1,2,3,4]) { $0 }.skip(2, scheduler: MainScheduler.instance) 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/skipUntil.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next skipWhile](@next) 9 | example("skipUntil") { 10 | let firstSequence = createSequenceWithWait([1,2,3,4]) { $0 } 11 | let secondSequence = Observable.just(1) 12 | .delaySubscription(1, scheduler: MainScheduler.instance) 13 | let skippedSequence = firstSequence.skipUntil(secondSequence) 14 | 15 | skippedSequence.subscribe { e in 16 | print(e) 17 | } 18 | } -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/skipWhile.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next skipWhileWithIndex](@next) 9 | example("skipWhile") { 10 | let firstSequence = [1,2,3,4,0].toObservable() 11 | let skipSequence = firstSequence.skipWhile { $0 < 3 } 12 | 13 | skipSequence.subscribe { e in 14 | print(e) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/skipWhileWithIndex.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next startWith](@next) 9 | example("skipWhileWithIndex") { 10 | let firstSequence = [1,2,5,0,7].toObservable() 11 | let skipSequence = firstSequence.skipWhileWithIndex{ value, idx in 12 | value < 4 || idx < 2 13 | } 14 | skipSequence.subscribe { e in 15 | print(e) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/startWith.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next subscribe](@next) 7 | example("startWith") { 8 | let sequence = Observable.of(1, 2, 3).startWith(0) 9 | sequence.subscribe { e in 10 | print(e) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/take.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next takeDuration](@next) 7 | example("take") { 8 | let sequence = Observable.of(1, 2, 3, 4).take(2) 9 | sequence.subscribe { e in 10 | print(e) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/takeDuration.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next takeLast](@next) 9 | 10 | example("take duration with wait") { 11 | let sequence = createSequenceWithWait([1,2,3,4]) { $0 } 12 | let takeSequence = sequence.take(2, scheduler: MainScheduler.instance) 13 | takeSequence.subscribe { e in 14 | print(e) 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/takeLast.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | 9 | //: [Next takeUntil](@next) 10 | example("takeLast") { 11 | let sequence = Observable.of(1, 2, 3, 4).takeLast(2) 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } 16 | 17 | example("takeLast with wait") { 18 | let sequence = createSequenceWithWait([1,2,3,4]) { $0 } 19 | let takeSequence = sequence.takeLast(2) 20 | takeSequence.subscribe { e in 21 | print(e) 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/takeUntil.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next takeWhile](@next) 9 | 10 | example("takeUntil") { 11 | let stopSequence = Observable.just(1) 12 | .delaySubscription(2, scheduler: MainScheduler.instance) 13 | let sequence = createSequenceWithWait([1,2,3,4]) { $0 } 14 | .takeUntil(stopSequence) 15 | sequence.subscribe { e in 16 | print(e) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/takeWhile.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next takeWhileWithIndex](@next) 9 | 10 | example("takeWhile") { 11 | let sequence = [1,2,3,4].toObservable().takeWhile{ $0 < 3 } 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/takeWhileWithIndex.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next throttle](@next) 9 | 10 | example("takeWhileWithIndex") { 11 | let sequence = [1,2,3,4,5,6].toObservable() 12 | .takeWhileWithIndex{ (val, idx) in 13 | val % 2 == 0 || idx < 3 14 | } 15 | sequence.subscribe { e in 16 | print(e) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/throttle.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next timeout](@next) 9 | example("throttle") { 10 | let sequence = Observable.of(1, 2, 3, 4) 11 | .throttle(1, scheduler: MainScheduler.instance) 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } 16 | 17 | example("throttle with wait") { 18 | let sequence = createSequenceWithWait([1,2,3,4]) { $0 } 19 | .throttle(0.5, scheduler: MainScheduler.instance) 20 | 21 | sequence.subscribe { e in 22 | print(e) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/timeout.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next](@next) 9 | 10 | func withoutError() { 11 | example("timeout ") { 12 | 13 | let sequence = createSequenceWithWait([1,2,3,4]) { $0 } 14 | let timeout = sequence.timeout(1, scheduler: MainScheduler.instance) 15 | timeout.subscribe { e in 16 | print(e) 17 | } 18 | } 19 | } 20 | 21 | //withoutError() 22 | func withError() { 23 | example("failed timeout ") { 24 | let sequence = createSequenceWithWait([1,2,3,4]) { $0 } 25 | let timeoutSequence = sequence.timeout(0.9, scheduler: MainScheduler.instance) 26 | timeoutSequence.subscribe { e in 27 | print(e) 28 | } 29 | } 30 | } 31 | 32 | withError() 33 | 34 | 35 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/timer.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | import XCPlayground 7 | 8 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 9 | //: [Next toArray](@next) 10 | example("timer") { 11 | let sequence = Observable.timer(2, period: 3, scheduler: MainScheduler.instance) 12 | sequence.subscribe { e in 13 | print(e) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/toArray.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next toObservable](@next) 7 | example("toArray") { 8 | let sequence = Observable.of(1, 2, 3) 9 | 10 | let arraySequence = sequence.toArray() 11 | arraySequence.subscribe { e in 12 | print(e) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/toObservable.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | 6 | //: [Next using](@next) 7 | example("toObservable") { 8 | let firstSequence = [1, 2, 3].toObservable() 9 | 10 | firstSequence.subscribe { e in 11 | print(e) 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/using.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | 5 | import Foundation 6 | import RxSwift 7 | 8 | //: [Next window](@next) 9 | 10 | class FakeDisposable: Disposable { 11 | func dispose() { 12 | print("disposed") 13 | } 14 | } 15 | 16 | example("using") { 17 | let sequence = Observable.using({ 18 | return FakeDisposable() 19 | }, observableFactory: { d in 20 | Observable.just(1) 21 | }) as Observable 22 | 23 | 24 | sequence.subscribe { e in 25 | print(e) 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/window.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | //: [Next withLatestFrom](@next) 9 | example("window") { 10 | let varA = Variable(0) 11 | 12 | let bufferSequence:Observable> = varA.asObservable() 13 | .window(timeSpan: 3, count: 3, scheduler: MainScheduler.instance) 14 | .debug("bufferSequence") 15 | bufferSequence.subscribe { e in 16 | if case .Next(let observable) = e { 17 | print("\(NSDate()) - генерируем новый Observable") 18 | observable.subscribe { val in 19 | print(val) 20 | 21 | } 22 | } 23 | } 24 | varA.value = 1 25 | varA.value = 2 26 | varA.value = 3 27 | delay(4) { 28 | varA.value = 4 29 | 30 | varA.value = 5 31 | delay(4) { 32 | varA.value = 6 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Pages/withLatestFrom.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | import RxSwift 5 | import XCPlayground 6 | 7 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 8 | 9 | 10 | //: [Next zip](@next) 11 | 12 | example("withLatestFrom") { 13 | let varA = Variable(0) 14 | let varB = Variable(10) 15 | 16 | let withLatestFromSequence = varA.asObservable().withLatestFrom(varB.asObservable()) { 17 | "\($0) - \($1)" 18 | } 19 | withLatestFromSequence.subscribe { e in 20 | print(e) 21 | } 22 | varA.value = 1 23 | varA.value = 2 24 | varB.value = 20 25 | 26 | varB.value = 30 27 | varA.value = 5 28 | varA.value = 6 29 | } 30 | -------------------------------------------------------------------------------- /DescribeOperators.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | 2 | import Foundation 3 | 4 | public func example(description: String, action: () -> ()) { 5 | print("\n--- \(description) example ---") 6 | action() 7 | } 8 | 9 | public func delay(delay:Double, closure:()->()) { 10 | dispatch_after( 11 | dispatch_time( 12 | DISPATCH_TIME_NOW, 13 | Int64(delay * Double(NSEC_PER_SEC)) 14 | ), 15 | dispatch_get_main_queue(), closure) 16 | } 17 | 18 | #if NOT_IN_PLAYGROUND 19 | 20 | public func playgroundShouldContinueIndefinitely() { 21 | } 22 | 23 | #else 24 | 25 | import XCPlayground 26 | 27 | public func playgroundShouldContinueIndefinitely() { 28 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /DescribeOperators.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Documentation/ExampleApp.md: -------------------------------------------------------------------------------- 1 | 2 | ## RxExamples 3 | 4 | To run the example app: 5 | 6 | * Open `Rx.xcworkspace` 7 | * Choose one of example schemes (RxExample-iOS, RxExample-OSX) and hit `Run`. 8 | 9 | You can also run the example app using CocoaPods. 10 | 11 | ``` 12 | pod try RxSwift 13 | ``` 14 | -------------------------------------------------------------------------------- /Documentation/Linux.md: -------------------------------------------------------------------------------- 1 | Linux 2 | ===== 3 | 4 | We've made a proof of concept for Linux. 5 | 6 | To test it, create `Package.swift` in your test directory with the following content: 7 | 8 | ``` 9 | import PackageDescription 10 | 11 | let package = Package( 12 | name: "MyShinyUnicornCat", 13 | dependencies: [ 14 | .Package(url: "https://github.com/ReactiveX/RxSwift.git", Version(2, 0, 0)) 15 | ] 16 | ) 17 | ``` 18 | 19 | What does work: 20 | * Distribution using Swift Package Manager 21 | * Single Threaded mode (CurrentThreadScheduler) 22 | * Half of unit tests are passing. 23 | * Projects that can be compiled and "used": 24 | * RxSwift 25 | * RxBlocking 26 | * RxTests 27 | 28 | What doesn't work: 29 | * Schedulers - because they are dependent on https://github.com/apple/swift-corelibs-libdispatch and it still hasn't been released 30 | * Multithreading - still no access to c11 locks 31 | * For some reason it looks like Swift compiler generates wrong code when using `ErrorType` on `Linux`, so don't use errors, otherwise you can get weird crashes. 32 | -------------------------------------------------------------------------------- /Documentation/NewFeatureRequestTemplate.md: -------------------------------------------------------------------------------- 1 | **Please copy the following template [here](https://github.com/ReactiveX/RxSwift/issues/new) and fill in the missing fields so we can help you as soon as possible.** 2 | 3 | ``` 4 | *Short description of missing functionality*: 5 | 6 | E.g. I want this library to implement xxx operator. 7 | 8 | *Short code example of how you would like to use the API*: 9 | 10 | code goes here 11 | 12 | *The reason why I need this functionality*: 13 | 14 | E.g. I was trying to .... 15 | 16 | *Code I have right now*: 17 | 18 | code snippet that demonstrates how you've attempted to solve the problem 19 | 20 | ``` 21 | -------------------------------------------------------------------------------- /Documentation/Playgrounds.md: -------------------------------------------------------------------------------- 1 | ## Playgrounds 2 | 3 | To use playgrounds: 4 | 5 | * Open `Rx.xcworkspace` 6 | * Build `RxSwift-OSX` scheme 7 | * And then open `Rx` playground in `Rx.xcworkspace` tree view. 8 | * Choose `View > Show Debug Area` 9 | -------------------------------------------------------------------------------- /Documentation/Subjects.md: -------------------------------------------------------------------------------- 1 | Subjects 2 | ======== 3 | 4 | All of behave exactly the same like described [here](http://reactivex.io/documentation/subject.html) 5 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | **The MIT License** 2 | **Copyright © 2015 Krunoslav Zaher** 3 | **All rights reserved.** 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Preprocessor/Preprocessor.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RXSwift operators.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RXSwift operators.pdf -------------------------------------------------------------------------------- /Rx.playground/Pages/Index.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | 2 | /*: 3 | > # IMPORTANT: To use `Rx.playground`, please: 4 | 5 | 1. Open `Rx.xcworkspace` 6 | 2. Build `RxSwift-OSX` scheme 7 | 3. And then open `Rx` playground in `Rx.xcworkspace` tree view. 8 | 4. Choose `View > Show Debug Area` 9 | */ 10 | 11 | /*: 12 | ## Index: 13 | 14 | 1. [Introduction](Introduction) 15 | 1. [Subjects](Subjects) 16 | 1. [Transforming Observables](Transforming_Observables) 17 | 1. [Filtering Observables](Filtering_Observables) 18 | 1. [Combining Observables](Combining_Observables) 19 | 1. [Error Handling Operators](Error_Handling_Operators) 20 | 1. [Observable Utility Operators](Observable_Utility_Operators) 21 | 1. [Conditional and Boolean Operators](Conditional_and_Boolean_Operators) 22 | 1. [Mathematical and Aggregate Operators](Mathematical_and_Aggregate_Operators) 23 | 1. [Connectable Observable Operators](Connectable_Observable_Operators) 24 | 25 | */ 26 | 27 | //: [Index](Index) - [Next >>](@next) 28 | -------------------------------------------------------------------------------- /Rx.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | 2 | import Foundation 3 | 4 | public func example(description: String, action: () -> ()) { 5 | print("\n--- \(description) example ---") 6 | action() 7 | } 8 | 9 | public func delay(delay:Double, closure:()->()) { 10 | dispatch_after( 11 | dispatch_time( 12 | DISPATCH_TIME_NOW, 13 | Int64(delay * Double(NSEC_PER_SEC)) 14 | ), 15 | dispatch_get_main_queue(), closure) 16 | } 17 | 18 | #if NOT_IN_PLAYGROUND 19 | 20 | public func playgroundShouldContinueIndefinitely() { 21 | } 22 | 23 | #else 24 | 25 | import XCPlayground 26 | 27 | public func playgroundShouldContinueIndefinitely() { 28 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /Rx.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /Rx.playground/playground.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Rx.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RxBlocking.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "RxBlocking" 3 | s.version = "2.4" 4 | s.summary = "RxSwift Blocking operatos" 5 | s.description = <<-DESC 6 | Set of blocking operators for RxSwift. These operators are mostly intended for unit/integration tests 7 | with a couple of other special scenarios where they could be useful. 8 | 9 | E.g. 10 | 11 | Waiting for observable sequence to complete before exiting command line application. 12 | DESC 13 | s.homepage = "https://github.com/ReactiveX/RxSwift" 14 | s.license = 'MIT' 15 | s.author = { "Krunoslav Zaher" => "krunoslav.zaher@gmail.com" } 16 | s.source = { :git => "https://github.com/ReactiveX/RxSwift.git", :tag => s.version.to_s } 17 | 18 | s.requires_arc = true 19 | 20 | s.ios.deployment_target = '8.0' 21 | s.osx.deployment_target = '10.9' 22 | s.watchos.deployment_target = '2.0' 23 | s.tvos.deployment_target = '9.0' 24 | 25 | s.source_files = 'RxBlocking/**/*.swift' 26 | 27 | s.dependency 'RxSwift', '~> 2.4' 28 | end 29 | -------------------------------------------------------------------------------- /RxBlocking/BlockingObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BlockingObservable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 10/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | /** 15 | `BlockingObservable` is a variety of `Observable` that provides blocking operators. 16 | 17 | It can be useful for testing and demo purposes, but is generally inappropriate for production applications. 18 | 19 | If you think you need to use a `BlockingObservable` this is usually a sign that you should rethink your 20 | design. 21 | */ 22 | public struct BlockingObservable { 23 | let source: Observable 24 | } -------------------------------------------------------------------------------- /RxBlocking/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /RxBlocking/ObservableConvertibleType+Blocking.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObservableConvertibleType+Blocking.swift 3 | // RxBlocking 4 | // 5 | // Created by Krunoslav Zaher on 7/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | extension ObservableConvertibleType { 15 | /** 16 | Converts an Observable into a `BlockingObservable` (an Observable with blocking operators). 17 | 18 | - returns: `BlockingObservable` version of `self` 19 | */ 20 | @warn_unused_result(message="http://git.io/rxs.uo") 21 | public func toBlocking() -> BlockingObservable { 22 | return BlockingObservable(source: self.asObservable()) 23 | } 24 | } -------------------------------------------------------------------------------- /RxBlocking/README.md: -------------------------------------------------------------------------------- 1 | RxBlocking 2 | ============================================================ 3 | 4 | Set of blocking operators for easy unit testing. 5 | 6 | ***Don't use these operators in production apps. These operators are only meant for testing purposes.*** 7 | 8 | 9 | ```swift 10 | extension ObservableType { 11 | public func toArray() throws -> [E] {} 12 | } 13 | 14 | extension ObservableType { 15 | public func first() throws -> E? {} 16 | } 17 | 18 | extension ObservableType { 19 | public func last() throws -> E? {} 20 | } 21 | ``` 22 | 23 | 24 | -------------------------------------------------------------------------------- /RxCocoa/Common/CocoaUnits/Driver/ControlEvent+Driver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControlEvent+Driver.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 9/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | extension ControlEvent { 15 | /** 16 | Converts `ControlEvent` to `Driver` unit. 17 | 18 | `ControlEvent` already can't fail, so no special case needs to be handled. 19 | */ 20 | @warn_unused_result(message="http://git.io/rxs.uo") 21 | public func asDriver() -> Driver { 22 | return self.asDriver { (error) -> Driver in 23 | #if DEBUG 24 | rxFatalError("Somehow driver received error from a source that shouldn't fail.") 25 | #else 26 | return Driver.empty() 27 | #endif 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /RxCocoa/Common/CocoaUnits/Driver/ControlProperty+Driver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ControlProperty+Driver.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 9/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | extension ControlProperty { 15 | /** 16 | Converts `ControlProperty` to `Driver` unit. 17 | 18 | `ControlProperty` already can't fail, so no special case needs to be handled. 19 | */ 20 | @warn_unused_result(message="http://git.io/rxs.uo") 21 | public func asDriver() -> Driver { 22 | return self.asDriver { (error) -> Driver in 23 | #if DEBUG 24 | rxFatalError("Somehow driver received error from a source that shouldn't fail.") 25 | #else 26 | return Driver.empty() 27 | #endif 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /RxCocoa/Common/CocoaUnits/Driver/Variable+Driver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Variable+Driver.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | extension Variable { 15 | /** 16 | Converts `Variable` to `Driver` unit. 17 | 18 | - returns: Driving observable sequence. 19 | */ 20 | @warn_unused_result(message="http://git.io/rxs.uo") 21 | public func asDriver() -> Driver { 22 | let source = self.asObservable() 23 | .observeOn(driverObserveOnScheduler) 24 | return Driver(source) 25 | } 26 | } -------------------------------------------------------------------------------- /RxCocoa/Common/KVORepresentable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KVORepresentable.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 | /** 12 | Type that is KVO representable (KVO mechanism can be used to observe it). 13 | */ 14 | public protocol KVORepresentable { 15 | /** 16 | Associated KVO type. 17 | */ 18 | associatedtype KVOType 19 | 20 | /** 21 | Constructs `Self` using KVO value. 22 | */ 23 | init?(KVOValue: KVOType) 24 | } 25 | 26 | extension KVORepresentable { 27 | /** 28 | Initializes `KVORepresentable` with optional value. 29 | */ 30 | init?(KVOValue: KVOType?) { 31 | guard let KVOValue = KVOValue else { 32 | return nil 33 | } 34 | 35 | self.init(KVOValue: KVOValue) 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /RxCocoa/Common/Logging.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Logging.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 4/3/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Simple logging settings for RxCocoa library. 13 | */ 14 | public struct Logging { 15 | public typealias LogURLRequest = (NSURLRequest) -> Bool 16 | 17 | /** 18 | Log URL requests to standard output in curl format. 19 | */ 20 | public static var URLRequests: LogURLRequest = { _ in 21 | #if DEBUG 22 | return true 23 | #else 24 | return false 25 | #endif 26 | } 27 | } -------------------------------------------------------------------------------- /RxCocoa/Common/NSLayoutConstraint+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSLayoutConstraint+Rx.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if os(OSX) 12 | import Cocoa 13 | #else 14 | import UIKit 15 | #endif 16 | 17 | #if !RX_NO_MODULE 18 | import RxSwift 19 | #endif 20 | 21 | #if os(iOS) || os(OSX) || os(tvOS) 22 | extension NSLayoutConstraint { 23 | /** 24 | Bindable sink for `constant` property. 25 | */ 26 | public var rx_constant: AnyObserver { 27 | return UIBindingObserver(UIElement: self) { constraint, constant in 28 | constraint.constant = constant 29 | }.asObserver() 30 | } 31 | 32 | /** 33 | Bindable sink for `active` property. 34 | */ 35 | @available(iOS 8, OSX 10.10, *) 36 | public var rx_active: AnyObserver { 37 | return UIBindingObserver(UIElement: self) { constraint, value in 38 | constraint.active = value 39 | }.asObserver() 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /RxCocoa/Common/Observables/Implementations/DeallocObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DeallocObservable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | class DeallocObservable { 15 | let _subject = ReplaySubject.create(bufferSize: 1) 16 | 17 | init() { 18 | } 19 | 20 | deinit { 21 | _subject.on(.Next(())) 22 | _subject.on(.Completed) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /RxCocoa/Common/Proxies/RxCLLocationManagerDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxCLLocationManagerDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Carlos García on 8/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import CoreLocation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | class RxCLLocationManagerDelegateProxy : DelegateProxy 15 | , CLLocationManagerDelegate 16 | , DelegateProxyType { 17 | 18 | class func currentDelegateFor(object: AnyObject) -> AnyObject? { 19 | let locationManager: CLLocationManager = castOrFatalError(object) 20 | return locationManager.delegate 21 | } 22 | 23 | class func setCurrentDelegate(delegate: AnyObject?, toObject object: AnyObject) { 24 | let locationManager: CLLocationManager = castOrFatalError(object) 25 | locationManager.delegate = castOptionalOrFatalError(delegate) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /RxCocoa/Common/RxTarget.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTarget.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | class RxTarget : NSObject 15 | , Disposable { 16 | 17 | private var retainSelf: RxTarget? 18 | 19 | override init() { 20 | super.init() 21 | self.retainSelf = self 22 | 23 | #if TRACE_RESOURCES 24 | OSAtomicIncrement32(&resourceCount) 25 | #endif 26 | 27 | #if DEBUG 28 | MainScheduler.ensureExecutingOnScheduler() 29 | #endif 30 | } 31 | 32 | func dispose() { 33 | #if DEBUG 34 | MainScheduler.ensureExecutingOnScheduler() 35 | #endif 36 | self.retainSelf = nil 37 | } 38 | 39 | #if TRACE_RESOURCES 40 | deinit { 41 | OSAtomicDecrement32(&resourceCount) 42 | } 43 | #endif 44 | } -------------------------------------------------------------------------------- /RxCocoa/Common/SectionedViewDataSourceType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SectionedViewDataSourceType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 1/10/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Data source with access to underlying sectioned model. 13 | */ 14 | public protocol SectionedViewDataSourceType { 15 | /** 16 | Returns model at index path. 17 | 18 | In case data source doesn't contain any sections when this method is being called, `RxCocoaError.ItemsNotYetBound(object: self)` is thrown. 19 | 20 | - parameter indexPath: Model index path 21 | - returns: Model at index path. 22 | */ 23 | func modelAtIndexPath(indexPath: NSIndexPath) throws -> Any 24 | } -------------------------------------------------------------------------------- /RxCocoa/Common/_RX.m: -------------------------------------------------------------------------------- 1 | // 2 | // _RX.m 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import "_RX.h" 10 | 11 | -------------------------------------------------------------------------------- /RxCocoa/Common/_RXDelegateProxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // _RXDelegateProxy.h 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface _RXDelegateProxy : NSObject 12 | 13 | @property (nonatomic, assign, readonly) id _forwardToDelegate; 14 | 15 | -(void)_setForwardToDelegate:(id)forwardToDelegate retainDelegate:(BOOL)retainDelegate; 16 | 17 | -(BOOL)hasWiredImplementationForSelector:(SEL)selector; 18 | 19 | -(void)interceptedSelector:(SEL)selector withArguments:(NSArray*)arguments; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /RxCocoa/Common/_RXKVOObserver.h: -------------------------------------------------------------------------------- 1 | // 2 | // _RXKVOObserver.h 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 7/11/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /** 12 | ################################################################################ 13 | This file is part of RX private API 14 | ################################################################################ 15 | */ 16 | 17 | typedef void (^KVOCallback)(id); 18 | 19 | // Exists because if written in Swift, reading unowned is disabled during dealloc process 20 | @interface _RXKVOObserver : NSObject 21 | 22 | -(instancetype)initWithTarget:(id)target 23 | retainTarget:(BOOL)retainTarget 24 | keyPath:(NSString*)keyPath 25 | options:(NSKeyValueObservingOptions)options 26 | callback:(KVOCallback)callback; 27 | 28 | -(void)dispose; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /RxCocoa/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /RxCocoa/OSX/NSButton+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSButton+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 5/17/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | import Cocoa 14 | 15 | extension NSButton { 16 | 17 | /** 18 | Reactive wrapper for control event. 19 | */ 20 | public var rx_tap: ControlEvent { 21 | return rx_controlEvent 22 | } 23 | 24 | /** 25 | Reactive wrapper for `state` property`. 26 | */ 27 | public var rx_state: ControlProperty { 28 | return NSButton.rx_value( 29 | self, 30 | getter: { control in 31 | return control.state 32 | }, setter: { control, state in 33 | control.state = state 34 | } 35 | ) 36 | } 37 | } -------------------------------------------------------------------------------- /RxCocoa/OSX/NSSlider+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSSlider+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Junior B. on 24/05/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | import Cocoa 14 | 15 | extension NSSlider { 16 | 17 | /** 18 | Reactive wrapper for `value` property. 19 | */ 20 | public var rx_value: ControlProperty { 21 | return NSControl.rx_value( 22 | self, 23 | getter: { control in 24 | return control.doubleValue 25 | }, 26 | setter: { control, value in 27 | control.doubleValue = value 28 | } 29 | ) 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /RxCocoa/OSX/NSView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSView+Rx.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import Cocoa 11 | #if !RX_NO_MODULE 12 | import RxSwift 13 | #endif 14 | 15 | extension NSView { 16 | /** 17 | Bindable sink for `hidden` property. 18 | */ 19 | public var rx_hidden: AnyObserver { 20 | return UIBindingObserver(UIElement: self) { view, value in 21 | view.hidden = value 22 | }.asObserver() 23 | } 24 | 25 | /** 26 | Bindable sink for `alphaValue` property. 27 | */ 28 | public var rx_alpha: AnyObserver { 29 | return UIBindingObserver(UIElement: self) { view, value in 30 | view.alphaValue = value 31 | }.asObserver() 32 | } 33 | } -------------------------------------------------------------------------------- /RxCocoa/RxCocoa.h: -------------------------------------------------------------------------------- 1 | // 2 | // RxCocoa.h 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 2/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "_RX.h" 11 | #import "_RXDelegateProxy.h" 12 | #import "_RXKVOObserver.h" 13 | #import "_RXObjCRuntime.h" 14 | 15 | //! Project version number for RxCocoa. 16 | FOUNDATION_EXPORT double RxCocoaVersionNumber; 17 | 18 | //! Project version string for RxCocoa. 19 | FOUNDATION_EXPORT const unsigned char RxCocoaVersionString[]; -------------------------------------------------------------------------------- /RxCocoa/iOS/Events/ItemEvents.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ItemEvents.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/20/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | public typealias ItemMovedEvent = (sourceIndex: NSIndexPath, destinationIndex: NSIndexPath) -------------------------------------------------------------------------------- /RxCocoa/iOS/Protocols/RxCollectionViewDataSourceType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxCollectionViewDataSourceType.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | import UIKit 13 | #if !RX_NO_MODULE 14 | import RxSwift 15 | #endif 16 | 17 | /** 18 | Marks data source as `UICollectionView` reactive data source enabling it to be used with one of the `bindTo` methods. 19 | */ 20 | public protocol RxCollectionViewDataSourceType /*: UICollectionViewDataSource*/ { 21 | 22 | /** 23 | Type of elements that can be bound to collection view. 24 | */ 25 | associatedtype Element 26 | 27 | /** 28 | New observable sequence event observed. 29 | 30 | - parameter collectionView: Bound collection view. 31 | - parameter observedEvent: Event 32 | */ 33 | func collectionView(collectionView: UICollectionView, observedEvent: Event) -> Void 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /RxCocoa/iOS/Protocols/RxTableViewDataSourceType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTableViewDataSourceType.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/26/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | import UIKit 13 | #if !RX_NO_MODULE 14 | import RxSwift 15 | #endif 16 | 17 | /** 18 | Marks data source as `UITableView` reactive data source enabling it to be used with one of the `bindTo` methods. 19 | */ 20 | public protocol RxTableViewDataSourceType /*: UITableViewDataSource*/ { 21 | 22 | /** 23 | Type of elements that can be bound to table view. 24 | */ 25 | associatedtype Element 26 | 27 | /** 28 | New observable sequence event observed. 29 | 30 | - parameter tableView: Bound table view. 31 | - parameter observedEvent: Event 32 | */ 33 | func tableView(tableView: UITableView, observedEvent: Event) -> Void 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /RxCocoa/iOS/Proxies/RxCollectionViewDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxCollectionViewDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | import UIKit 13 | #if !RX_NO_MODULE 14 | import RxSwift 15 | #endif 16 | 17 | /** 18 | For more information take a look at `DelegateProxyType`. 19 | */ 20 | public class RxCollectionViewDelegateProxy 21 | : RxScrollViewDelegateProxy 22 | , UICollectionViewDelegate 23 | , UICollectionViewDelegateFlowLayout { 24 | 25 | /** 26 | Typed parent object. 27 | */ 28 | public weak private(set) var collectionView: UICollectionView? 29 | 30 | /** 31 | Initializes `RxCollectionViewDelegateProxy` 32 | 33 | - parameter parentObject: Parent object for delegate proxy. 34 | */ 35 | public required init(parentObject: AnyObject) { 36 | self.collectionView = (parentObject as! UICollectionView) 37 | super.init(parentObject: parentObject) 38 | } 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /RxCocoa/iOS/Proxies/RxTableViewDelegateProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTableViewDelegateProxy.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 6/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | import UIKit 13 | #if !RX_NO_MODULE 14 | import RxSwift 15 | #endif 16 | 17 | /** 18 | For more information take a look at `DelegateProxyType`. 19 | */ 20 | public class RxTableViewDelegateProxy 21 | : RxScrollViewDelegateProxy 22 | , UITableViewDelegate { 23 | 24 | 25 | /** 26 | Typed parent object. 27 | */ 28 | public weak private(set) var tableView: UITableView? 29 | 30 | /** 31 | Initializes `RxTableViewDelegateProxy` 32 | 33 | - parameter parentObject: Parent object for delegate proxy. 34 | */ 35 | public required init(parentObject: AnyObject) { 36 | self.tableView = (parentObject as! UITableView) 37 | super.init(parentObject: parentObject) 38 | } 39 | } 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UIActivityIndicatorView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIActivityIndicatorView+Rx.swift 3 | // Rx 4 | // 5 | // Created by Ivan Persidskiy on 02/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | 16 | extension UIActivityIndicatorView { 17 | 18 | /** 19 | Bindable sink for `startAnimating()`, `stopAnimating()` methods. 20 | */ 21 | public var rx_animating: AnyObserver { 22 | return UIBindingObserver(UIElement: self) { activityIndicator, active in 23 | if active { 24 | self.startAnimating() 25 | } else { 26 | self.stopAnimating() 27 | } 28 | }.asObserver() 29 | } 30 | 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UIApplication+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplication+Rx.swift 3 | // RxExample 4 | // 5 | // Created by Mads Bøgeskov on 18/01/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if os(iOS) 12 | import UIKit 13 | 14 | #if !RX_NO_MODULE 15 | import RxSwift 16 | #endif 17 | 18 | extension UIApplication { 19 | 20 | /** 21 | Bindable sink for `networkActivityIndicatorVisible`. 22 | */ 23 | public var rx_networkActivityIndicatorVisible: AnyObserver { 24 | return UIBindingObserver(UIElement: self) { application, active in 25 | application.networkActivityIndicatorVisible = active 26 | }.asObserver() 27 | } 28 | } 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UIButton+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIButton+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 3/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import Foundation 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | import UIKit 16 | 17 | extension UIButton { 18 | 19 | /** 20 | Reactive wrapper for `TouchUpInside` control event. 21 | */ 22 | public var rx_tap: ControlEvent { 23 | return rx_controlEvent(.TouchUpInside) 24 | } 25 | 26 | } 27 | 28 | #endif 29 | 30 | #if os(tvOS) 31 | 32 | import Foundation 33 | #if !RX_NO_MODULE 34 | import RxSwift 35 | #endif 36 | import UIKit 37 | 38 | extension UIButton { 39 | 40 | /** 41 | Reactive wrapper for `PrimaryActionTriggered` control event. 42 | */ 43 | public var rx_primaryAction: ControlEvent { 44 | return rx_controlEvent(.PrimaryActionTriggered) 45 | } 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UIDatePicker+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIDatePicker+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Daniel Tartaglia on 5/31/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import Foundation 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | import UIKit 16 | 17 | extension UIDatePicker { 18 | 19 | /** 20 | Reactive wrapper for `date` property. 21 | */ 22 | public var rx_date: ControlProperty { 23 | return UIControl.rx_value( 24 | self, 25 | getter: { datePicker in 26 | datePicker.date 27 | }, setter: { datePicker, value in 28 | datePicker.date = value 29 | } 30 | ) 31 | } 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UILabel+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UILabel+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 4/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | import UIKit 16 | 17 | extension UILabel { 18 | 19 | /** 20 | Bindable sink for `text` property. 21 | */ 22 | public var rx_text: AnyObserver { 23 | return UIBindingObserver(UIElement: self) { label, text in 24 | label.text = text 25 | }.asObserver() 26 | } 27 | 28 | /** 29 | Bindable sink for `attributedText` property. 30 | */ 31 | public var rx_attributedText: AnyObserver { 32 | return UIBindingObserver(UIElement: self) { label, text in 33 | label.attributedText = text 34 | }.asObserver() 35 | } 36 | 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UIProgressView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIProgressView+Rx.swift 3 | // Rx 4 | // 5 | // Created by Samuel Bae on 2/27/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | import UIKit 16 | 17 | extension UIProgressView { 18 | 19 | /** 20 | Bindable sink for `progress` property 21 | */ 22 | public var rx_progress: AnyObserver { 23 | return UIBindingObserver(UIElement: self) { progressView, progress in 24 | progressView.progress = progress 25 | }.asObserver() 26 | } 27 | 28 | } 29 | 30 | #endif -------------------------------------------------------------------------------- /RxCocoa/iOS/UIRefreshControl+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIRefreshControl+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Yosuke Ishikawa on 1/31/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | import UIKit 11 | 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | 16 | extension UIRefreshControl { 17 | 18 | /** 19 | Bindable sink for `beginRefreshing()`, `endRefreshing()` methods. 20 | */ 21 | public var rx_refreshing: AnyObserver { 22 | return UIBindingObserver(UIElement: self) { refreshControl, refresh in 23 | if refresh { 24 | refreshControl.beginRefreshing() 25 | } else { 26 | refreshControl.endRefreshing() 27 | } 28 | }.asObserver() 29 | } 30 | 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UISegmentedControl+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UISegmentedControl+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Carlos García on 8/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import UIKit 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | 16 | 17 | extension UISegmentedControl { 18 | 19 | /** 20 | Reactive wrapper for `selectedSegmentIndex` property. 21 | */ 22 | public var rx_value: ControlProperty { 23 | return UIControl.rx_value( 24 | self, 25 | getter: { segmentedControl in 26 | segmentedControl.selectedSegmentIndex 27 | }, setter: { segmentedControl, value in 28 | segmentedControl.selectedSegmentIndex = value 29 | } 30 | ) 31 | } 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UISlider+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UISlider+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Alexander van der Werff on 28/05/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import Foundation 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | import UIKit 16 | 17 | extension UISlider { 18 | 19 | /** 20 | Reactive wrapper for `value` property. 21 | */ 22 | public var rx_value: ControlProperty { 23 | return UIControl.rx_value( 24 | self, 25 | getter: { slider in 26 | slider.value 27 | }, setter: { slider, value in 28 | slider.value = value 29 | } 30 | ) 31 | } 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UIStepper+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIStepper+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Yuta ToKoRo on 9/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import Foundation 12 | import UIKit 13 | #if !RX_NO_MODULE 14 | import RxSwift 15 | #endif 16 | 17 | extension UIStepper { 18 | 19 | /** 20 | Reactive wrapper for `value` property. 21 | */ 22 | public var rx_value: ControlProperty { 23 | return UIControl.rx_value( 24 | self, 25 | getter: { stepper in 26 | stepper.value 27 | }, setter: { stepper, value in 28 | stepper.value = value 29 | } 30 | ) 31 | } 32 | 33 | } 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UISwitch+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UISwitch+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Carlos García on 8/7/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | 11 | import UIKit 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | 16 | 17 | extension UISwitch { 18 | 19 | /** 20 | Reactive wrapper for `on` property. 21 | */ 22 | public var rx_value: ControlProperty { 23 | return UIControl.rx_value( 24 | self, 25 | getter: { uiSwitch in 26 | uiSwitch.on 27 | }, setter: { uiSwitch, value in 28 | uiSwitch.on = value 29 | } 30 | ) 31 | } 32 | 33 | } 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UITabBarItem+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UITabBarItem+Rx.swift 3 | // Rx 4 | // 5 | // Created by Mateusz Derks on 04/03/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | import UIKit 13 | #if !RX_NO_MODULE 14 | import RxSwift 15 | #endif 16 | 17 | extension UITabBarItem { 18 | 19 | /** 20 | Bindable sink for `badgeValue` property. 21 | */ 22 | public var rx_badgeValue: AnyObserver { 23 | return UIBindingObserver(UIElement: self) { tabBarItem, badgeValue in 24 | tabBarItem.badgeValue = badgeValue 25 | }.asObserver() 26 | } 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UITextField+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UITextField+Rx.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 2/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | #if !RX_NO_MODULE 13 | import RxSwift 14 | #endif 15 | import UIKit 16 | 17 | extension UITextField { 18 | 19 | /** 20 | Reactive wrapper for `text` property. 21 | */ 22 | public var rx_text: ControlProperty { 23 | return UIControl.rx_value( 24 | self, 25 | getter: { textField in 26 | textField.text ?? "" 27 | }, setter: { textField, value in 28 | textField.text = value 29 | } 30 | ) 31 | } 32 | 33 | } 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /RxCocoa/iOS/UIView+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Rx.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | 11 | import Foundation 12 | import UIKit 13 | #if !RX_NO_MODULE 14 | import RxSwift 15 | #endif 16 | 17 | extension UIView { 18 | /** 19 | Bindable sink for `hidden` property. 20 | */ 21 | public var rx_hidden: AnyObserver { 22 | return UIBindingObserver(UIElement: self) { view, hidden in 23 | view.hidden = hidden 24 | }.asObserver() 25 | } 26 | 27 | /** 28 | Bindable sink for `alpha` property. 29 | */ 30 | public var rx_alpha: AnyObserver { 31 | return UIBindingObserver(UIElement: self) { view, alpha in 32 | view.alpha = alpha 33 | }.asObserver() 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources+Rx/RxCollectionViewSectionedReloadDataSource.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxCollectionViewSectionedReloadDataSource.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 7/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | #if !RX_NO_MODULE 12 | import RxSwift 13 | import RxCocoa 14 | #endif 15 | 16 | public class RxCollectionViewSectionedReloadDataSource 17 | : CollectionViewSectionedDataSource 18 | , RxCollectionViewDataSourceType { 19 | 20 | public typealias Element = [S] 21 | 22 | public override init() { 23 | super.init() 24 | } 25 | 26 | public func collectionView(collectionView: UICollectionView, observedEvent: Event) { 27 | UIBindingObserver(UIElement: self) { dataSource, element in 28 | dataSource.setSections(element) 29 | collectionView.reloadData() 30 | }.on(observedEvent) 31 | } 32 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources+Rx/RxTableViewSectionedReloadDataSource.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTableViewSectionedReloadDataSource.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 6/27/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | #if !RX_NO_MODULE 12 | import RxSwift 13 | import RxCocoa 14 | #endif 15 | 16 | public class RxTableViewSectionedReloadDataSource 17 | : RxTableViewSectionedDataSource 18 | , RxTableViewDataSourceType { 19 | public typealias Element = [S] 20 | 21 | public override init() { 22 | super.init() 23 | } 24 | 25 | public func tableView(tableView: UITableView, observedEvent: Event) { 26 | UIBindingObserver(UIElement: self) { dataSource, element in 27 | dataSource.setSections(element) 28 | tableView.reloadData() 29 | }.on(observedEvent) 30 | } 31 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/AnimatableSectionModelType+ItemPath.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimatableSectionModelType+ItemPath.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 1/9/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension Array where Element: AnimatableSectionModelType { 12 | subscript(index: ItemPath) -> Element.Item { 13 | return self[index.sectionIndex].items[index.itemIndex] 14 | } 15 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/AnimatableSectionModelType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimatableSectionModelType.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 1/6/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public protocol AnimatableSectionModelType 12 | : SectionModelType 13 | , IdentifiableType { 14 | associatedtype Item : IdentifiableType, Equatable 15 | 16 | init(original: Self, items: [Item]) 17 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/AnimationConfiguration.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnimationConfiguration.swift 3 | // RxDataSources 4 | // 5 | // Created by Esteban Torres on 5/2/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | /** 13 | Exposes custom animation styles for insertion, deletion and reloading behavior. 14 | */ 15 | public struct AnimationConfiguration { 16 | let insertAnimation: UITableViewRowAnimation 17 | let reloadAnimation: UITableViewRowAnimation 18 | let deleteAnimation: UITableViewRowAnimation 19 | 20 | public init(insertAnimation: UITableViewRowAnimation = .Automatic, 21 | reloadAnimation: UITableViewRowAnimation = .Automatic, 22 | deleteAnimation: UITableViewRowAnimation = .Automatic) { 23 | self.insertAnimation = insertAnimation 24 | self.reloadAnimation = reloadAnimation 25 | self.deleteAnimation = deleteAnimation 26 | } 27 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/DataSources.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DataSources.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 1/8/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum RxDataSourceError : ErrorType { 12 | case UnwrappingOptional 13 | case PreconditionFailed(message: String) 14 | } 15 | 16 | func rxPrecondition(condition: Bool, @autoclosure _ message: () -> String) throws -> () { 17 | if condition { 18 | return 19 | } 20 | rxDebugFatalError("Precondition failed") 21 | 22 | throw RxDataSourceError.PreconditionFailed(message: message()) 23 | } 24 | 25 | func rxDebugFatalError(error: ErrorType) { 26 | rxDebugFatalError("\(error)") 27 | } 28 | 29 | func rxDebugFatalError(message: String) { 30 | #if DEBUG 31 | fatalError(message) 32 | #else 33 | print(message) 34 | #endif 35 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/IdentifiableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IdentifiableType.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 1/6/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public protocol IdentifiableType { 12 | associatedtype Identity: Hashable 13 | 14 | var identity : Identity { get } 15 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/IdentifiableValue.swift: -------------------------------------------------------------------------------- 1 | // 2 | // IdentifiableValue.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 1/7/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct IdentifiableValue 12 | : IdentifiableType 13 | , Equatable 14 | , CustomStringConvertible 15 | , CustomDebugStringConvertible { 16 | public typealias Identity = Value 17 | 18 | public let value: Value 19 | 20 | public var identity : Identity { 21 | return value 22 | } 23 | 24 | public var description: String { 25 | return "\(value)" 26 | } 27 | 28 | public var debugDescription: String { 29 | return "\(value)" 30 | } 31 | } 32 | 33 | public func == (lhs: IdentifiableValue, rhs: IdentifiableValue) -> Bool { 34 | return lhs.value == rhs.value 35 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/ItemPath.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ItemPath.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 1/9/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct ItemPath { 12 | public let sectionIndex: Int 13 | public let itemIndex: Int 14 | } 15 | 16 | extension ItemPath : Equatable { 17 | 18 | } 19 | 20 | public func == (lhs: ItemPath, rhs: ItemPath) -> Bool { 21 | return lhs.sectionIndex == rhs.sectionIndex && lhs.itemIndex == rhs.itemIndex 22 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/Optional+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Optional+Extensions.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 1/8/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension Optional { 12 | func unwrap() throws -> Wrapped { 13 | if let unwrapped = self { 14 | return unwrapped 15 | } 16 | else { 17 | rxDebugFatalError("Error during unwrapping optional") 18 | throw RxDataSourceError.UnwrappingOptional 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/SectionModel.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SectionModel.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 6/16/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct SectionModel 12 | : SectionModelType 13 | , CustomStringConvertible { 14 | public typealias Identity = Section 15 | public typealias Item = ItemType 16 | public var model: Section 17 | 18 | public var identity: Section { 19 | return model 20 | } 21 | 22 | public var items: [Item] 23 | 24 | public init(model: Section, items: [Item]) { 25 | self.model = model 26 | self.items = items 27 | } 28 | 29 | public var description: String { 30 | return "\(self.model) > \(items)" 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /RxExample/RxDataSources/DataSources/SectionModelType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SectionModelType.swift 3 | // RxDataSources 4 | // 5 | // Created by Krunoslav Zaher on 6/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public protocol SectionModelType { 12 | associatedtype Item 13 | 14 | var items: [Item] { get } 15 | } -------------------------------------------------------------------------------- /RxExample/RxExample-iOSTests/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 | -------------------------------------------------------------------------------- /RxExample/RxExample-iOSTests/Mocks/MockGitHubAPI.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MockGitHubAPI.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | 12 | class MockGitHubAPI : GitHubAPI { 13 | let _usernameAvailable: String -> Observable 14 | let _signup: (String, String) -> Observable 15 | 16 | init( 17 | usernameAvailable: (String) -> Observable = notImplemented(), 18 | signup: (String, String) -> Observable = notImplemented() 19 | ) { 20 | _usernameAvailable = usernameAvailable 21 | _signup = signup 22 | } 23 | 24 | func usernameAvailable(username: String) -> Observable { 25 | return _usernameAvailable(username) 26 | } 27 | 28 | func signup(username: String, password: String) -> Observable { 29 | return _signup(username, password) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /RxExample/RxExample-iOSTests/Mocks/MockWireframe.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MockWireframe.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | 12 | class MockWireframe : Wireframe { 13 | let _openURL: (NSURL) -> () 14 | let _promptFor: (String, Any, [Any]) -> Observable 15 | 16 | init(openURL: (NSURL) -> () = notImplementedSync(), 17 | promptFor: (String, Any, [Any]) -> Observable = notImplemented()) { 18 | _openURL = openURL 19 | _promptFor = promptFor 20 | } 21 | 22 | func openURL(URL: NSURL) { 23 | _openURL(URL) 24 | } 25 | 26 | func promptFor(message: String, cancelAction: Action, actions: [Action]) -> Observable { 27 | return _promptFor(message, cancelAction, actions.map { $0 as Any }).map { $0 as! Action } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /RxExample/RxExample-iOSTests/Mocks/NotImplementedStubs.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NotImplementedStubs.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | import RxTests 12 | 13 | // MARK: Generic support code 14 | 15 | 16 | // MARK: Not implemented stubs 17 | 18 | func notImplemented() -> (T1) -> Observable { 19 | return { _ in 20 | fatalError() 21 | return Observable.empty() 22 | } 23 | } 24 | 25 | func notImplementedSync() -> (T1) -> Void { 26 | return { _ in 27 | fatalError() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /RxExample/RxExample-iOSTests/Mocks/ValidationResult+Equatable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ValidationResult+Equatable.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | // MARK: Equatable 12 | 13 | extension ValidationResult : Equatable { 14 | 15 | } 16 | 17 | func == (lhs: ValidationResult, rhs: ValidationResult) -> Bool { 18 | switch (lhs, rhs) { 19 | case (.OK, .OK): 20 | return true 21 | case (.Empty, .Empty): 22 | return true 23 | case (.Validating, .Validating): 24 | return true 25 | case (.Failed, .Failed): 26 | return true 27 | default: 28 | return false 29 | } 30 | } -------------------------------------------------------------------------------- /RxExample/RxExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/Calculator/CalculatorAction.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CalculatorAction.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum Action { 12 | case Clear 13 | case ChangeSign 14 | case Percent 15 | case Operation(Operator) 16 | case Equal 17 | case AddNumber(Character) 18 | case AddDot 19 | } -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/Calculator/Operation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Operation.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | enum Operator { 12 | case Addition 13 | case Subtraction 14 | case Multiplication 15 | case Division 16 | } -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/Numbers/NumbersViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumbersViewController.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | #if !RX_NO_MODULE 12 | import RxSwift 13 | import RxCocoa 14 | #endif 15 | 16 | class NumbersViewController: ViewController { 17 | @IBOutlet weak var number1: UITextField! 18 | @IBOutlet weak var number2: UITextField! 19 | @IBOutlet weak var number3: UITextField! 20 | 21 | @IBOutlet weak var result: UILabel! 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | 26 | Observable.combineLatest(number1.rx_text, number2.rx_text, number3.rx_text) { textValue1, textValue2, textValue3 -> Int in 27 | return (Int(textValue1) ?? 0) + (Int(textValue2) ?? 0) + (Int(textValue3) ?? 0) 28 | } 29 | .map { $0.description } 30 | .bindTo(result.rx_text) 31 | .addDisposableTo(disposeBag) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/TableViewPartialUpdates/NumberCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberCell.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 7/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class NumberCell : UICollectionViewCell { 13 | @IBOutlet var value: UILabel? 14 | } -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/TableViewPartialUpdates/NumberSectionView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NumberSectionView.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 7/2/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | 12 | class NumberSectionView : UICollectionReusableView { 13 | @IBOutlet weak var value: UILabel? 14 | } -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/TableViewWithEditingCommands/String+extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String+extensions.swift 3 | // RxExample 4 | // 5 | // Created by carlos on 28/5/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | extension String { 10 | 11 | } 12 | -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/TableViewWithEditingCommands/UIImageView+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageView+Extensions.swift 3 | // RxExample 4 | // 5 | // Created by carlos on 28/5/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | extension UIImageView { 12 | 13 | func makeRoundedCorners(radius: CGFloat) { 14 | self.layer.cornerRadius = self.frame.size.width / 2 15 | self.layer.borderColor = UIColor.darkGrayColor().CGColor 16 | self.layer.borderWidth = radius 17 | self.layer.masksToBounds = true 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/TableViewWithEditingCommands/User.swift: -------------------------------------------------------------------------------- 1 | // 2 | // User.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/29/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct User: Equatable, CustomDebugStringConvertible { 12 | 13 | var firstName: String 14 | var lastName: String 15 | var imageURL: String 16 | 17 | init(firstName: String, lastName: String, imageURL: String) { 18 | self.firstName = firstName 19 | self.lastName = lastName 20 | self.imageURL = imageURL 21 | } 22 | } 23 | 24 | extension User { 25 | var debugDescription: String { 26 | return firstName + " " + lastName 27 | } 28 | } 29 | 30 | func ==(lhs: User, rhs:User) -> Bool { 31 | return lhs.firstName == rhs.firstName && 32 | lhs.lastName == rhs.lastName && 33 | lhs.imageURL == rhs.imageURL 34 | } -------------------------------------------------------------------------------- /RxExample/RxExample/Examples/WikipediaImageSearch/WikipediaAPI/WikipediaPage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // WikipediaPage.swift 3 | // Example 4 | // 5 | // Created by Krunoslav Zaher on 3/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | 14 | struct WikipediaPage { 15 | let title: String 16 | let text: String 17 | 18 | init(title: String, text: String) { 19 | self.title = title 20 | self.text = text 21 | } 22 | 23 | // tedious parsing part 24 | static func parseJSON(json: NSDictionary) throws -> WikipediaPage { 25 | guard let title = json.valueForKey("parse")?.valueForKey("title") as? String, 26 | let text = json.valueForKey("parse")?.valueForKey("text")?.valueForKey("*") as? String else { 27 | throw apiError("Error parsing page content") 28 | } 29 | 30 | return WikipediaPage(title: title, text: text) 31 | } 32 | } -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-40@2x-1.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-60@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-60@2x-1.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-76@2x.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-Small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-Small.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-Small@2x-1.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Icon-Small@3x.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Rx_Logo_M.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/AppIcon.appiconset/Rx_Logo_M.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/ReactiveExtensionsLogo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "ReactiveExtensionsLogo.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x", 15 | "filename" : "ReactiveExtensionsLogo-2.png" 16 | } 17 | ], 18 | "info" : { 19 | "version" : 1, 20 | "author" : "xcode" 21 | } 22 | } -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/ReactiveExtensionsLogo.imageset/ReactiveExtensionsLogo-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/ReactiveExtensionsLogo.imageset/ReactiveExtensionsLogo-2.png -------------------------------------------------------------------------------- /RxExample/RxExample/Images.xcassets/ReactiveExtensionsLogo.imageset/ReactiveExtensionsLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/RxExample/RxExample/Images.xcassets/ReactiveExtensionsLogo.imageset/ReactiveExtensionsLogo.png -------------------------------------------------------------------------------- /RxExample/RxExample/Info-OSX.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 | NSMainStoryboardFile 24 | Main 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /RxExample/RxExample/OSX/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 5/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | func applicationDidFinishLaunching(aNotification: NSNotification) { 15 | // Insert code here to initialize your application 16 | } 17 | 18 | func applicationWillTerminate(aNotification: NSNotification) { 19 | // Insert code here to tear down your application 20 | } 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /RxExample/RxExample/Operators.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Operators.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | import RxCocoa 13 | #endif 14 | 15 | // Two way binding operator between control property and variable, that's all it takes { 16 | 17 | infix operator <-> { 18 | } 19 | 20 | func <-> (property: ControlProperty, variable: Variable) -> Disposable { 21 | let bindToUIDisposable = variable.asObservable() 22 | .bindTo(property) 23 | let bindToVariable = property 24 | .subscribe(onNext: { n in 25 | variable.value = n 26 | }, onCompleted: { 27 | bindToUIDisposable.dispose() 28 | }) 29 | 30 | return StableCompositeDisposable.create(bindToUIDisposable, bindToVariable) 31 | } 32 | 33 | // } 34 | 35 | -------------------------------------------------------------------------------- /RxExample/RxExample/RxExample.xcdatamodeld/.xccurrentversion: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /RxExample/RxExample/RxExample.xcdatamodeld/RxExample.xcdatamodel/contents: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /RxExample/RxExample/Services/DownloadableImage.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DownloadableImage.swift 3 | // RxExample 4 | // 5 | // Created by Vodovozov Gleb on 10/31/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if !RX_NO_MODULE 11 | import RxSwift 12 | #endif 13 | #if os(iOS) 14 | import UIKit 15 | #elseif os(OSX) 16 | import Cocoa 17 | #endif 18 | 19 | enum DownloadableImage{ 20 | case Content(image:Image) 21 | case OfflinePlaceholder 22 | 23 | } 24 | -------------------------------------------------------------------------------- /RxExample/RxExample/Services/PseudoRandomGenerator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PseudoRandomGenerator.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 6/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | 12 | // https://en.wikipedia.org/wiki/Random_number_generation 13 | class PseudoRandomGenerator { 14 | var m_w: UInt32 /* must not be zero, nor 0x464fffff */ 15 | var m_z: UInt32 /* must not be zero, nor 0x9068ffff */ 16 | 17 | init(_ m_w: UInt32, _ m_z: UInt32) { 18 | self.m_w = m_w 19 | self.m_z = m_z 20 | } 21 | 22 | func get_random() -> Int { 23 | m_z = 36969 &* (m_z & 65535) &+ (m_z >> 16); 24 | m_w = 18000 &* (m_w & 65535) &+ (m_w >> 16); 25 | let val = ((m_z << 16) &+ m_w) 26 | return Int(val % (1 << 30)) /* 32-bit result */ 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /RxExample/RxExample/Services/UIImage+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+Extensions.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 11/1/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if os(iOS) 11 | import UIKit 12 | #endif 13 | 14 | extension Image { 15 | func forceLazyImageDecompression() -> Image { 16 | #if os(iOS) 17 | UIGraphicsBeginImageContext(CGSizeMake(1, 1)) 18 | self.drawAtPoint(CGPointZero) 19 | UIGraphicsEndImageContext() 20 | #endif 21 | return self 22 | } 23 | } -------------------------------------------------------------------------------- /RxExample/RxExample/String+URL.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String+URL.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 12/28/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension String { 12 | var URLEscaped: String { 13 | return self.stringByAddingPercentEncodingWithAllowedCharacters(.URLHostAllowedCharacterSet()) ?? "" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /RxExample/RxExample/iOS/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Example 4 | // 5 | // Created by Krunoslav Zaher on 2/21/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 17 | // Override point for customization after application launch. 18 | return true 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /RxExample/RxExample/iOS/RootViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RootViewController.swift 3 | // RxExample 4 | // 5 | // Created by Krunoslav Zaher on 4/6/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import UIKit 11 | #if !RX_NO_MODULE 12 | import RxSwift 13 | import RxCocoa 14 | #endif 15 | 16 | public class RootViewController : UITableViewController { 17 | public override func viewDidLoad() { 18 | super.viewDidLoad() 19 | // force load 20 | GitHubSearchRepositoriesAPI.sharedAPI.activityIndicator 21 | DefaultWikipediaAPI.sharedAPI 22 | DefaultImageService.sharedImageService 23 | DefaultWireframe.sharedInstance 24 | MainScheduler.instance 25 | ReachabilityService.sharedReachabilityService 26 | let geoService = GeolocationService.instance 27 | geoService.autorized.driveNext { _ in 28 | 29 | }.dispose() 30 | geoService.location.driveNext { _ in 31 | 32 | }.dispose() 33 | } 34 | } -------------------------------------------------------------------------------- /RxSwift/Cancelable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Cancelable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/12/15. 6 | // Copyright © 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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /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 | associatedtype DisposeKey 13 | 14 | func synchronizedUnsubscribe(disposeKey: DisposeKey) 15 | } -------------------------------------------------------------------------------- /RxSwift/ConnectableObservableType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConnectableObservableType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright © 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 | } -------------------------------------------------------------------------------- /RxSwift/DataStructures/InfiniteSequence.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InfiniteSequence.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/13/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Sequence that repeats `repeatedValue` infinite number of times. 13 | */ 14 | struct 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 | } -------------------------------------------------------------------------------- /RxSwift/Disposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Disposable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 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 | } -------------------------------------------------------------------------------- /RxSwift/Disposables/DisposeBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DisposeBase.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 4/4/15. 6 | // Copyright © 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 | AtomicIncrement(&resourceCount) 18 | #endif 19 | } 20 | 21 | deinit { 22 | #if TRACE_RESOURCES 23 | AtomicDecrement(&resourceCount) 24 | #endif 25 | } 26 | } -------------------------------------------------------------------------------- /RxSwift/Disposables/NAryDisposable.swift: -------------------------------------------------------------------------------- 1 | // This file is autogenerated. Take a look at `Preprocessor` target in RxSwift project 2 | // 3 | // NAryDisposable.swift 4 | // RxSwift 5 | // 6 | // Created by Krunoslav Zaher on 8/20/15. 7 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 8 | // 9 | 10 | import Foundation 11 | -------------------------------------------------------------------------------- /RxSwift/Disposables/NAryDisposable.tt: -------------------------------------------------------------------------------- 1 | // 2 | // NAryDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 8/20/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | -------------------------------------------------------------------------------- /RxSwift/Disposables/NopDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NopDisposable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 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 | } -------------------------------------------------------------------------------- /RxSwift/Disposables/StableCompositeDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StableCompositeDisposable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 6/12/15. 6 | // Copyright © 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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /RxSwift/Extensions/String+Rx.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String+Rx.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | extension String { 12 | /** 13 | This is needed because on Linux Swift doesn't have `rangeOfString(..., options: .BackwardsSearch)` 14 | */ 15 | func lastIndexOf(character: Character) -> Index? { 16 | var last: Index? 17 | for i in startIndex ..< endIndex { 18 | if self[i] == character { 19 | last = i 20 | } 21 | } 22 | 23 | return last 24 | } 25 | } -------------------------------------------------------------------------------- /RxSwift/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /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 | associatedtype E 19 | 20 | /** 21 | Converts `self` to `Observable` sequence. 22 | 23 | - returns: Observable sequence that represents `self`. 24 | */ 25 | func asObservable() -> Observable 26 | } 27 | -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /RxSwift/Observables/Implementations/Error.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Error.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 Error : 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 | } -------------------------------------------------------------------------------- /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 | } -------------------------------------------------------------------------------- /RxSwift/Observables/Implementations/Producer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Producer.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/20/15. 6 | // Copyright © 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 | } -------------------------------------------------------------------------------- /RxSwift/Observables/Implementations/StartWith.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StartWith.swift 3 | // RxCocoa 4 | // 5 | // Created by Krunoslav Zaher on 4/6/15. 6 | // Copyright © 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 | -------------------------------------------------------------------------------- /RxSwift/Observables/Observable+Debug.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable+Debug.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/2/15. 6 | // Copyright © 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 | - seealso: [do operator on reactivex.io](http://reactivex.io/documentation/operators/do.html) 19 | 20 | - parameter identifier: Identifier that is printed together with event description to standard output. 21 | - returns: An observable sequence whose events are printed to standard output. 22 | */ 23 | @warn_unused_result(message="http://git.io/rxs.uo") 24 | public func debug(identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) 25 | -> Observable { 26 | return Debug(source: self.asObservable(), identifier: identifier, file: file, line: line, function: function) 27 | } 28 | } -------------------------------------------------------------------------------- /RxSwift/Observers/AnonymousObserver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AnonymousObserver.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/8/15. 6 | // Copyright © 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 | AtomicIncrement(&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 | AtomicDecrement(&resourceCount) 32 | } 33 | #endif 34 | } 35 | -------------------------------------------------------------------------------- /RxSwift/Observers/ObserverBase.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ObserverBase.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 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: AtomicInt = 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 !AtomicCompareAndSwap(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 | } 40 | -------------------------------------------------------------------------------- /RxSwift/RxMutableBox.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxMutableBox.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 5/22/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Creates mutable reference wrapper for any type. 13 | */ 14 | class RxMutableBox : CustomDebugStringConvertible { 15 | /** 16 | Wrapped value 17 | */ 18 | var value : T 19 | 20 | /** 21 | Creates reference wrapper for `value`. 22 | 23 | - parameter value: Value to wrap. 24 | */ 25 | init (_ value: T) { 26 | self.value = value 27 | } 28 | } 29 | 30 | extension RxMutableBox { 31 | /** 32 | - returns: Box description. 33 | */ 34 | var debugDescription: String { 35 | return "MutatingBox(\(self.value))" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /RxSwift/Schedulers/HistoricalScheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // HistoricalScheduler.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/27/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Provides a virtual time scheduler that uses `NSDate` for absolute time and `NSTimeInterval` for relative time. 13 | */ 14 | public class HistoricalScheduler : VirtualTimeScheduler { 15 | 16 | /** 17 | Creates a new historical scheduler with initial clock value. 18 | 19 | - parameter initialClock: Initial value for virtual clock. 20 | */ 21 | public init(initialClock: RxTime = NSDate(timeIntervalSince1970: 0)) { 22 | super.init(initialClock: initialClock, converter: HistoricalSchedulerTimeConverter()) 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /RxSwift/Schedulers/Internal/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 | } -------------------------------------------------------------------------------- /RxSwift/Schedulers/Internal/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 | } -------------------------------------------------------------------------------- /RxSwift/Schedulers/Internal/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 | associatedtype Value 17 | 18 | func invoke(value: Value) 19 | } -------------------------------------------------------------------------------- /RxSwift/Schedulers/Internal/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 | return _disposable.disposed 23 | } 24 | 25 | init(action: Action, state: T) { 26 | _action = action 27 | _state = state 28 | } 29 | 30 | func invoke() { 31 | _disposable.disposable = _action(_state) 32 | } 33 | 34 | func dispose() { 35 | _disposable.dispose() 36 | } 37 | } -------------------------------------------------------------------------------- /RxSwift/Schedulers/Internal/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 | -------------------------------------------------------------------------------- /RxSwift/Subjects/SubjectType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SubjectType.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/1/15. 6 | // Copyright © 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 | associatedtype SubjectObserverType : ObserverType 21 | 22 | /** 23 | Returns observer interface for subject. 24 | 25 | - returns: Observer interface for subject. 26 | */ 27 | func asObserver() -> SubjectObserverType 28 | } -------------------------------------------------------------------------------- /RxTests/Any+Equatable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Any+Equatable.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | A way to use built in XCTest methods with objects that are partially equatable. 13 | 14 | If this can be done simpler, PRs are welcome :) 15 | */ 16 | struct AnyEquatable 17 | : Equatable 18 | , CustomDebugStringConvertible 19 | , CustomStringConvertible { 20 | typealias Comparer = (Target, Target) -> Bool 21 | 22 | let _target: Target 23 | let _comparer: Comparer 24 | 25 | init(target: Target, comparer: Comparer) { 26 | _target = target 27 | _comparer = comparer 28 | } 29 | } 30 | 31 | func == (lhs: AnyEquatable, rhs: AnyEquatable) -> Bool { 32 | return lhs._comparer(lhs._target, rhs._target) 33 | } 34 | 35 | extension AnyEquatable { 36 | var description: String { 37 | return "\(_target)" 38 | } 39 | 40 | var debugDescription: String { 41 | return "\(_target)" 42 | } 43 | } -------------------------------------------------------------------------------- /RxTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 2.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /RxTests/RxTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // RxTests.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 12/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /** 12 | Virtual time type. 13 | */ 14 | public typealias TestTime = Int 15 | 16 | -------------------------------------------------------------------------------- /RxTests/TestableObserver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestableObserver.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 2/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | 12 | /** 13 | Observer that records events together with virtual time when they were received. 14 | */ 15 | public class TestableObserver 16 | : ObserverType { 17 | public typealias Element = ElementType 18 | 19 | private let _scheduler: TestScheduler 20 | 21 | /** 22 | Recorded events. 23 | */ 24 | public private(set) var events = [Recorded>]() 25 | 26 | init(scheduler: TestScheduler) { 27 | _scheduler = scheduler 28 | } 29 | 30 | /** 31 | Notify observer about sequence event. 32 | 33 | - parameter event: Event that occured. 34 | */ 35 | public func on(event: Event) { 36 | events.append(Recorded(time: _scheduler.clock, event: event)) 37 | } 38 | } -------------------------------------------------------------------------------- /Sources/AllTests/AnonymousObservable+Test.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/AnonymousObservable+Test.swift -------------------------------------------------------------------------------- /Sources/AllTests/AssumptionsTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/AssumptionsTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/BackgroundThreadPrimitiveHotObservable.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Mocks/BackgroundThreadPrimitiveHotObservable.swift -------------------------------------------------------------------------------- /Sources/AllTests/BagTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/BagTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/BehaviorSubjectTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/BehaviorSubjectTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/CurrentThreadSchedulerTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/CurrentThreadSchedulerTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/DisposableTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/DisposableTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/ElementIndexPair.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/ElementIndexPair.swift -------------------------------------------------------------------------------- /Sources/AllTests/EquatableArray.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/EquatableArray.swift -------------------------------------------------------------------------------- /Sources/AllTests/Foundation+Extensions.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/Tests/Foundation+Extensions.swift -------------------------------------------------------------------------------- /Sources/AllTests/MainSchedulerTests.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/MainSchedulerTests.swift -------------------------------------------------------------------------------- /Sources/AllTests/MainThreadPrimitiveHotObservable.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Mocks/MainThreadPrimitiveHotObservable.swift -------------------------------------------------------------------------------- /Sources/AllTests/MockDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Mocks/MockDisposable.swift -------------------------------------------------------------------------------- /Sources/AllTests/MySubject.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Mocks/MySubject.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+AggregateTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+AggregateTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+BindingTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+BindingTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+BlockingTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+BlockingTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+ConcurrencyTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+ConcurrencyTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+CreationTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+CreationTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+Extensions.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Observable+Extensions.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+MultipleTest+CombineLatest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+MultipleTest+CombineLatest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+MultipleTest+Zip.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+MultipleTest+Zip.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+MultipleTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+MultipleTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+SingleTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+SingleTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+StandardSequenceOperatorsTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+StandardSequenceOperatorsTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+SubscriptionTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+SubscriptionTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable+TimeTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/Observable+TimeTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/Observable.Extensions.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Mocks/Observable.Extensions.swift -------------------------------------------------------------------------------- /Sources/AllTests/ObserverTests.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/ObserverTests.swift -------------------------------------------------------------------------------- /Sources/AllTests/PrimitiveHotObservable.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Mocks/PrimitiveHotObservable.swift -------------------------------------------------------------------------------- /Sources/AllTests/PrimitiveMockObserver.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Mocks/PrimitiveMockObserver.swift -------------------------------------------------------------------------------- /Sources/AllTests/QueueTests.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/QueueTests.swift -------------------------------------------------------------------------------- /Sources/AllTests/Recorded+Timeless.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/Tests/Recorded+Timeless.swift -------------------------------------------------------------------------------- /Sources/AllTests/RxMutableBox.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/RxMutableBox.swift -------------------------------------------------------------------------------- /Sources/AllTests/RxTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/SubjectConcurrencyTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/SubjectConcurrencyTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/TestConnectableObservable.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/Mocks/TestConnectableObservable.swift -------------------------------------------------------------------------------- /Sources/AllTests/TestErrors.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/Tests/TestErrors.swift -------------------------------------------------------------------------------- /Sources/AllTests/TestVirtualScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/TestImplementations/TestVirtualScheduler.swift -------------------------------------------------------------------------------- /Sources/AllTests/VariableTest.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/RxSwiftTests/Tests/VariableTest.swift -------------------------------------------------------------------------------- /Sources/AllTests/XCTest+AllTests.swift: -------------------------------------------------------------------------------- 1 | ../../Tests/Tests/XCTest+AllTests.swift -------------------------------------------------------------------------------- /Sources/RxBlocking/BlockingObservable+Operators.swift: -------------------------------------------------------------------------------- 1 | ../../RxBlocking/BlockingObservable+Operators.swift -------------------------------------------------------------------------------- /Sources/RxBlocking/BlockingObservable.swift: -------------------------------------------------------------------------------- 1 | ../../RxBlocking/BlockingObservable.swift -------------------------------------------------------------------------------- /Sources/RxBlocking/ObservableConvertibleType+Blocking.swift: -------------------------------------------------------------------------------- 1 | ../../RxBlocking/ObservableConvertibleType+Blocking.swift -------------------------------------------------------------------------------- /Sources/RxBlocking/RunLoopLock.swift: -------------------------------------------------------------------------------- 1 | ../../RxBlocking/RunLoopLock.swift -------------------------------------------------------------------------------- /Sources/RxCocoa/RxCocoa.h: -------------------------------------------------------------------------------- 1 | ../../RxCocoa/RxCocoa.h -------------------------------------------------------------------------------- /Sources/RxSwift/AddRef.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/AddRef.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Amb.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Amb.swift -------------------------------------------------------------------------------- /Sources/RxSwift/AnonymousDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/AnonymousDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/AnonymousInvocable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/Internal/AnonymousInvocable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/AnonymousObservable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/AnonymousObservable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/AnonymousObserver.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observers/AnonymousObserver.swift -------------------------------------------------------------------------------- /Sources/RxSwift/AnyObserver.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/AnyObserver.swift -------------------------------------------------------------------------------- /Sources/RxSwift/AsyncLock.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Concurrency/AsyncLock.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Bag.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/DataStructures/Bag.swift -------------------------------------------------------------------------------- /Sources/RxSwift/BehaviorSubject.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Subjects/BehaviorSubject.swift -------------------------------------------------------------------------------- /Sources/RxSwift/BinaryDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/BinaryDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/BooleanDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/BooleanDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Buffer.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Buffer.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Cancelable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Cancelable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Catch.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Catch.swift -------------------------------------------------------------------------------- /Sources/RxSwift/CombineLatest+CollectionType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/CombineLatest+CollectionType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/CombineLatest+arity.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/CombineLatest+arity.swift -------------------------------------------------------------------------------- /Sources/RxSwift/CombineLatest.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/CombineLatest.swift -------------------------------------------------------------------------------- /Sources/RxSwift/CompositeDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/CompositeDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Concat.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Concat.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ConcurrentDispatchQueueScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/ConcurrentDispatchQueueScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ConcurrentMainScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/ConcurrentMainScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ConnectableObservable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/ConnectableObservable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ConnectableObservableType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/ConnectableObservableType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/CurrentThreadScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/CurrentThreadScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Debug.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Debug.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Deferred.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Deferred.swift -------------------------------------------------------------------------------- /Sources/RxSwift/DelaySubscription.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/DelaySubscription.swift -------------------------------------------------------------------------------- /Sources/RxSwift/DispatchQueueSchedulerQOS.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/DispatchQueueSchedulerQOS.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Disposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/DisposeBag.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/DisposeBag.swift -------------------------------------------------------------------------------- /Sources/RxSwift/DisposeBase.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/DisposeBase.swift -------------------------------------------------------------------------------- /Sources/RxSwift/DistinctUntilChanged.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/DistinctUntilChanged.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Do.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Do.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ElementAt.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/ElementAt.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Empty.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Empty.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Error.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Error.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Errors.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Errors.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Event.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Event.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Filter.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Filter.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Generate.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Generate.swift -------------------------------------------------------------------------------- /Sources/RxSwift/HistoricalScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/HistoricalScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/HistoricalSchedulerTimeConverter.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/HistoricalSchedulerTimeConverter.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ImmediateScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/ImmediateScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ImmediateSchedulerType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/ImmediateSchedulerType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/InfiniteSequence.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/DataStructures/InfiniteSequence.swift -------------------------------------------------------------------------------- /Sources/RxSwift/InvocableScheduledItem.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/Internal/InvocableScheduledItem.swift -------------------------------------------------------------------------------- /Sources/RxSwift/InvocableType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/Internal/InvocableType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Just.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Just.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Lock.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Concurrency/Lock.swift -------------------------------------------------------------------------------- /Sources/RxSwift/LockOwnerType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Concurrency/LockOwnerType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/MainScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/MainScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Map.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Map.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Merge.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Merge.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Multicast.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Multicast.swift -------------------------------------------------------------------------------- /Sources/RxSwift/NAryDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/NAryDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Never.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Never.swift -------------------------------------------------------------------------------- /Sources/RxSwift/NopDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/NopDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Aggregate.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+Aggregate.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Binding.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+Binding.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Concurrency.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+Concurrency.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Creation.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+Creation.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Debug.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+Debug.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Extensions.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observable+Extensions.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Multiple.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+Multiple.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Single.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+Single.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+StandardSequenceOperators.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+StandardSequenceOperators.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable+Time.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Observable+Time.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Observable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ObservableConvertibleType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/ObservableConvertibleType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ObservableType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/ObservableType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ObserveOn.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/ObserveOn.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ObserveOnSerialDispatchQueue.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/ObserveOnSerialDispatchQueue.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ObserverBase.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observers/ObserverBase.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ObserverType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/ObserverType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/OperationQueueScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/OperationQueueScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Platform.Darwin.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Platform/Platform.Darwin.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Platform.Linux.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Platform/Platform.Linux.swift -------------------------------------------------------------------------------- /Sources/RxSwift/PriorityQueue.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/DataStructures/PriorityQueue.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Producer.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Producer.swift -------------------------------------------------------------------------------- /Sources/RxSwift/PublishSubject.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Subjects/PublishSubject.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Queue.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/DataStructures/Queue.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Range.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Range.swift -------------------------------------------------------------------------------- /Sources/RxSwift/RecursiveScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/RecursiveScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Reduce.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Reduce.swift -------------------------------------------------------------------------------- /Sources/RxSwift/RefCount.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/RefCount.swift -------------------------------------------------------------------------------- /Sources/RxSwift/RefCountDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/RefCountDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Repeat.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Repeat.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ReplaySubject.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Subjects/ReplaySubject.swift -------------------------------------------------------------------------------- /Sources/RxSwift/RetryWhen.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/RetryWhen.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Rx.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Rx.swift -------------------------------------------------------------------------------- /Sources/RxSwift/RxMutableBox.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/RxMutableBox.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Sample.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Sample.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Scan.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Scan.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ScheduledDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/ScheduledDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ScheduledItem.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/Internal/ScheduledItem.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ScheduledItemType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/Internal/ScheduledItemType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SchedulerServices+Emulation.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/SchedulerServices+Emulation.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SchedulerType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/SchedulerType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Sequence.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Sequence.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SerialDispatchQueueScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/SerialDispatchQueueScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SerialDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/SerialDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ShareReplay1.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/ShareReplay1.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ShareReplay1WhileConnected.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/ShareReplay1WhileConnected.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SingleAssignmentDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/SingleAssignmentDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SingleAsync.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/SingleAsync.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Sink.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Sink.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Skip.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Skip.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SkipUntil.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/SkipUntil.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SkipWhile.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/SkipWhile.swift -------------------------------------------------------------------------------- /Sources/RxSwift/StableCompositeDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/StableCompositeDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/StartWith.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/StartWith.swift -------------------------------------------------------------------------------- /Sources/RxSwift/String+Rx.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Extensions/String+Rx.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SubjectType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Subjects/SubjectType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SubscribeOn.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/SubscribeOn.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SubscriptionDisposable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Disposables/SubscriptionDisposable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Switch.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Switch.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SynchronizedDisposeType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Concurrency/SynchronizedDisposeType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SynchronizedOnType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Concurrency/SynchronizedOnType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SynchronizedSubscribeType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Concurrency/SynchronizedSubscribeType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/SynchronizedUnsubscribeType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Concurrency/SynchronizedUnsubscribeType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/TailRecursiveSink.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observers/TailRecursiveSink.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Take.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Take.swift -------------------------------------------------------------------------------- /Sources/RxSwift/TakeLast.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/TakeLast.swift -------------------------------------------------------------------------------- /Sources/RxSwift/TakeUntil.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/TakeUntil.swift -------------------------------------------------------------------------------- /Sources/RxSwift/TakeWhile.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/TakeWhile.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Throttle.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Throttle.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Timeout.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Timeout.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Timer.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Timer.swift -------------------------------------------------------------------------------- /Sources/RxSwift/ToArray.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/ToArray.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Using.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Using.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Variable.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Subjects/Variable.swift -------------------------------------------------------------------------------- /Sources/RxSwift/VirtualTimeConverterType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/VirtualTimeConverterType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/VirtualTimeScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Schedulers/VirtualTimeScheduler.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Window.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Window.swift -------------------------------------------------------------------------------- /Sources/RxSwift/WithLatestFrom.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/WithLatestFrom.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Zip+CollectionType.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Zip+CollectionType.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Zip+arity.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Zip+arity.swift -------------------------------------------------------------------------------- /Sources/RxSwift/Zip.swift: -------------------------------------------------------------------------------- 1 | ../../RxSwift/Observables/Implementations/Zip.swift -------------------------------------------------------------------------------- /Sources/RxTests/Any+Equatable.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/Any+Equatable.swift -------------------------------------------------------------------------------- /Sources/RxTests/ColdObservable.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/ColdObservable.swift -------------------------------------------------------------------------------- /Sources/RxTests/Event+Equatable.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/Event+Equatable.swift -------------------------------------------------------------------------------- /Sources/RxTests/HotObservable.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/HotObservable.swift -------------------------------------------------------------------------------- /Sources/RxTests/Recorded.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/Recorded.swift -------------------------------------------------------------------------------- /Sources/RxTests/RxTests.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/RxTests.swift -------------------------------------------------------------------------------- /Sources/RxTests/Subscription.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/Subscription.swift -------------------------------------------------------------------------------- /Sources/RxTests/TestScheduler.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/Schedulers/TestScheduler.swift -------------------------------------------------------------------------------- /Sources/RxTests/TestSchedulerVirtualTimeConverter.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/Schedulers/TestSchedulerVirtualTimeConverter.swift -------------------------------------------------------------------------------- /Sources/RxTests/TestableObservable.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/TestableObservable.swift -------------------------------------------------------------------------------- /Sources/RxTests/TestableObserver.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/TestableObserver.swift -------------------------------------------------------------------------------- /Sources/RxTests/XCTest+Rx.swift: -------------------------------------------------------------------------------- 1 | ../../RxTests/XCTest+Rx.swift -------------------------------------------------------------------------------- /Tests/RxCocoaTests/Control+RxTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Control+RxTests.swift 3 | // RxTests 4 | // 5 | // Created by Krunoslav Zaher on 10/18/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxCocoa 11 | import RxSwift 12 | import XCTest 13 | 14 | class ControlTests : RxTest { 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Tests/RxCocoaTests/Driver+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Driver+Extensions.swift 3 | // Tests 4 | // 5 | // Created by Krunoslav Zaher on 12/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxCocoa 11 | 12 | extension Driver : Equatable { 13 | 14 | } 15 | 16 | public func == (lhs: Driver, rhs: Driver) -> Bool { 17 | return lhs.asObservable() === rhs.asObservable() 18 | } -------------------------------------------------------------------------------- /Tests/RxCocoaTests/NSControl+RxTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSControl+RxTests.swift 3 | // Tests 4 | // 5 | // Created by mrahmiao on 1/1/16. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | import RxCocoa 12 | import Cocoa 13 | import XCTest 14 | 15 | class NSControlTests : RxTest { 16 | } 17 | 18 | extension NSControlTests { 19 | func testEnabled_False() { 20 | let subject = NSButton(frame: CGRectMake(0, 0, 1, 1)) 21 | Observable.just(false).subscribe(subject.rx_enabled).dispose() 22 | 23 | XCTAssertTrue(subject.enabled == false) 24 | } 25 | 26 | func testEnabled_True() { 27 | let subject = NSButton(frame: CGRectMake(0, 0, 1, 1)) 28 | Observable.just(true).subscribe(subject.rx_enabled).dispose() 29 | 30 | XCTAssertTrue(subject.enabled == true) 31 | } 32 | } -------------------------------------------------------------------------------- /Tests/RxCocoaTests/RxTests-OSX-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "RXObjCRuntime+Testing.h" -------------------------------------------------------------------------------- /Tests/RxCocoaTests/RxTests-iOS-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "RXObjCRuntime+Testing.h" -------------------------------------------------------------------------------- /Tests/RxCocoaTests/RxTests-tvOS-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "RXObjCRuntime+Testing.h" -------------------------------------------------------------------------------- /Tests/RxCocoaTests/UIRefreshControl+RxTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIRefreshControl+RxTests.swift 3 | // RxTests 4 | // 5 | // Created by Yosuke Ishikawa on 1/31/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | #if os(iOS) 10 | import Foundation 11 | 12 | import RxSwift 13 | import RxCocoa 14 | import UIKit 15 | import XCTest 16 | 17 | class UIRefreshControlTests : RxTest { 18 | } 19 | 20 | extension UIRefreshControlTests { 21 | func testRefreshing_True() { 22 | let subject = UIRefreshControl() 23 | Observable.just(true).subscribe(subject.rx_refreshing).dispose() 24 | 25 | XCTAssertTrue(subject.refreshing == true) 26 | } 27 | 28 | func testRefreshing_False() { 29 | let subject = UIRefreshControl() 30 | Observable.just(false).subscribe(subject.rx_refreshing).dispose() 31 | 32 | XCTAssertTrue(subject.refreshing == false) 33 | } 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Tests/RxCocoaTests/UITabBarItem+RxTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UITabBarItem+RxTests.swift 3 | // Rx 4 | // 5 | // Created by Mateusz Derks on 04/03/16. 6 | // Copyright © 2016 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | import RxSwift 12 | import RxCocoa 13 | import UIKit 14 | import XCTest 15 | 16 | class UITabBarItemTests : RxTest { 17 | } 18 | 19 | extension UITabBarItemTests { 20 | func testBadgetValue_Text() { 21 | let subject = UITabBarItem(tabBarSystemItem: .More, tag: 0) 22 | Observable.just("5").subscribe(subject.rx_badgeValue).dispose() 23 | 24 | XCTAssertTrue(subject.badgeValue == "5") 25 | } 26 | 27 | func testBadgetValue_Empty() { 28 | let subject = UITabBarItem(tabBarSystemItem: .More, tag: 0) 29 | Observable.just(nil).subscribe(subject.rx_badgeValue).dispose() 30 | 31 | XCTAssertTrue(subject.badgeValue == nil) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/ElementIndexPair.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ElementIndexPair.swift 3 | // RxTests 4 | // 5 | // Created by Krunoslav Zaher on 6/12/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct ElementIndexPair : Equatable { 12 | let element: E 13 | let index: I 14 | 15 | init(_ element: E, _ index: I) { 16 | self.element = element 17 | self.index = index 18 | } 19 | } 20 | 21 | func == (lhs: ElementIndexPair, rhs: ElementIndexPair) -> Bool { 22 | return lhs.element == rhs.element && lhs.index == rhs.index 23 | } -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/EquatableArray.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EquatableArray.swift 3 | // RxTests 4 | // 5 | // Created by Krunoslav Zaher on 10/15/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | struct EquatableArray : Equatable { 12 | let elements: [Element] 13 | init(_ elements: [Element]) { 14 | self.elements = elements 15 | } 16 | } 17 | 18 | func == (lhs: EquatableArray, rhs: EquatableArray) -> Bool { 19 | return lhs.elements == rhs.elements 20 | } 21 | -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/Mocks/BackgroundThreadPrimitiveHotObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BackgroundThreadPrimitiveHotObservable.swift 3 | // RxTests 4 | // 5 | // Created by Krunoslav Zaher on 10/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | import XCTest 12 | 13 | class BackgroundThreadPrimitiveHotObservable : PrimitiveHotObservable { 14 | override func subscribe(observer: O) -> Disposable { 15 | XCTAssertTrue(!isMainThread()) 16 | return super.subscribe(observer) 17 | } 18 | } -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/Mocks/MainThreadPrimitiveHotObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MainThreadPrimitiveHotObservable.swift 3 | // RxTests 4 | // 5 | // Created by Krunoslav Zaher on 10/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | import XCTest 12 | 13 | class MainThreadPrimitiveHotObservable : PrimitiveHotObservable { 14 | override func subscribe(observer: O) -> Disposable { 15 | XCTAssertTrue(isMainThread()) 16 | return super.subscribe(observer) 17 | } 18 | } -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/Mocks/MockDisposable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MockDisposable.swift 3 | // RxTests 4 | // 5 | // Created by Yury Korolev on 10/17/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | import RxTests 12 | 13 | class MockDisposable : Disposable 14 | { 15 | var ticks = [Int]() 16 | private let _scheduler: TestScheduler 17 | 18 | init(scheduler: TestScheduler) { 19 | _scheduler = scheduler 20 | ticks.append(_scheduler.clock) 21 | } 22 | 23 | func dispose() { 24 | ticks.append(_scheduler.clock) 25 | } 26 | } -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/Mocks/Observable.Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable.Extensions.swift 3 | // Rx 4 | // 5 | // Created by Krunoslav Zaher on 3/14/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import RxSwift 10 | 11 | extension Observable : Equatable { 12 | 13 | } -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/Mocks/PrimitiveMockObserver.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PrimitiveMockObserver.swift 3 | // RxTests 4 | // 5 | // Created by Krunoslav Zaher on 6/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | import RxTests 12 | 13 | class PrimitiveMockObserver : ObserverType { 14 | typealias Element = ElementType 15 | 16 | var events: [Recorded>] 17 | 18 | init() { 19 | self.events = [] 20 | } 21 | 22 | func on(event: Event) { 23 | events.append(Recorded(time: 0, event: event)) 24 | } 25 | } -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/Mocks/TestConnectableObservable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestConnectableObservable.swift 3 | // RxSwift 4 | // 5 | // Created by Krunoslav Zaher on 4/19/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | 12 | class TestConnectableObservable : ConnectableObservableType { 13 | typealias E = S.E 14 | 15 | let _o: ConnectableObservable 16 | 17 | init(o: Observable, s: S) { 18 | _o = o.multicast(s) 19 | } 20 | 21 | func connect() -> Disposable { 22 | return _o.connect() 23 | } 24 | 25 | func subscribe(observer: O) -> Disposable { 26 | return _o.subscribe(observer) 27 | } 28 | } -------------------------------------------------------------------------------- /Tests/RxSwiftTests/TestImplementations/Observable+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Observable+Extensions.swift 3 | // RxTests 4 | // 5 | // Created by Krunoslav Zaher on 6/4/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxSwift 11 | import RxTests 12 | 13 | public func == (lhs: Observable, rhs: Observable) -> Bool { 14 | return lhs === rhs 15 | } 16 | 17 | extension TestableObservable : Equatable { 18 | 19 | } 20 | 21 | public func == (lhs: TestableObservable, rhs: TestableObservable) -> Bool { 22 | return lhs === rhs 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Tests/Tests/Foundation+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Foundation+Extensions.swift 3 | // Tests 4 | // 5 | // Created by Krunoslav Zaher on 12/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | func isMainThread() -> Bool { 12 | return NSThread.currentThread().isMainThread 13 | } -------------------------------------------------------------------------------- /Tests/Tests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Tests/Tests/Recorded+Timeless.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Recorded+Timeless.swift 3 | // Tests 4 | // 5 | // Created by Krunoslav Zaher on 12/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | import RxTests 11 | import RxSwift 12 | 13 | func next(value: T) -> Recorded> { 14 | return Recorded(time: 0, event: .Next(value)) 15 | } 16 | 17 | func completed() -> Recorded> { 18 | return Recorded(time: 0, event: .Completed) 19 | } 20 | 21 | func error(error: ErrorType) -> Recorded> { 22 | return Recorded(time: 0, event: .Error(error)) 23 | } -------------------------------------------------------------------------------- /Tests/Tests/TestErrors.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TestErrors.swift 3 | // Tests 4 | // 5 | // Created by Krunoslav Zaher on 12/25/15. 6 | // Copyright © 2015 Krunoslav Zaher. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | let testError = NSError(domain: "dummyError", code: -232, userInfo: nil) 12 | let testError1 = NSError(domain: "dummyError1", code: -233, userInfo: nil) 13 | let testError2 = NSError(domain: "dummyError2", code: -234, userInfo: nil) 14 | -------------------------------------------------------------------------------- /UIExplanation.playground/Pages/From Main Thread.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import RxSwift 3 | import RxCocoa 4 | import XCPlayground 5 | 6 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 7 | 8 | example("from main thread") { 9 | print("init thread: \(NSThread.currentThread())") 10 | let source = NSTextField() 11 | let status = NSTextField() 12 | 13 | let URL = NSURL(string: "https://github.com/")! 14 | let request = NSURLRequest(URL: URL) 15 | let observable = NSURLSession.sharedSession().rx_response(request).shareReplayLatestWhileConnected() 16 | 17 | let sourceObservable = observable.map { (maybeData, response) in 18 | return String(data: maybeData, encoding: NSUTF8StringEncoding)! 19 | } 20 | 21 | sourceObservable.subscribe() { e in 22 | print("observer thread: \(NSThread.currentThread())") 23 | } 24 | } -------------------------------------------------------------------------------- /UIExplanation.playground/Pages/From Queue.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import RxSwift 3 | import RxCocoa 4 | import XCPlayground 5 | 6 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 7 | 8 | example("from another queue") { 9 | print("init thread: \(NSThread.currentThread())") 10 | let source = NSTextField() 11 | let status = NSTextField() 12 | 13 | let URL = NSURL(string: "https://github.com/")! 14 | let request = NSURLRequest(URL: URL) 15 | let observable = NSURLSession.sharedSession().rx_response(request).shareReplayLatestWhileConnected() 16 | 17 | let sourceObservable = observable.map { (maybeData, response) in 18 | return String(data: maybeData, encoding: NSUTF8StringEncoding)! 19 | } 20 | 21 | let queue1 = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) 22 | dispatch_async(queue1,{ 23 | print("queue1 thread: \(NSThread.currentThread())") 24 | sourceObservable.subscribe() { e in 25 | print("observer thread: \(NSThread.currentThread())") 26 | } 27 | }) 28 | } -------------------------------------------------------------------------------- /UIExplanation.playground/Pages/SubjectTests.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: [Previous](@previous) 2 | 3 | import Foundation 4 | 5 | var str = "Hello, playground" 6 | 7 | //: [Next](@next) 8 | -------------------------------------------------------------------------------- /UIExplanation.playground/Pages/Without ShareRelay.xcplaygroundpage/Contents.swift: -------------------------------------------------------------------------------- 1 | //: Playground - noun: a place where people can play 2 | 3 | import Cocoa 4 | import RxSwift 5 | import RxCocoa 6 | import XCPlayground 7 | 8 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 9 | 10 | example("without shareReplay duplicate call problem") { 11 | let source = NSTextField() 12 | let status = NSTextField() 13 | 14 | let URL = NSURL(string: "https://github.com/")! 15 | let request = NSURLRequest(URL: URL) 16 | let observable = NSURLSession.sharedSession().rx_response(request).debug("http") 17 | 18 | let sourceObservable = observable.map { (maybeData, response) in 19 | return String(data: maybeData, encoding: NSUTF8StringEncoding)! 20 | }.observeOn(MainScheduler.instance) 21 | let statusObservable = observable.map { (maybeData, response) in 22 | return response.statusCode.description 23 | }.observeOn(MainScheduler.instance) 24 | 25 | sourceObservable.subscribe(source.rx_text) 26 | statusObservable.subscribe(status.rx_text) 27 | } -------------------------------------------------------------------------------- /UIExplanation.playground/Sources/SupportCode.swift: -------------------------------------------------------------------------------- 1 | 2 | import Foundation 3 | 4 | public func example(description: String, action: () -> ()) { 5 | print("\n--- \(description) example ---") 6 | action() 7 | } 8 | 9 | public func delay(delay:Double, closure:()->()) { 10 | dispatch_after( 11 | dispatch_time( 12 | DISPATCH_TIME_NOW, 13 | Int64(delay * Double(NSEC_PER_SEC)) 14 | ), 15 | dispatch_get_main_queue(), closure) 16 | } 17 | 18 | #if NOT_IN_PLAYGROUND 19 | 20 | public func playgroundShouldContinueIndefinitely() { 21 | } 22 | 23 | #else 24 | 25 | import XCPlayground 26 | 27 | public func playgroundShouldContinueIndefinitely() { 28 | XCPlaygroundPage.currentPage.needsIndefiniteExecution = true 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /UIExplanation.playground/contents.xcplayground: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /assets/CNAME.txt: -------------------------------------------------------------------------------- 1 | reactivex.io 2 | -------------------------------------------------------------------------------- /assets/Rx_Logo_M.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparklone/RxSwift/58b9db9ff73f690c6356caeafd0314f44b49966d/assets/Rx_Logo_M.png -------------------------------------------------------------------------------- /scripts/automation-tests/01_githubSignUp.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | test("----- githubSignUp -----", function (check, pass) { 4 | 5 | var target = UIATarget.localTarget(); 6 | 7 | UIATarget.onAlert = function(alert){ 8 | var okButton = UIATarget.localTarget().frontMostApp().alert().cancelButton().tap(); 9 | 10 | sleep(1) 11 | goBack() 12 | 13 | pass() 14 | return false; 15 | } 16 | 17 | target.frontMostApp().mainWindow().tableViews()[0].cells()[3].tap(); 18 | 19 | target.frontMostApp().mainWindow().textFields()[0].tap(); 20 | target.frontMostApp().keyboard().typeString("rxrevolution") 21 | 22 | target.frontMostApp().mainWindow().secureTextFields()[0].tap(); 23 | target.frontMostApp().keyboard().typeString("mypassword") 24 | 25 | target.frontMostApp().mainWindow().secureTextFields()[1].tap(); 26 | target.frontMostApp().keyboard().typeString("mypassword") 27 | 28 | UIATarget.localTarget().tap({x:14.50, y:80.00}); 29 | target.frontMostApp().mainWindow().buttons()["Sign up"].tap(); 30 | 31 | sleep(2) 32 | }); 33 | -------------------------------------------------------------------------------- /scripts/automation-tests/02_searchWikipedia.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | test("----- searchWikipedia -----", function (check, pass) { 4 | 5 | var target = UIATarget.localTarget() 6 | 7 | var width = target.frontMostApp().mainWindow().rect().size.width 8 | 9 | target.frontMostApp().mainWindow().tableViews()[0].cells()[12].tap(); 10 | 11 | target.delay(2); 12 | 13 | var searchBar = target.frontMostApp().mainWindow().searchBars()[0]; 14 | 15 | searchBar.tap() 16 | target.frontMostApp().keyboard().typeString("banana"); 17 | 18 | target.delay(1); 19 | 20 | target.tap({x:width - 40, y:43}); 21 | 22 | target.delay(1); 23 | 24 | searchBar.tap(); 25 | target.delay(1); 26 | 27 | target.frontMostApp().keyboard().typeString("Yosemite"); 28 | target.delay(1); 29 | 30 | target.tap({x:width - 40, y:43}); 31 | 32 | goBack(); 33 | 34 | pass(); 35 | }); 36 | -------------------------------------------------------------------------------- /scripts/automation-tests/05_reactivePartialUpdates.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | test("----- reactivePartialUpdates -----", function (check, pass) { 4 | var target = UIATarget.localTarget() 5 | 6 | target.frontMostApp().mainWindow().tableViews()[0].cells()[11].tap(); 7 | 8 | var rightButton = target.frontMostApp().navigationBar().rightButton(); 9 | rightButton.tap(); 10 | rightButton.tap(); 11 | rightButton.tap(); 12 | rightButton.tap(); 13 | rightButton.tap(); 14 | rightButton.tap(); 15 | rightButton.tap(); 16 | 17 | goBack() 18 | 19 | pass() 20 | }); 21 | -------------------------------------------------------------------------------- /scripts/automation-tests/main.js: -------------------------------------------------------------------------------- 1 | 2 | #import "common.js" 3 | #import "01_githubSignUp.js" 4 | #import "02_searchWikipedia.js" 5 | #import "03_masterDetail.js" 6 | #import "04_controlsTests.js" 7 | #import "05_reactivePartialUpdates.js" 8 | 9 | var target = UIATarget.localTarget(); 10 | 11 | // open all screens 12 | for (var i = 0; i < 14; ++i) { 13 | log(i); 14 | target.delay( 0.5 ); 15 | target.frontMostApp().mainWindow().tableViews()[0].cells()[i].tap(); 16 | target.frontMostApp().navigationBar().leftButton().tap(); 17 | } 18 | -------------------------------------------------------------------------------- /scripts/test-linux.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | CONFIGURATIONS=(debug release) 4 | 5 | for configuration in ${CONFIGURATIONS[@]} 6 | do 7 | swift build -c ${configuration} && .build/${configuration}/AllTests 8 | done 9 | 10 | -------------------------------------------------------------------------------- /scripts/validate-markdown.sh: -------------------------------------------------------------------------------- 1 | mdast -u mdast-slug -u mdast-validate-links ./*.md 2 | mdast -u mdast-slug -u mdast-validate-links ./**/*.md -------------------------------------------------------------------------------- /scripts/validate-playgrounds.sh: -------------------------------------------------------------------------------- 1 | . scripts/common.sh 2 | 3 | CONFIGURATIONS=(Release) 4 | 5 | # make sure osx builds 6 | for scheme in "RxSwift-OSX" 7 | do 8 | for configuration in ${CONFIGURATIONS[@]} 9 | do 10 | PAGES_PATH=${BUILD_DIRECTORY}/Build/Products/${configuration}/all-playground-pages.swift 11 | rx ${scheme} ${configuration} "" build 12 | cat Rx.playground/Sources/*.swift Rx.playground/Pages/**/*.swift > ${PAGES_PATH} 13 | swift -v -D NOT_IN_PLAYGROUND -F ${BUILD_DIRECTORY}/Build/Products/${configuration} ${PAGES_PATH} 14 | done 15 | done 16 | 17 | --------------------------------------------------------------------------------