diff --git a/Documentation/Examples.md b/Documentation/Examples.md index 4a18fa21..0c4e09c8 100644 --- a/Documentation/Examples.md +++ b/Documentation/Examples.md @@ -49,9 +49,9 @@ let c = Observable.combineLatest(a.asObservable(), b.asObservable()) { $0 + $1 } // 1 + 2 = 3 which is >= 0, so `c` is initially equal to "3 is positive" // To pull values out of the Rx `Observable` `c`, subscribe to values from `c`. -// `subscribeNext` means subscribe to the next (fresh) values of `c`. +// `subscribe(onNext:)` means subscribe to the next (fresh) values of `c`. // That also includes the initial value "3 is positive". -c.subscribeNext { print($0) } // prints: "3 is positive" +c.subscribe(onNext: { print($0) }) // prints: "3 is positive" // Now, let's increase the value of `a` a.value = 4 // prints: 6 is positive @@ -152,12 +152,12 @@ self.usernameOutlet.rx_text // That's what `switchLatest` does. .switchLatest() // Now we need to bind that to the user interface somehow. -// Good old `subscribeNext` can do that. +// Good old `subscribe(onNext:)` can do that. // That's the end of `Observable` chain. - .subscribeNext { valid in + .subscribe(onNext: { valid in errorLabel.textColor = validationColor(valid) errorLabel.text = valid.message - } + }) // This will produce a `Disposable` object that can unbind everything and cancel // pending async operations. // Instead of doing it manually, which is tedious, diff --git a/Documentation/GettingStarted.md b/Documentation/GettingStarted.md index 9178b2b9..7663d9b5 100644 --- a/Documentation/GettingStarted.md +++ b/Documentation/GettingStarted.md @@ -79,7 +79,7 @@ Sequences in Rx are described by a push interface (aka callback). ```swift enum Event { case Next(Element) // next element of a sequence - case Error(ErrorProtocol) // sequence failed with error + case Error(Swift.Error) // sequence failed with error case Completed // sequence terminated successfully } @@ -102,7 +102,7 @@ If a sequence does not terminate in some way, resources will be allocated perman **Using dispose bags or `takeUntil` operator is a robust way of making sure resources are cleaned up. We recommend using them in production even if the sequences will terminate in finite time.** -In case you are curious why `ErrorProtocol` isn't generic, you can find explanation [here](DesignRationale.md#why-error-type-isnt-generic). +In case you are curious why `Swift.Error` isn't generic, you can find explanation [here](DesignRationale.md#why-error-type-isnt-generic). ## Disposing @@ -133,7 +133,7 @@ This will print: 5 ``` -Note the you usually do not want to manually call `dispose`; this is only educational example. Calling dispose manually is usually a bad code smell. There are better ways to dispose subscriptions. We can use `DisposeBag`, the `takeUntil` operator, or some other mechanism. +Note that you usually do not want to manually call `dispose`; this is only educational example. Calling dispose manually is usually a bad code smell. There are better ways to dispose subscriptions. We can use `DisposeBag`, the `takeUntil` operator, or some other mechanism. So can this code print something after the `dispose` call executed? The answer is: it depends. @@ -276,9 +276,9 @@ let searchForMe = searchWikipedia("me") let cancel = searchForMe // sequence generation starts now, URL requests are fired - .subscribeNext { results in + .subscribe(onNext: { results in print(results) - } + }) ``` @@ -293,14 +293,14 @@ func myJust(element: E) -> Observable { return Observable.create { observer in observer.on(.Next(element)) observer.on(.Completed) - return NopDisposable.instance + return Disposables.create() } } myJust(0) - .subscribeNext { n in + .subscribe(onNext: { n in print(n) - } + }) ``` this will print: @@ -329,7 +329,7 @@ func myFrom(sequence: [E]) -> Observable { } observer.on(.Completed) - return NopDisposable.instance + return Disposables.create() } } @@ -339,17 +339,17 @@ print("Started ----") // first time stringCounter - .subscribeNext { n in + .subscribe(onNext: { n in print(n) - } + }) print("----") // again stringCounter - .subscribeNext { n in + .subscribe(onNext: { n in print(n) - } + }) print("Ended ----") ``` @@ -382,12 +382,12 @@ func myInterval(interval: NSTimeInterval) -> Observable { var next = 0 dispatch_source_set_timer(timer, 0, UInt64(interval * Double(NSEC_PER_SEC)), 0) - let cancel = AnonymousDisposable { + let cancel = Disposables.create { print("Disposed") dispatch_source_cancel(timer) } dispatch_source_set_event_handler(timer, { - if cancel.disposed { + if cancel.isDisposed { return } observer.on(.Next(next)) @@ -406,9 +406,9 @@ let counter = myInterval(0.1) print("Started ----") let subscription = counter - .subscribeNext { n in + .subscribe(onNext: { n in print(n) - } + }) NSThread.sleepForTimeInterval(0.5) @@ -438,13 +438,13 @@ let counter = myInterval(0.1) print("Started ----") let subscription1 = counter - .subscribeNext { n in + .subscribe(onNext: { n in print("First \(n)") - } + }) let subscription2 = counter - .subscribeNext { n in + .subscribe(onNext: { n in print("Second \(n)") - } + }) NSThread.sleepForTimeInterval(0.5) @@ -503,13 +503,13 @@ let counter = myInterval(0.1) print("Started ----") let subscription1 = counter - .subscribeNext { n in + .subscribe(onNext: { n in print("First \(n)") - } + }) let subscription2 = counter - .subscribeNext { n in + .subscribe(onNext: { n in print("Second \(n)") - } + }) NSThread.sleepForTimeInterval(0.5) @@ -574,7 +574,7 @@ extension NSURLSession { task.resume() - return AnonymousDisposable { + return Disposables.create { task.cancel() } } @@ -637,9 +637,9 @@ let subscription = myInterval(0.1) .myMap { e in return "This is simply \(e)" } - .subscribeNext { n in + .subscribe(onNext: { n in print(n) - } + }) ``` and this will print @@ -668,9 +668,9 @@ This isn't something that should be practiced often, and is a bad code smell, bu let magicBeings: Observable = summonFromMiddleEarth() magicBeings - .subscribeNext { being in // exit the Rx monad + .subscribe(onNext: { being in // exit the Rx monad self.doSomeStateMagic(being) - } + }) .addDisposableTo(disposeBag) // @@ -698,9 +698,9 @@ Every time you do this, somebody will probably write this code somewhere ```swift kittens - .subscribeNext { kitten in + .subscribe(onNext: { kitten in // so something with kitten - } + }) .addDisposableTo(disposeBag) ``` @@ -716,7 +716,7 @@ If you are unsure how exactly some of the operators work, [playgrounds](../Rx.pl ## Error handling -The are two error mechanisms. +There are two error mechanisms. ### Asynchronous error handling mechanism in observables @@ -783,9 +783,9 @@ let subscription = myInterval(0.1) .map { e in return "This is simply \(e)" } - .subscribeNext { n in + .subscribe(onNext: { n in print(n) - } + }) NSThread.sleepForTimeInterval(0.5) @@ -831,7 +831,7 @@ extension ObservableType { observer.on(.Completed) } } - return AnonymousDisposable { + return Disposables.create { print("disposing \(identifier)") subscription.dispose() } @@ -851,9 +851,9 @@ In case you want to have some resource leak detection logic, the simplest method func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool */ _ = Observable.interval(1, scheduler: MainScheduler.instance) - .subscribeNext { _ in - print("Resource count \(RxSwift.resourceCount)") - } + .subscribe(onNext: { _ in + print("Resource count \(RxSwift.resourceCount)") + }) ``` Most efficient way to test for memory leaks is: @@ -952,9 +952,9 @@ Example how to observe frame of `UIView`. ```swift view .rx_observe(CGRect.self, "frame") - .subscribeNext { frame in + .subscribe(onNext: { frame in ... - } + }) ``` or @@ -962,9 +962,9 @@ or ```swift view .rx_observeWeakly(CGRect.self, "frame") - .subscribeNext { frame in + .subscribe(onNext: { frame in ... - } + }) ``` ### `rx_observe` @@ -1077,9 +1077,9 @@ let responseJSON = NSURLSession.sharedSession().rx_JSON(request) let cancelRequest = responseJSON // this will fire the request - .subscribeNext { json in + .subscribe(onNext: { json in print(json) - } + }) NSThread.sleepForTimeInterval(3) diff --git a/Documentation/Linux.md b/Documentation/Linux.md index 413b0ea1..1fd2d6e6 100644 --- a/Documentation/Linux.md +++ b/Documentation/Linux.md @@ -28,4 +28,4 @@ What works: What doesn't work: * Schedulers - because they are dependent on https://github.com/apple/swift-corelibs-libdispatch and it still hasn't been released * Multithreading - still no access to c11 locks -* For some reason it looks like Swift compiler generates wrong code when using `ErrorProtocol` on `Linux`, so don't use errors, otherwise you can get weird crashes. +* For some reason it looks like Swift compiler generates wrong code when using `Swift.Error` on `Linux`, so don't use errors, otherwise you can get weird crashes. diff --git a/Documentation/Schedulers.md b/Documentation/Schedulers.md index 6dbe7cc3..9d6b70f3 100644 --- a/Documentation/Schedulers.md +++ b/Documentation/Schedulers.md @@ -13,7 +13,7 @@ There are two main operators that work with schedulers, `observeOn` and `subscri If you want to perform work on a different scheduler just use `observeOn(scheduler)` operator. -You would usually use `observeOn` a lot more often then `subscribeOn`. +You would usually use `observeOn` a lot more often than `subscribeOn`. In case `observeOn` isn't explicitly specified, work will be performed on whichever thread/scheduler elements are generated. @@ -33,7 +33,7 @@ sequence1 If you want to start sequence generation (`subscribe` method) and call dispose on a specific scheduler, use `subscribeOn(scheduler)`. -In case `subscribeOn` isn't explicitly specified, the `subscribe` method will be called on the same thread/scheduler on which `subscribeNext` or `subscribe` is called. +In case `subscribeOn` isn't explicitly specified, the `subscribe` method will be called on the same thread/scheduler on which `subscribe(onNext:)` or `subscribe` is called. In case `subscribeOn` isn't explicitly specified, the `dispose` method will be called on the same thread/scheduler that initiated disposing. diff --git a/Documentation/Warnings.md b/Documentation/Warnings.md index f3267550..52813279 100644 --- a/Documentation/Warnings.md +++ b/Documentation/Warnings.md @@ -114,9 +114,9 @@ let disposeBag = DisposeBag() xs .filter { ... } .map { ... } - .subscribeNext { nextElement in // <-- note the `subscribe*` method + .subscribe(onNext: { nextElement in // <-- note the `subscribe*` method // use the element print(nextElement) - } + }) .addDisposableTo(disposeBag) ``` diff --git a/Package.swift b/Package.swift index 99b9b3bf..c088c2f5 100644 --- a/Package.swift +++ b/Package.swift @@ -3,11 +3,6 @@ import PackageDescription #if os(OSX) let package = Package( name: "RxSwift", - exclude: [ - "Sources/RxCocoa", - "Sources/RxTests", - "Sources/AllTests" - ], targets: [ Target( name: "RxSwift" @@ -32,14 +27,16 @@ let package = Package( .Target(name: "RxTests") ] ) + ], + exclude: [ + "Sources/RxCocoa", + "Sources/RxTests", + "Sources/AllTests" ] ) #elseif os(Linux) let package = Package( name: "RxSwift", - exclude: [ - "Sources/RxCocoa", - ], targets: [ Target( name: "RxSwift" @@ -64,6 +61,9 @@ let package = Package( .Target(name: "RxTests") ] ) + ], + exclude: [ + "Sources/RxCocoa", ] ) #endif diff --git a/README.md b/README.md index 2e55424d..b65cb038 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ KVO observing, async operations and streams are all unified under [abstraction o ###### ... interact -* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences.
[![Slack channel](http://slack.rxswift.org/badge.svg)](http://slack.rxswift.org) [Join Slack Channel](http://slack.rxswift.org/) +* All of this is great, but it would be nice to talk with other people using RxSwift and exchange experiences.
[![Slack channel](http://rxswift-slack.herokuapp.com/badge.svg)](http://slack.rxswift.org) [Join Slack Channel](http://rxswift-slack.herokuapp.com) * Report a problem using the library. [Open an Issue With Bug Template](ISSUE_TEMPLATE.md) * Request a new feature. [Open an Issue With Feature Request Template](Documentation/NewFeatureRequestTemplate.md) diff --git a/Rx.playground/Pages/Combining_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Combining_Operators.xcplaygroundpage/Contents.swift index 2ca58278..146814f5 100644 --- a/Rx.playground/Pages/Combining_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Combining_Operators.xcplaygroundpage/Contents.swift @@ -22,7 +22,7 @@ example("startWith") { .startWith("1️⃣") .startWith("2️⃣") .startWith("3️⃣", "🅰️", "🅱️") - .subscribeNext { print($0) } + ..subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -40,7 +40,7 @@ example("merge") { Observable.of(subject1, subject2) .merge() - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) subject1.onNext("🅰️") @@ -70,7 +70,7 @@ example("zip") { Observable.zip(stringSubject, intSubject) { stringElement, intElement in "\(stringElement) \(intElement)" } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) stringSubject.onNext("🅰️") @@ -98,7 +98,7 @@ example("combineLatest") { Observable.combineLatest(stringSubject, intSubject) { stringElement, intElement in "\(stringElement) \(intElement)" } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) stringSubject.onNext("🅰️") @@ -121,7 +121,7 @@ example("Array.combineLatest") { [stringObservable, fruitObservable, animalObservable].combineLatest { "\($0[0]) \($0[1]) \($0[2])" } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -141,7 +141,7 @@ example("switchLatest") { variable.asObservable() .switchLatest() - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) subject1.onNext("🏈") diff --git a/Rx.playground/Pages/Connectable_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Connectable_Operators.xcplaygroundpage/Contents.swift index d7637db0..1c8e96f3 100644 --- a/Rx.playground/Pages/Connectable_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Connectable_Operators.xcplaygroundpage/Contents.swift @@ -23,11 +23,11 @@ func sampleWithoutConnectableOperators() { let interval = Observable.interval(1, scheduler: MainScheduler.instance) _ = interval - .subscribeNext { print("Subscription: 1, Event: \($0)") } + .subscribe(onNext: { print("Subscription: 1, Event: \($0)") }) delay(5) { _ = interval - .subscribeNext { print("Subscription: 2, Event: \($0)") } + .subscribe(onNext: { print("Subscription: 2, Event: \($0)") }) } } @@ -47,18 +47,18 @@ func sampleWithPublish() { .publish() _ = intSequence - .subscribeNext { print("Subscription 1:, Event: \($0)") } + .subscribe(onNext: { print("Subscription 1:, Event: \($0)") }) - delay(2) { intSequence.connect() } + delay(2) { _ = intSequence.connect() } delay(4) { _ = intSequence - .subscribeNext { print("Subscription 2:, Event: \($0)") } + .subscribe(onNext: { print("Subscription 2:, Event: \($0)") }) } delay(6) { _ = intSequence - .subscribeNext { print("Subscription 3:, Event: \($0)") } + .subscribe(onNext: { print("Subscription 3:, Event: \($0)") }) } } @@ -79,18 +79,18 @@ func sampleWithReplayBuffer() { .replay(5) _ = intSequence - .subscribeNext { print("Subscription 1:, Event: \($0)") } + ..subscribe(onNext: { print("Subscription 1:, Event: \($0)") }) - delay(2) { intSequence.connect() } + delay(2) { _ = intSequence.connect() } delay(4) { _ = intSequence - .subscribeNext { print("Subscription 2:, Event: \($0)") } + .subscribe(onNext: { print("Subscription 2:, Event: \($0)") }) } delay(8) { _ = intSequence - .subscribeNext { print("Subscription 3:, Event: \($0)") } + .subscribe(onNext: { print("Subscription 3:, Event: \($0)") }) } } @@ -107,24 +107,24 @@ func sampleWithMulticast() { let subject = PublishSubject() _ = subject - .subscribeNext { print("Subject: \($0)") } + .subscribe(onNext: { print("Subject: \($0)") }) let intSequence = Observable.interval(1, scheduler: MainScheduler.instance) .multicast(subject) _ = intSequence - .subscribeNext { print("\tSubscription 1:, Event: \($0)") } + .subscribe(onNext: { print("\tSubscription 1:, Event: \($0)") }) - delay(2) { intSequence.connect() } + delay(2) { _ = intSequence.connect() } delay(4) { _ = intSequence - .subscribeNext { print("\tSubscription 2:, Event: \($0)") } + .subscribe(onNext: { print("\tSubscription 2:, Event: \($0)") }) } delay(6) { _ = intSequence - .subscribeNext { print("\tSubscription 3:, Event: \($0)") } + .subscribe(onNext: { print("\tSubscription 3:, Event: \($0)") }) } } diff --git a/Rx.playground/Pages/Creating_and_Subscribing_to_Observables.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Creating_and_Subscribing_to_Observables.xcplaygroundpage/Contents.swift index 7f751cf0..2d82494f 100644 --- a/Rx.playground/Pages/Creating_and_Subscribing_to_Observables.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Creating_and_Subscribing_to_Observables.xcplaygroundpage/Contents.swift @@ -63,13 +63,13 @@ example("of") { let disposeBag = DisposeBag() Observable.of("🐶", "🐱", "🐭", "🐹") - .subscribeNext { element in + .subscribe(onNext: { element in print(element) - } + }) .addDisposableTo(disposeBag) } /*: - > This example also introduces using the `subscribeNext(_:)` convenience method. Unlike `subscribe(_:)`, which subscribes an _event_ handler for all event types (Next, Error, and Completed), `subscribeNext(_:)` subscribes an _element_ handler that will ignore Error and Completed events and only produce Next event elements. There are also `subscribeError(_:)` and `subscribeCompleted(_:)` convenience methods, should you only want to subscribe to those event types. And there is a `subscribe(onNext:onError:onCompleted:onDisposed:)` method, which allows you to react to one or more event types and when the subscription is terminated for any reason, or disposed, in a single call: + > This example also introduces using the `subscribe(onNext:)` convenience method. Unlike `subscribe(_:)`, which subscribes an _event_ handler for all event types (Next, Error, and Completed), `subscribe(onNext:)` subscribes an _element_ handler that will ignore Error and Completed events and only produce Next event elements. There are also `subscribe(onError:)` and `subscribe(onCompleted:)` convenience methods, should you only want to subscribe to those event types. And there is a `subscribe(onNext:onError:onCompleted:onDisposed:)` method, which allows you to react to one or more event types and when the subscription is terminated for any reason, or disposed, in a single call: ``` someObservable.subscribe( onNext: { print("Element:", $0) }, @@ -79,14 +79,14 @@ example("of") { ) ``` ---- - ## toObservable + ## from Creates an `Observable` sequence from a `SequenceType`, such as an `Array`, `Dictionary`, or `Set`. */ -example("toObservable") { +example("from") { let disposeBag = DisposeBag() - ["🐶", "🐱", "🐭", "🐹"].toObservable() - .subscribeNext { print($0) } + Observable.from(["🐶", "🐱", "🐭", "🐹"]) + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -102,7 +102,7 @@ example("create") { return Observable.create { observer in observer.on(.next(element)) observer.on(.completed) - return NopDisposable.instance + return Disposables.create() } } @@ -132,7 +132,7 @@ example("repeatElement") { Observable.repeatElement("🔴") .take(3) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -149,7 +149,7 @@ example("generate") { condition: { $0 < 3 }, iterate: { $0 + 1 } ) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -170,16 +170,16 @@ example("deferred") { observer.onNext("🐶") observer.onNext("🐱") observer.onNext("🐵") - return NopDisposable.instance + return Disposables.create() } } deferredSequence - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) deferredSequence - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -190,7 +190,7 @@ example("deferred") { example("error") { let disposeBag = DisposeBag() - Observable.error(Error.test) + Observable.error(TestError.test) .subscribe { print($0) } .addDisposableTo(disposeBag) } @@ -204,7 +204,7 @@ example("doOn") { Observable.of("🍎", "🍐", "🍊", "🍋") .doOn { print("Intercepted:", $0) } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } //: > There are also `doOnNext(_:)`, `doOnError(_:)`, and `doOnCompleted(_:)` convenience methods to intercept those specific events, and `doOn(onNext:onError:onCompleted:)` to intercept one or more events in a single call. diff --git a/Rx.playground/Pages/Debugging_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Debugging_Operators.xcplaygroundpage/Contents.swift index fdde6b68..b83b0905 100644 --- a/Rx.playground/Pages/Debugging_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Debugging_Operators.xcplaygroundpage/Contents.swift @@ -24,7 +24,7 @@ example("debug") { observer.onNext("🍊") if count < 5 { - observer.onError(Error.Test) + observer.onError(TestError.test) print("Error encountered") count += 1 } @@ -34,13 +34,13 @@ example("debug") { observer.onNext("🐭") observer.onCompleted() - return NopDisposable.instance + return Disposables.create() } sequenceThatErrors .retry(3) .debug() - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -59,11 +59,11 @@ example("RxSwift.resourceCount") { let variable = Variable("🍎") - let subscription1 = variable.asObservable().subscribeNext { print($0) } + let subscription1 = variable.asObservable().subscribe(onNext: { print($0) }) print(RxSwift.resourceCount) - let subscription2 = variable.asObservable().subscribeNext { print($0) } + let subscription2 = variable.asObservable().subscribe(onNext: { print($0) }) print(RxSwift.resourceCount) @@ -80,4 +80,4 @@ print(RxSwift.resourceCount) #endif //: > `RxSwift.resourceCount` is not enabled by default, and should generally not be enabled in Release builds. [Click here](Enable_RxSwift.resourceCount) for instructions on how to enable it. -//: [Table of Contents](Table_of_Contents) +//: [Table of Contents](Tabl \ No newline at end of file diff --git a/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift index 0383aa15..00570f86 100644 --- a/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Error_Handling_Operators.xcplaygroundpage/Contents.swift @@ -29,7 +29,7 @@ example("catchErrorJustReturn") { sequenceThatFails.onNext("😨") sequenceThatFails.onNext("😡") sequenceThatFails.onNext("🔴") - sequenceThatFails.onError(Error.Test) + sequenceThatFails.onError(TestError.test) } /*: ---- @@ -55,7 +55,7 @@ example("catchError") { sequenceThatFails.onNext("😨") sequenceThatFails.onNext("😡") sequenceThatFails.onNext("🔴") - sequenceThatFails.onError(Error.Test) + sequenceThatFails.onError(TestError.test) recoverySequence.onNext("😊") } @@ -75,7 +75,7 @@ example("retry") { observer.onNext("🍊") if count == 1 { - observer.onError(Error.Test) + observer.onError(TestError.test) print("Error encountered") count += 1 } @@ -85,12 +85,12 @@ example("retry") { observer.onNext("🐭") observer.onCompleted() - return NopDisposable.instance + return Disposables.create() } sequenceThatErrors .retry() - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -109,7 +109,7 @@ example("retry maxAttemptCount") { observer.onNext("🍊") if count < 5 { - observer.onError(Error.Test) + observer.onError(TestError.test) print("Error encountered") count += 1 } @@ -119,13 +119,13 @@ example("retry maxAttemptCount") { observer.onNext("🐭") observer.onCompleted() - return NopDisposable.instance + return Disposables.create() } sequenceThatErrors .retry(3) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } -//: [Next](@next) - [Table of Contents](Table_of_Contents) +//: [Next](@next) - [Table of Contents](Table_of_ \ No newline at end of file diff --git a/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift index c885603a..9f6a0819 100644 --- a/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Filtering_and_Conditional_Operators.xcplaygroundpage/Contents.swift @@ -25,7 +25,7 @@ example("filter") { .filter { $0 == "🐱" } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -39,7 +39,7 @@ example("distinctUntilChanged") { Observable.of("🐱", "🐷", "🐱", "🐱", "🐱", "🐵", "🐱") .distinctUntilChanged() - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -53,7 +53,7 @@ example("elementAt") { Observable.of("🐱", "🐰", "🐶", "🐸", "🐷", "🐵") .elementAt(3) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -66,7 +66,7 @@ example("single") { Observable.of("🐱", "🐰", "🐶", "🐸", "🐷", "🐵") .single() - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } @@ -99,7 +99,7 @@ example("take") { Observable.of("🐱", "🐰", "🐶", "🐸", "🐷", "🐵") .take(3) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -113,7 +113,7 @@ example("takeLast") { Observable.of("🐱", "🐰", "🐶", "🐸", "🐷", "🐵") .takeLast(3) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -127,7 +127,7 @@ example("takeWhile") { Observable.of(1, 2, 3, 4, 5, 6) .takeWhile { $0 < 4 } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -168,7 +168,7 @@ example("skip") { Observable.of("🐱", "🐰", "🐶", "🐸", "🐷", "🐵") .skip(2) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -182,7 +182,7 @@ example("skipWhile") { Observable.of(1, 2, 3, 4, 5, 6) .skipWhile { $0 < 4 } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -197,7 +197,7 @@ example("skipWhileWithIndex") { .skipWhileWithIndex { element, index in index < 3 } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -214,7 +214,7 @@ example("skipUntil") { sourceSequence .skipUntil(referenceSequence) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) sourceSequence.onNext("🐱") @@ -228,4 +228,4 @@ example("skipUntil") { sourceSequence.onNext("🐵") } -//: [Next](@next) - [Table of Contents](Table_of_Contents) +//: \ No newline at end of file diff --git a/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift index 58855807..80f529e7 100644 --- a/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Introduction.xcplaygroundpage/Contents.swift @@ -46,7 +46,7 @@ All of these various systems makes our code needlessly complex. Wouldn't it be b `--tap--tap----------tap--> // "|" = Continues indefinitely, such as a sequence of button taps` - > These diagrams are call marble diagrams. You can learn more about them at [RxMarbles.com](http://rxmarbles.com). + > These diagrams are called marble diagrams. You can learn more about them at [RxMarbles.com](http://rxmarbles.com). */ /*: ### Observables and observers (aka subscribers) @@ -58,7 +58,7 @@ example("Observable with no subscribers") { print("This will never be printed") observerOfString.on(.next("😬")) observerOfString.on(.completed) - return NopDisposable.instance + return Disposables.create() } } /*: @@ -70,7 +70,7 @@ example("Observable with subscriber") { print("Observable created") observerOfString.on(.next("😉")) observerOfString.on(.completed) - return NopDisposable.instance + return Disposables.create() } .subscribe { event in print(event) diff --git a/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift index 398abac4..59d77ecb 100644 --- a/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Mathematical_and_Aggregate_Operators.xcplaygroundpage/Contents.swift @@ -34,7 +34,7 @@ example("reduce") { Observable.of(10, 100, 1000) .reduce(1, accumulator: +) - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -69,4 +69,4 @@ example("concat") { subject2.onNext("🐭") } -//: [Next](@next) - [Table of Contents](Table_of_Contents) +//: [Next](@next) - [Table of Contents](Table_of_Conte \ No newline at end of file diff --git a/Rx.playground/Pages/Transforming_Operators.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Transforming_Operators.xcplaygroundpage/Contents.swift index d1768805..f1fb0a1e 100644 --- a/Rx.playground/Pages/Transforming_Operators.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Transforming_Operators.xcplaygroundpage/Contents.swift @@ -19,7 +19,7 @@ example("map") { let disposeBag = DisposeBag() Observable.of(1, 2, 3) .map { $0 * $0 } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } /*: @@ -42,7 +42,7 @@ example("flatMap and flatMapLatest") { player.asObservable() .flatMap { $0.score.asObservable() } // Change flatMap to flatMapLatest and observe change in printed output - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) 👦🏻.score.value = 85 @@ -71,8 +71,8 @@ example("scan") { .scan(1) { aggregateValue, newValue in aggregateValue + newValue } - .subscribeNext { print($0) } + .subscribe(onNext: { print($0) }) .addDisposableTo(disposeBag) } -//: [Next](@next) - [Table of Contents](Table_of_Contents) +//: [Next](@next) - [Table of Contents](Tabl \ No newline at end of file diff --git a/Rx.playground/Pages/Working_with_Subjects.xcplaygroundpage/Contents.swift b/Rx.playground/Pages/Working_with_Subjects.xcplaygroundpage/Contents.swift index 7d8e4da2..b61ffd75 100644 --- a/Rx.playground/Pages/Working_with_Subjects.xcplaygroundpage/Contents.swift +++ b/Rx.playground/Pages/Working_with_Subjects.xcplaygroundpage/Contents.swift @@ -18,7 +18,7 @@ extension ObservableType { Add observer with `id` and print each emitted event. - parameter id: an identifier for the subscription. */ - func addObserver(id: String) -> Disposable { + func addObserver(_ id: String) -> Disposable { return subscribe { print("Subscription:", id, "Event:", $0) } } diff --git a/Rx.playground/Sources/SupportCode.swift b/Rx.playground/Sources/SupportCode.swift index 7c653a7b..e830a8f7 100644 --- a/Rx.playground/Sources/SupportCode.swift +++ b/Rx.playground/Sources/SupportCode.swift @@ -5,16 +5,16 @@ import Foundation - parameter description: example description - parameter action: `Void` closure */ -public func example(description: String, action: @noescape(Void) -> Void) { - printExampleHeader(description: description) +public func example(_ description: String, action: @noescape(Void) -> Void) { + printExampleHeader(description) action() } -public func printExampleHeader(description: String) { +public func printExampleHeader(_ description: String) { print("\n--- \(description) example ---") } -public enum Error: ErrorProtocol { +public enum TestError: Swift.Error { case test } @@ -24,10 +24,10 @@ public enum Error: ErrorProtocol { - parameter delay: time in seconds to wait before executing `closure` - parameter closure: `Void` closure */ -public func delay(delay: Double, closure: (Void) -> Void) { +public func delay(_ delay: Double, closure: (Void) -> Void) { let delayTime = DispatchTime.now() + DispatchTimeInterval.seconds(Int(delay)) - DispatchQueue.main.after(when: delayTime) { + DispatchQueue.main.asyncAfter(deadline: delayTime) { closure() } } diff --git a/Rx.playground/contents.xcplayground b/Rx.playground/contents.xcplayground index 82b9ef3e..ec46306c 100644 --- a/Rx.playground/contents.xcplayground +++ b/Rx.playground/contents.xcplayground @@ -1,5 +1,5 @@ - + diff --git a/Rx.xcodeproj/project.pbxproj b/Rx.xcodeproj/project.pbxproj index 14db7eb6..13e7fea3 100644 --- a/Rx.xcodeproj/project.pbxproj +++ b/Rx.xcodeproj/project.pbxproj @@ -66,6 +66,7 @@ 84E4D3931C9AFD3500ADFDC9 /* UISearchController+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E4D3901C9AFCD500ADFDC9 /* UISearchController+Rx.swift */; }; 84E4D3941C9AFD3600ADFDC9 /* UISearchController+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E4D3901C9AFCD500ADFDC9 /* UISearchController+Rx.swift */; }; 84E4D3961C9B011000ADFDC9 /* UISearchController+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E4D3951C9B011000ADFDC9 /* UISearchController+RxTests.swift */; }; + 87379AE01D61C6F50047CA88 /* Reactive.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2F461001CD7ABE400527B4D /* Reactive.swift */; }; 88718CFE1CE5D80000D88D60 /* UITabBar+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88718CFD1CE5D80000D88D60 /* UITabBar+Rx.swift */; }; 88718CFF1CE5D80000D88D60 /* UITabBar+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88718CFD1CE5D80000D88D60 /* UITabBar+Rx.swift */; }; 88718D011CE5DE2600D88D60 /* UITabBar+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88718D001CE5DE2500D88D60 /* UITabBar+RxTests.swift */; }; @@ -121,8 +122,6 @@ C8093CDE1B8A72BE0088E94D /* DisposeBag.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C581B8A72BE0088E94D /* DisposeBag.swift */; }; C8093CDF1B8A72BE0088E94D /* DisposeBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C591B8A72BE0088E94D /* DisposeBase.swift */; }; C8093CE01B8A72BE0088E94D /* DisposeBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C591B8A72BE0088E94D /* DisposeBase.swift */; }; - C8093CE11B8A72BE0088E94D /* NAryDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5A1B8A72BE0088E94D /* NAryDisposable.swift */; }; - C8093CE21B8A72BE0088E94D /* NAryDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5A1B8A72BE0088E94D /* NAryDisposable.swift */; }; C8093CE51B8A72BE0088E94D /* NopDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5C1B8A72BE0088E94D /* NopDisposable.swift */; }; C8093CE61B8A72BE0088E94D /* NopDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5C1B8A72BE0088E94D /* NopDisposable.swift */; }; C8093CE71B8A72BE0088E94D /* ScheduledDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5D1B8A72BE0088E94D /* ScheduledDisposable.swift */; }; @@ -139,8 +138,8 @@ C8093CF61B8A72BE0088E94D /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C641B8A72BE0088E94D /* Event.swift */; }; C8093CF71B8A72BE0088E94D /* ImmediateSchedulerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C651B8A72BE0088E94D /* ImmediateSchedulerType.swift */; }; C8093CF81B8A72BE0088E94D /* ImmediateSchedulerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C651B8A72BE0088E94D /* ImmediateSchedulerType.swift */; }; - C8093CFB1B8A72BE0088E94D /* Observable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C671B8A72BE0088E94D /* Observable+Extensions.swift */; }; - C8093CFC1B8A72BE0088E94D /* Observable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C671B8A72BE0088E94D /* Observable+Extensions.swift */; }; + C8093CFB1B8A72BE0088E94D /* ObservableType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C671B8A72BE0088E94D /* ObservableType+Extensions.swift */; }; + C8093CFC1B8A72BE0088E94D /* ObservableType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C671B8A72BE0088E94D /* ObservableType+Extensions.swift */; }; C8093CFD1B8A72BE0088E94D /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C681B8A72BE0088E94D /* Observable.swift */; }; C8093CFE1B8A72BE0088E94D /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C681B8A72BE0088E94D /* Observable.swift */; }; C8093CFF1B8A72BE0088E94D /* Amb.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C6B1B8A72BE0088E94D /* Amb.swift */; }; @@ -810,6 +809,9 @@ C8E7B36A1C30C6B800B34368 /* TestableObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E7B3681C30C6B800B34368 /* TestableObservable.swift */; }; C8E7B36B1C30C6B800B34368 /* TestableObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E7B3681C30C6B800B34368 /* TestableObservable.swift */; }; C8E7B36C1C30C6B800B34368 /* TestableObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E7B3681C30C6B800B34368 /* TestableObservable.swift */; }; + C8E9E42B1D43B26C0049644E /* Observable+DebugTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E9E42A1D43B26C0049644E /* Observable+DebugTest.swift */; }; + C8E9E42C1D43B26C0049644E /* Observable+DebugTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E9E42A1D43B26C0049644E /* Observable+DebugTest.swift */; }; + C8E9E42D1D43B26C0049644E /* Observable+DebugTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8E9E42A1D43B26C0049644E /* Observable+DebugTest.swift */; }; C8F0BF921BBBFB8B001B112F /* Observable+Creation.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C981B8A72BE0088E94D /* Observable+Creation.swift */; }; C8F0BF931BBBFB8B001B112F /* ConnectableObservableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C4D1B8A72BE0088E94D /* ConnectableObservableType.swift */; }; C8F0BF941BBBFB8B001B112F /* Just.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8C3DA021B9390C4004D233E /* Just.swift */; }; @@ -833,7 +835,7 @@ C8F0BFA61BBBFB8B001B112F /* ReplaySubject.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093CC01B8A72BE0088E94D /* ReplaySubject.swift */; }; C8F0BFA71BBBFB8B001B112F /* Zip+CollectionType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8C3D9FD1B935EDF004D233E /* Zip+CollectionType.swift */; }; C8F0BFA81BBBFB8B001B112F /* Observable+Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C9D1B8A72BE0088E94D /* Observable+Time.swift */; }; - C8F0BFA91BBBFB8B001B112F /* Observable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C671B8A72BE0088E94D /* Observable+Extensions.swift */; }; + C8F0BFA91BBBFB8B001B112F /* ObservableType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C671B8A72BE0088E94D /* ObservableType+Extensions.swift */; }; C8F0BFAA1BBBFB8B001B112F /* Throttle.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C901B8A72BE0088E94D /* Throttle.swift */; }; C8F0BFAC1BBBFB8B001B112F /* Catch.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C6E1B8A72BE0088E94D /* Catch.swift */; }; C8F0BFAD1BBBFB8B001B112F /* CombineLatest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C711B8A72BE0088E94D /* CombineLatest.swift */; }; @@ -904,7 +906,6 @@ C8F0BFF21BBBFB8B001B112F /* ObserverType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093CAB1B8A72BE0088E94D /* ObserverType.swift */; }; C8F0BFF31BBBFB8B001B112F /* SubscribeOn.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C8B1B8A72BE0088E94D /* SubscribeOn.swift */; }; C8F0BFF41BBBFB8B001B112F /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C681B8A72BE0088E94D /* Observable.swift */; }; - C8F0BFF51BBBFB8B001B112F /* NAryDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5A1B8A72BE0088E94D /* NAryDisposable.swift */; }; C8F0BFF61BBBFB8B001B112F /* SerialDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */; }; C8F0BFF71BBBFB8B001B112F /* Never.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8C3DA0B1B93959F004D233E /* Never.swift */; }; C8F0BFF91BBBFB8B001B112F /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C641B8A72BE0088E94D /* Event.swift */; }; @@ -1015,6 +1016,10 @@ CBEE77201BD649A000AD584C /* ToArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEE771E1BD649A000AD584C /* ToArray.swift */; }; CBEE77211BD649A000AD584C /* ToArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEE771E1BD649A000AD584C /* ToArray.swift */; }; CBEE77221BD649A000AD584C /* ToArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = CBEE771E1BD649A000AD584C /* ToArray.swift */; }; + CDDEF16A1D4FB40000CA8546 /* Disposables.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDEF1691D4FB40000CA8546 /* Disposables.swift */; }; + CDDEF16B1D4FB40000CA8546 /* Disposables.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDEF1691D4FB40000CA8546 /* Disposables.swift */; }; + CDDEF16C1D4FB40000CA8546 /* Disposables.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDEF1691D4FB40000CA8546 /* Disposables.swift */; }; + CDDEF16D1D4FB40000CA8546 /* Disposables.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDEF1691D4FB40000CA8546 /* Disposables.swift */; }; D203C4F31BB9C4CA00D02D00 /* RxCollectionViewReactiveArrayDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88253F11B8A752B00B02D69 /* RxCollectionViewReactiveArrayDataSource.swift */; }; D203C4F41BB9C52400D02D00 /* RxTableViewReactiveArrayDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88253F21B8A752B00B02D69 /* RxTableViewReactiveArrayDataSource.swift */; }; D203C4F51BB9C52900D02D00 /* ItemEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88253F41B8A752B00B02D69 /* ItemEvents.swift */; }; @@ -1086,7 +1091,7 @@ D2EBEAE01BB9B697003A27DC /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C641B8A72BE0088E94D /* Event.swift */; }; D2EBEAE11BB9B697003A27DC /* ImmediateSchedulerType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C651B8A72BE0088E94D /* ImmediateSchedulerType.swift */; }; D2EBEAE21BB9B697003A27DC /* Observable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C681B8A72BE0088E94D /* Observable.swift */; }; - D2EBEAE31BB9B697003A27DC /* Observable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C671B8A72BE0088E94D /* Observable+Extensions.swift */; }; + D2EBEAE31BB9B697003A27DC /* ObservableType+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C671B8A72BE0088E94D /* ObservableType+Extensions.swift */; }; D2EBEAE41BB9B697003A27DC /* ObservableType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C9E1B8A72BE0088E94D /* ObservableType.swift */; }; D2EBEAE51BB9B697003A27DC /* AnyObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093CA01B8A72BE0088E94D /* AnyObserver.swift */; }; D2EBEAE61BB9B697003A27DC /* ObserverType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093CAB1B8A72BE0088E94D /* ObserverType.swift */; }; @@ -1103,7 +1108,6 @@ D2EBEAF21BB9B6AE003A27DC /* CompositeDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C571B8A72BE0088E94D /* CompositeDisposable.swift */; }; D2EBEAF31BB9B6AE003A27DC /* DisposeBag.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C581B8A72BE0088E94D /* DisposeBag.swift */; }; D2EBEAF41BB9B6AE003A27DC /* DisposeBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C591B8A72BE0088E94D /* DisposeBase.swift */; }; - D2EBEAF51BB9B6AE003A27DC /* NAryDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5A1B8A72BE0088E94D /* NAryDisposable.swift */; }; D2EBEAF61BB9B6B2003A27DC /* NopDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5C1B8A72BE0088E94D /* NopDisposable.swift */; }; D2EBEAF71BB9B6B2003A27DC /* ScheduledDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5D1B8A72BE0088E94D /* ScheduledDisposable.swift */; }; D2EBEAF91BB9B6B2003A27DC /* SerialDisposable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */; }; @@ -1440,8 +1444,6 @@ C8093C571B8A72BE0088E94D /* CompositeDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CompositeDisposable.swift; sourceTree = ""; }; C8093C581B8A72BE0088E94D /* DisposeBag.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisposeBag.swift; sourceTree = ""; }; C8093C591B8A72BE0088E94D /* DisposeBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisposeBase.swift; sourceTree = ""; }; - C8093C5A1B8A72BE0088E94D /* NAryDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NAryDisposable.swift; sourceTree = ""; }; - C8093C5B1B8A72BE0088E94D /* NAryDisposable.tt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NAryDisposable.tt; sourceTree = ""; }; C8093C5C1B8A72BE0088E94D /* NopDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NopDisposable.swift; sourceTree = ""; }; C8093C5D1B8A72BE0088E94D /* ScheduledDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScheduledDisposable.swift; sourceTree = ""; }; C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SerialDisposable.swift; sourceTree = ""; }; @@ -1451,7 +1453,7 @@ C8093C641B8A72BE0088E94D /* Event.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Event.swift; sourceTree = ""; }; C8093C651B8A72BE0088E94D /* ImmediateSchedulerType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImmediateSchedulerType.swift; sourceTree = ""; }; C8093C661B8A72BE0088E94D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C8093C671B8A72BE0088E94D /* Observable+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "Observable+Extensions.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + C8093C671B8A72BE0088E94D /* ObservableType+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "ObservableType+Extensions.swift"; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; C8093C681B8A72BE0088E94D /* Observable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Observable.swift; sourceTree = ""; }; C8093C6B1B8A72BE0088E94D /* Amb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Amb.swift; sourceTree = ""; }; C8093C6E1B8A72BE0088E94D /* Catch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Catch.swift; sourceTree = ""; }; @@ -1724,6 +1726,7 @@ C8C4B4C01C17727000828BD5 /* MessageSentObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageSentObserver.swift; sourceTree = ""; }; C8D132431C42D15E00B59FFF /* SectionedViewDataSourceType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SectionedViewDataSourceType.swift; sourceTree = ""; }; C8D132521C42DA7F00B59FFF /* SectionedViewDataSourceMock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SectionedViewDataSourceMock.swift; sourceTree = ""; }; + C8D2C1501D4F3CD6006E2431 /* Rx.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Rx.playground; sourceTree = ""; }; C8DB967D1BF7496C0084BD53 /* KVORepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KVORepresentable.swift; sourceTree = ""; }; C8DB96821BF754C80084BD53 /* NSObject+Rx+KVORepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSObject+Rx+KVORepresentable.swift"; sourceTree = ""; }; C8DB96871BF756F40084BD53 /* KVORepresentable+CoreGraphics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "KVORepresentable+CoreGraphics.swift"; sourceTree = ""; }; @@ -1740,6 +1743,7 @@ C8E3A7301C2606A900643FE6 /* Event+Equatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Event+Equatable.swift"; sourceTree = ""; }; C8E3A7351C26088C00643FE6 /* Any+Equatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Any+Equatable.swift"; sourceTree = ""; }; C8E7B3681C30C6B800B34368 /* TestableObservable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestableObservable.swift; sourceTree = ""; }; + C8E9E42A1D43B26C0049644E /* Observable+DebugTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+DebugTest.swift"; sourceTree = ""; }; C8F0C0021BBBFB8B001B112F /* RxSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C8F0C04B1BBBFBB9001B112F /* RxCocoa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxCocoa.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C8F0C0581BBBFBCE001B112F /* RxBlocking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxBlocking.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1758,6 +1762,7 @@ CB883B441BE256D4000AC2EE /* BooleanDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BooleanDisposable.swift; sourceTree = ""; }; CB883B491BE369AA000AC2EE /* AddRef.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddRef.swift; sourceTree = ""; }; CBEE771E1BD649A000AD584C /* ToArray.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToArray.swift; sourceTree = ""; }; + CDDEF1691D4FB40000CA8546 /* Disposables.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Disposables.swift; sourceTree = ""; }; D2138C751BB9BE9800339B5C /* RxCocoa.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = RxCocoa.framework; sourceTree = BUILT_PRODUCTS_DIR; }; D2245A1A1BD5657300E7146F /* WithLatestFrom.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WithLatestFrom.swift; sourceTree = ""; }; D22B6D251BC8504A00BCE0AB /* SkipWhile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SkipWhile.swift; sourceTree = ""; }; @@ -1927,7 +1932,7 @@ C8093C641B8A72BE0088E94D /* Event.swift */, C8093C651B8A72BE0088E94D /* ImmediateSchedulerType.swift */, C8093C681B8A72BE0088E94D /* Observable.swift */, - C8093C671B8A72BE0088E94D /* Observable+Extensions.swift */, + C8093C671B8A72BE0088E94D /* ObservableType+Extensions.swift */, C849BE2A1BAB5D070019AD27 /* ObservableConvertibleType.swift */, C8093C9E1B8A72BE0088E94D /* ObservableType.swift */, C8093CA01B8A72BE0088E94D /* AnyObserver.swift */, @@ -1983,14 +1988,13 @@ C8093C581B8A72BE0088E94D /* DisposeBag.swift */, C8093C591B8A72BE0088E94D /* DisposeBase.swift */, C84CC5661BDD08A500E06A64 /* SubscriptionDisposable.swift */, - C8093C5A1B8A72BE0088E94D /* NAryDisposable.swift */, - C8093C5B1B8A72BE0088E94D /* NAryDisposable.tt */, C8093C5C1B8A72BE0088E94D /* NopDisposable.swift */, CB883B3F1BE24C15000AC2EE /* RefCountDisposable.swift */, C8093C5D1B8A72BE0088E94D /* ScheduledDisposable.swift */, C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */, C8093C601B8A72BE0088E94D /* SingleAssignmentDisposable.swift */, C8093C611B8A72BE0088E94D /* StableCompositeDisposable.swift */, + CDDEF1691D4FB40000CA8546 /* Disposables.swift */, ); path = Disposables; sourceTree = ""; @@ -2379,6 +2383,7 @@ C835090C1C38706D0027C24C /* Observable+BlockingTest.swift */, C835090D1C38706D0027C24C /* Observable+ConcurrencyTest.swift */, C835090E1C38706D0027C24C /* Observable+CreationTest.swift */, + C8E9E42A1D43B26C0049644E /* Observable+DebugTest.swift */, C83509131C38706D0027C24C /* Observable+MultipleTest.swift */, C835090F1C38706D0027C24C /* Observable+MultipleTest+CombineLatest.swift */, C83509101C38706D0027C24C /* Observable+MultipleTest+CombineLatest.tt */, @@ -2524,6 +2529,7 @@ C8A56ACD1AD7424700B4673B = { isa = PBXGroup; children = ( + C8D2C1501D4F3CD6006E2431 /* Rx.playground */, C8093C471B8A72BE0088E94D /* RxSwift */, C8093F571B8A73A20088E94D /* RxBlocking */, C8093E801B8A732E0088E94D /* RxCocoa */, @@ -3134,7 +3140,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0720; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Krunoslav Zaher"; TargetAttributes = { C80938F51B8A71760088E94D = { @@ -3556,6 +3562,7 @@ C83509531C38706E0027C24C /* Observable+AggregateTest.swift in Sources */, C8B290891C94D64600E923D0 /* RxTest+Controls.swift in Sources */, C83509291C38706E0027C24C /* PerformanceTools.swift in Sources */, + C8E9E42B1D43B26C0049644E /* Observable+DebugTest.swift in Sources */, C835096A1C38706E0027C24C /* TestErrors.swift in Sources */, 1AF67DA61CED430100C310FA /* ReplaySubjectTest.swift in Sources */, C83509561C38706E0027C24C /* Observable+ConcurrencyTest.swift in Sources */, @@ -3660,6 +3667,7 @@ C83509EC1C3875580027C24C /* MockDisposable.swift in Sources */, 1AF67DA31CED427D00C310FA /* PublishSubjectTest.swift in Sources */, C8350A111C38756A0027C24C /* Observable+SingleTest.swift in Sources */, + C8E9E42C1D43B26C0049644E /* Observable+DebugTest.swift in Sources */, C8350A2A1C3875B50027C24C /* RxMutableBox.swift in Sources */, C8350A151C38756A0027C24C /* ObserverTests.swift in Sources */, C83509B11C3874E20027C24C /* PerformanceTools.swift in Sources */, @@ -3729,6 +3737,7 @@ C8350A071C38755E0027C24C /* MainSchedulerTests.swift in Sources */, C83509B81C38750D0027C24C /* ControlEventTests.swift in Sources */, C83509CB1C3875230027C24C /* KVOObservableTests.swift in Sources */, + C8E9E42D1D43B26C0049644E /* Observable+DebugTest.swift in Sources */, C83509AD1C3874D70027C24C /* Foundation+Extensions.swift in Sources */, C83509C81C3875230027C24C /* DelegateProxyTest.swift in Sources */, C8350A0D1C38755E0027C24C /* Observable+MultipleTest+CombineLatest.swift in Sources */, @@ -3833,7 +3842,7 @@ C8093DA41B8A72BE0088E94D /* ReplaySubject.swift in Sources */, C8C3D9FF1B935EDF004D233E /* Zip+CollectionType.swift in Sources */, C8093D641B8A72BE0088E94D /* Observable+Time.swift in Sources */, - C8093CFC1B8A72BE0088E94D /* Observable+Extensions.swift in Sources */, + C8093CFC1B8A72BE0088E94D /* ObservableType+Extensions.swift in Sources */, C8093D4A1B8A72BE0088E94D /* Throttle.swift in Sources */, C8B145011BD2D80100267DCE /* ImmediateScheduler.swift in Sources */, C8093D061B8A72BE0088E94D /* Catch.swift in Sources */, @@ -3909,6 +3918,7 @@ C8093D9E1B8A72BE0088E94D /* SerialDispatchQueueScheduler.swift in Sources */, C8093D341B8A72BE0088E94D /* RefCount.swift in Sources */, C8093D0E1B8A72BE0088E94D /* Concat.swift in Sources */, + CDDEF16B1D4FB40000CA8546 /* Disposables.swift in Sources */, C8093CCA1B8A72BE0088E94D /* Lock.swift in Sources */, C8093D441B8A72BE0088E94D /* Take.swift in Sources */, C84CC5591BDCF51200E06A64 /* SynchronizedSubscribeType.swift in Sources */, @@ -3933,7 +3943,6 @@ CBEE77201BD649A000AD584C /* ToArray.swift in Sources */, C8093CFE1B8A72BE0088E94D /* Observable.swift in Sources */, C84CC55E1BDD010800E06A64 /* SynchronizedUnsubscribeType.swift in Sources */, - C8093CE21B8A72BE0088E94D /* NAryDisposable.swift in Sources */, C8093CEC1B8A72BE0088E94D /* SerialDisposable.swift in Sources */, C8C3DA0D1B93959F004D233E /* Never.swift in Sources */, C84CC5681BDD08A500E06A64 /* SubscriptionDisposable.swift in Sources */, @@ -4055,7 +4064,7 @@ C8093DA31B8A72BE0088E94D /* ReplaySubject.swift in Sources */, C8C3D9FE1B935EDF004D233E /* Zip+CollectionType.swift in Sources */, C8093D631B8A72BE0088E94D /* Observable+Time.swift in Sources */, - C8093CFB1B8A72BE0088E94D /* Observable+Extensions.swift in Sources */, + C8093CFB1B8A72BE0088E94D /* ObservableType+Extensions.swift in Sources */, C8093D491B8A72BE0088E94D /* Throttle.swift in Sources */, C8B145001BD2D80100267DCE /* ImmediateScheduler.swift in Sources */, C8093D051B8A72BE0088E94D /* Catch.swift in Sources */, @@ -4132,6 +4141,7 @@ C8093D9D1B8A72BE0088E94D /* SerialDispatchQueueScheduler.swift in Sources */, C8093D331B8A72BE0088E94D /* RefCount.swift in Sources */, C8093D0D1B8A72BE0088E94D /* Concat.swift in Sources */, + CDDEF16A1D4FB40000CA8546 /* Disposables.swift in Sources */, C8093CC91B8A72BE0088E94D /* Lock.swift in Sources */, C8093D431B8A72BE0088E94D /* Take.swift in Sources */, C84CC5581BDCF51200E06A64 /* SynchronizedSubscribeType.swift in Sources */, @@ -4156,7 +4166,6 @@ CBEE771F1BD649A000AD584C /* ToArray.swift in Sources */, C8093CFD1B8A72BE0088E94D /* Observable.swift in Sources */, C84CC55D1BDD010800E06A64 /* SynchronizedUnsubscribeType.swift in Sources */, - C8093CE11B8A72BE0088E94D /* NAryDisposable.swift in Sources */, C8093CEB1B8A72BE0088E94D /* SerialDisposable.swift in Sources */, C8C3DA0C1B93959F004D233E /* Never.swift in Sources */, C84CC5671BDD08A500E06A64 /* SubscriptionDisposable.swift in Sources */, @@ -4203,7 +4212,7 @@ C8F0BFA61BBBFB8B001B112F /* ReplaySubject.swift in Sources */, C8F0BFA71BBBFB8B001B112F /* Zip+CollectionType.swift in Sources */, C8F0BFA81BBBFB8B001B112F /* Observable+Time.swift in Sources */, - C8F0BFA91BBBFB8B001B112F /* Observable+Extensions.swift in Sources */, + C8F0BFA91BBBFB8B001B112F /* ObservableType+Extensions.swift in Sources */, C8F0BFAA1BBBFB8B001B112F /* Throttle.swift in Sources */, C8B145031BD2D80100267DCE /* ImmediateScheduler.swift in Sources */, C8F0BFAC1BBBFB8B001B112F /* Catch.swift in Sources */, @@ -4279,6 +4288,7 @@ C8F0BFE01BBBFB8B001B112F /* SerialDispatchQueueScheduler.swift in Sources */, C8F0BFE11BBBFB8B001B112F /* RefCount.swift in Sources */, C8F0BFE21BBBFB8B001B112F /* Concat.swift in Sources */, + CDDEF16D1D4FB40000CA8546 /* Disposables.swift in Sources */, C8F0BFE31BBBFB8B001B112F /* Lock.swift in Sources */, C8F0BFE41BBBFB8B001B112F /* Take.swift in Sources */, C84CC55B1BDCF51200E06A64 /* SynchronizedSubscribeType.swift in Sources */, @@ -4303,7 +4313,6 @@ CBEE77221BD649A000AD584C /* ToArray.swift in Sources */, C8F0BFF41BBBFB8B001B112F /* Observable.swift in Sources */, C84CC5601BDD010800E06A64 /* SynchronizedUnsubscribeType.swift in Sources */, - C8F0BFF51BBBFB8B001B112F /* NAryDisposable.swift in Sources */, C8F0BFF61BBBFB8B001B112F /* SerialDisposable.swift in Sources */, C8F0BFF71BBBFB8B001B112F /* Never.swift in Sources */, C84CC56A1BDD08A500E06A64 /* SubscriptionDisposable.swift in Sources */, @@ -4368,6 +4377,7 @@ C8F0C0261BBBFBB9001B112F /* _RXDelegateProxy.m in Sources */, C8F0C0271BBBFBB9001B112F /* NSObject+Rx.swift in Sources */, 9BA1CBFE1C0F84C40044B50A /* UIActivityIndicatorView+Rx.swift in Sources */, + 87379AE01D61C6F50047CA88 /* Reactive.swift in Sources */, 842A5A2E1C357F94003568D5 /* NSTextStorage+Rx.swift in Sources */, C8F0C0281BBBFBB9001B112F /* RxTextViewDelegateProxy.swift in Sources */, C8F0C0291BBBFBB9001B112F /* UIBarButtonItem+Rx.swift in Sources */, @@ -4597,7 +4607,6 @@ D2EBEAF61BB9B6B2003A27DC /* NopDisposable.swift in Sources */, CB30D9EB1BF0E3500084C1C0 /* SingleAsync.swift in Sources */, D2EBEAFF1BB9B6BA003A27DC /* Buffer.swift in Sources */, - D2EBEAF51BB9B6AE003A27DC /* NAryDisposable.swift in Sources */, D2EBEB1D1BB9B6C1003A27DC /* Scan.swift in Sources */, D2EBEB261BB9B6C1003A27DC /* Throttle.swift in Sources */, D2EBEAE81BB9B697003A27DC /* Rx.swift in Sources */, @@ -4613,7 +4622,7 @@ D2EBEAE91BB9B697003A27DC /* RxMutableBox.swift in Sources */, D2EBEAFC1BB9B6BA003A27DC /* Amb.swift in Sources */, D2EBEB231BB9B6C1003A27DC /* Take.swift in Sources */, - D2EBEAE31BB9B697003A27DC /* Observable+Extensions.swift in Sources */, + D2EBEAE31BB9B697003A27DC /* ObservableType+Extensions.swift in Sources */, B1D899911BF653410027B05C /* Timeout.swift in Sources */, D2EBEB121BB9B6C1003A27DC /* Merge.swift in Sources */, D2EBEAEF1BB9B6A4003A27DC /* Queue.swift in Sources */, @@ -4621,6 +4630,7 @@ D2EBEB2B1BB9B6CA003A27DC /* Observable+Aggregate.swift in Sources */, D2EBEB291BB9B6C1003A27DC /* Zip+arity.swift in Sources */, D2EBEB241BB9B6C1003A27DC /* TakeUntil.swift in Sources */, + CDDEF16C1D4FB40000CA8546 /* Disposables.swift in Sources */, C84CC55A1BDCF51200E06A64 /* SynchronizedSubscribeType.swift in Sources */, D2EBEB3B1BB9B6D8003A27DC /* OperationQueueScheduler.swift in Sources */, D2EBEAE51BB9B697003A27DC /* AnyObserver.swift in Sources */, @@ -5235,8 +5245,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -5630,8 +5642,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -5687,8 +5701,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; diff --git a/RxBlocking.podspec b/RxBlocking.podspec index 08bc648a..5c1906b1 100644 --- a/RxBlocking.podspec +++ b/RxBlocking.podspec @@ -18,7 +18,7 @@ Waiting for observable sequence to complete before exiting command line applicat s.requires_arc = true s.ios.deployment_target = '8.0' - s.osx.deployment_target = '10.9' + s.osx.deployment_target = '10.10' s.watchos.deployment_target = '2.0' s.tvos.deployment_target = '9.0' diff --git a/RxBlocking/BlockingObservable+Operators.swift b/RxBlocking/BlockingObservable+Operators.swift index faf5f025..3df54e5e 100644 --- a/RxBlocking/BlockingObservable+Operators.swift +++ b/RxBlocking/BlockingObservable+Operators.swift @@ -22,7 +22,7 @@ extension BlockingObservable { public func toArray() throws -> [E] { var elements: [E] = Array() - var error: ErrorProtocol? + var error: Swift.Error? let lock = RunLoopLock() @@ -30,7 +30,7 @@ extension BlockingObservable { lock.dispatch { d.disposable = self.source.subscribe { e in - if d.disposed { + if d.isDisposed { return } switch e { @@ -70,7 +70,7 @@ extension BlockingObservable { public func first() throws -> E? { var element: E? - var error: ErrorProtocol? + var error: Swift.Error? let d = SingleAssignmentDisposable() @@ -78,7 +78,7 @@ extension BlockingObservable { lock.dispatch { d.disposable = self.source.subscribe { e in - if d.disposed { + if d.isDisposed { return } @@ -122,7 +122,7 @@ extension BlockingObservable { public func last() throws -> E? { var element: E? - var error: ErrorProtocol? + var error: Swift.Error? let d = SingleAssignmentDisposable() @@ -130,7 +130,7 @@ extension BlockingObservable { lock.dispatch { d.disposable = self.source.subscribe { e in - if d.disposed { + if d.isDisposed { return } switch e { @@ -183,7 +183,7 @@ extension BlockingObservable { public func single(_ predicate: (E) throws -> Bool) throws -> E? { var element: E? - var error: ErrorProtocol? + var error: Swift.Error? let d = SingleAssignmentDisposable() @@ -191,7 +191,7 @@ extension BlockingObservable { lock.dispatch { d.disposable = self.source.subscribe { e in - if d.disposed { + if d.isDisposed { return } switch e { diff --git a/RxBlocking/RunLoopLock.swift b/RxBlocking/RunLoopLock.swift index 8b5eec73..6112ae88 100644 --- a/RxBlocking/RunLoopLock.swift +++ b/RxBlocking/RunLoopLock.swift @@ -43,7 +43,7 @@ class RunLoopLock { if CurrentThreadScheduler.isScheduleRequired { _ = CurrentThreadScheduler.instance.schedule(()) { _ in action() - return NopDisposable.instance + return Disposables.create() } } else { diff --git a/RxCocoa.podspec b/RxCocoa.podspec index 6a5eb53b..ecc48c8d 100644 --- a/RxCocoa.podspec +++ b/RxCocoa.podspec @@ -15,7 +15,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.ios.deployment_target = '8.0' - s.osx.deployment_target = '10.9' + s.osx.deployment_target = '10.10' s.watchos.deployment_target = '2.0' s.tvos.deployment_target = '9.0' diff --git a/RxCocoa/Common/CocoaUnits/Driver/Driver+Operators.swift b/RxCocoa/Common/CocoaUnits/Driver/Driver+Operators.swift index ea428d94..2438a8d8 100644 --- a/RxCocoa/Common/CocoaUnits/Driver/Driver+Operators.swift +++ b/RxCocoa/Common/CocoaUnits/Driver/Driver+Operators.swift @@ -120,6 +120,7 @@ extension DriverConvertibleType { - returns: The source sequence with the side-effecting behavior applied. */ // @warn_unused_result(message:"http://git.io/rxs.uo") + @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") public func doOn(_ eventHandler: (Event) -> Void) -> Driver { let source = self.asObservable() @@ -137,7 +138,8 @@ extension DriverConvertibleType { - returns: The source sequence with the side-effecting behavior applied. */ // @warn_unused_result(message:"http://git.io/rxs.uo") - public func doOn(onNext: ((E) -> Void)? = nil, onError: ((ErrorProtocol) -> Void)? = nil, onCompleted: (() -> Void)? = nil) + @available(*, deprecated, renamed: "do(onNext:onError:onCompleted:)") + public func doOn(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil) -> Driver { let source = self.asObservable() .doOn(onNext: onNext, onError: onError, onCompleted: onCompleted) @@ -152,9 +154,10 @@ extension DriverConvertibleType { - returns: The source sequence with the side-effecting behavior applied. */ // @warn_unused_result(message:"http://git.io/rxs.uo") - public func `do`(onNext: ((E) -> Void)) + @available(*, deprecated, renamed: "do(onNext:)") + public func doOnNext(_ onNext: ((E) -> Void)) -> Driver { - return self.doOn(onNext: onNext) + return self.do(onNext: onNext) } /** @@ -164,9 +167,27 @@ extension DriverConvertibleType { - returns: The source sequence with the side-effecting behavior applied. */ // @warn_unused_result(message:"http://git.io/rxs.uo") - public func `do`(onCompleted: (() -> Void)) + @available(*, deprecated, renamed: "do(onCompleted:)") + public func doOnCompleted(_ onCompleted: (() -> Void)) -> Driver { - return self.doOn(onCompleted: onCompleted) + return self.do(onCompleted: onCompleted) + } + + /** + Invokes an action for each event in the observable sequence, and propagates all observer messages through the result sequence. + + - parameter onNext: Action to invoke for each element in the observable sequence. + - parameter onError: Action to invoke upon errored termination of the observable sequence. This callback will never be invoked since driver can't error out. + - parameter onCompleted: Action to invoke upon graceful termination of the observable sequence. + - returns: The source sequence with the side-effecting behavior applied. + */ + // @warn_unused_result(message:"http://git.io/rxs.uo") + public func `do`(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil) + -> Driver { + let source = self.asObservable() + .doOn(onNext: onNext, onError: onError, onCompleted: onCompleted) + + return Driver(source) } } diff --git a/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift b/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift index 9f15a343..e62982b6 100644 --- a/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift +++ b/RxCocoa/Common/CocoaUnits/Driver/Driver+Subscription.swift @@ -105,9 +105,10 @@ extension DriverConvertibleType { - returns: Subscription object used to unsubscribe from the observable sequence. */ // @warn_unused_result(message:"http://git.io/rxs.ud") + @available(*, deprecated, renamed: "drive(onNext:)") public func driveNext(_ onNext: (E) -> Void) -> Disposable { MainScheduler.ensureExecutingOnScheduler(errorMessage: driverErrorMessage) - return self.asObservable().subscribeNext(onNext) + return self.asObservable().subscribe(onNext: onNext) } } diff --git a/RxCocoa/Common/CocoaUnits/Driver/Driver.swift b/RxCocoa/Common/CocoaUnits/Driver/Driver.swift index 0844fe1d..67a82d97 100644 --- a/RxCocoa/Common/CocoaUnits/Driver/Driver.swift +++ b/RxCocoa/Common/CocoaUnits/Driver/Driver.swift @@ -145,7 +145,7 @@ extension Driver { */ // @warn_unused_result(message:"http://git.io/rxs.uo") public static func of(_ elements: E ...) -> Driver { - let source = elements.toObservable(driverSubscribeOnScheduler) + let source = Observable.from(elements, scheduler: driverSubscribeOnScheduler) return Driver(raw: source) } } diff --git a/RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift b/RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift index 4ccfc56e..455bdff1 100644 --- a/RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift +++ b/RxCocoa/Common/CocoaUnits/Driver/ObservableConvertibleType+Driver.swift @@ -51,7 +51,7 @@ extension ObservableConvertibleType { - returns: Driving observable sequence. */ // @warn_unused_result(message:"http://git.io/rxs.uo") - public func asDriver(onErrorRecover: (error: ErrorProtocol) -> Driver) -> Driver { + public func asDriver(onErrorRecover: (error: Swift.Error) -> Driver) -> Driver { let source = self .asObservable() .observeOn(driverObserveOnScheduler) diff --git a/RxCocoa/Common/DelegateProxyType.swift b/RxCocoa/Common/DelegateProxyType.swift index 7a41fc08..3a37f28a 100644 --- a/RxCocoa/Common/DelegateProxyType.swift +++ b/RxCocoa/Common/DelegateProxyType.swift @@ -178,14 +178,14 @@ extension DelegateProxyType { let maybeProxy = Self.assignedProxyFor(object) as? Self let proxy: Self - if maybeProxy == nil { + if let existingProxy = maybeProxy { + proxy = existingProxy + } + else { proxy = Self.createProxyForObject(object) as! Self Self.assignProxy(proxy, toObject: object) assert(Self.assignedProxyFor(object) === proxy) } - else { - proxy = maybeProxy! - } let currentDelegate: AnyObject? = Self.currentDelegateFor(object) @@ -228,7 +228,7 @@ extension DelegateProxyType { assert(proxy.forwardToDelegate() === forwardDelegate, "Setting of delegate failed") - return AnonymousDisposable { + return Disposables.create { MainScheduler.ensureExecutingOnScheduler() let delegate: AnyObject? = weakForwardDelegate @@ -241,7 +241,7 @@ extension DelegateProxyType { } extension ObservableType { - func subscribeProxyDataSourceForObject(_ object: AnyObject, dataSource: AnyObject, retainDataSource: Bool, binding: (P, Event) -> Void) + func subscribeProxyDataSource(ofObject object: AnyObject, dataSource: AnyObject, retainDataSource: Bool, binding: (P, Event) -> Void) -> Disposable { let proxy = P.proxyForObject(object) let disposable = P.installForwardDelegate(dataSource, retainDelegate: retainDataSource, onProxyForObject: object) @@ -273,6 +273,6 @@ extension ObservableType { } } - return CompositeDisposable(subscription, disposable) + return Disposables.create(subscription, disposable) } } diff --git a/RxCocoa/Common/Observables/Implementations/KVOObservable.swift b/RxCocoa/Common/Observables/Implementations/KVOObservable.swift index 95762a3c..b45516b4 100644 --- a/RxCocoa/Common/Observables/Implementations/KVOObservable.swift +++ b/RxCocoa/Common/Observables/Implementations/KVOObservable.swift @@ -42,7 +42,7 @@ class KVOObservable observer.on(.next(value as? Element)) } - return AnonymousDisposable(observer.dispose) + return Disposables.create(with: observer.dispose) } } diff --git a/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift b/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift index 01809544..23f1f533 100644 --- a/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift +++ b/RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift @@ -26,7 +26,7 @@ extension Reactive where Base: NotificationCenter { observer.on(.next(notification)) } - return AnonymousDisposable { + return Disposables.create { self.base.removeObserver(nsObserver) } } diff --git a/RxCocoa/Common/Observables/NSURLSession+Rx.swift b/RxCocoa/Common/Observables/NSURLSession+Rx.swift index 4c520f09..d97fa0c1 100644 --- a/RxCocoa/Common/Observables/NSURLSession+Rx.swift +++ b/RxCocoa/Common/Observables/NSURLSession+Rx.swift @@ -15,7 +15,7 @@ import RxSwift RxCocoa URL errors. */ public enum RxCocoaURLError - : ErrorProtocol + : Swift.Error , CustomDebugStringConvertible { /** Unknown error occurred. @@ -32,7 +32,7 @@ public enum RxCocoaURLError /** Deserialization error. */ - case deserializationError(error: ErrorProtocol) + case deserializationError(error: Swift.Error) } public extension RxCocoaURLError { @@ -155,7 +155,7 @@ extension Reactive where Base: URLSession { let t = task t.resume() - return AnonymousDisposable(task.cancel) + return Disposables.create(with: task.cancel) } } diff --git a/RxCocoa/Common/RxCocoa.swift b/RxCocoa/Common/RxCocoa.swift index bf27d498..1ab1937f 100644 --- a/RxCocoa/Common/RxCocoa.swift +++ b/RxCocoa/Common/RxCocoa.swift @@ -18,7 +18,7 @@ import RxSwift RxCocoa errors. */ public enum RxCocoaError - : ErrorProtocol + : Swift.Error , CustomDebugStringConvertible { /** Unknown error has occurred. @@ -69,7 +69,7 @@ public enum RxCocoaInterceptionMechanism { RxCocoa ObjC runtime modification errors. */ public enum RxCocoaObjCRuntimeError - : ErrorProtocol + : Swift.Error , CustomDebugStringConvertible { /** Unknown error has occurred. @@ -193,23 +193,23 @@ public extension RxCocoaObjCRuntimeError { switch self { case let .unknown(target): return "Unknown error occurred.\nTarget: `\(target)`" - case let objectMessagesAlreadyBeingIntercepted(target, interceptionMechanism): + case let .objectMessagesAlreadyBeingIntercepted(target, interceptionMechanism): let interceptionMechanismDescription = interceptionMechanism == .kvo ? "KVO" : "other interception mechanism" return "Collision between RxCocoa interception mechanism and \(interceptionMechanismDescription)." + " To resolve this conflict please use this interception mechanism first.\nTarget: \(target)" - case let selectorNotImplemented(target): + case let .selectorNotImplemented(target): return "Trying to observe messages for selector that isn't implemented.\nTarget: \(target)" - case let cantInterceptCoreFoundationTollFreeBridgedObjects(target): + case let .cantInterceptCoreFoundationTollFreeBridgedObjects(target): return "Interception of messages sent to Core Foundation isn't supported.\nTarget: \(target)" - case let threadingCollisionWithOtherInterceptionMechanism(target): + case let .threadingCollisionWithOtherInterceptionMechanism(target): return "Detected a conflict while modifying ObjC runtime.\nTarget: \(target)" - case let savingOriginalForwardingMethodFailed(target): + case let .savingOriginalForwardingMethodFailed(target): return "Saving original method implementation failed.\nTarget: \(target)" - case let replacingMethodWithForwardingImplementation(target): + case let .replacingMethodWithForwardingImplementation(target): return "Intercepting a sent message by replacing a method implementation with `_objc_msgForward` failed for some reason.\nTarget: \(target)" - case let observingPerformanceSensitiveMessages(target): + case let .observingPerformanceSensitiveMessages(target): return "Attempt to intercept one of the performance sensitive methods. \nTarget: \(target)" - case let observingMessagesWithUnsupportedReturnType(target): + case let .observingMessagesWithUnsupportedReturnType(target): return "Attempt to intercept a method with unsupported return type. \nTarget: \(target)" } } @@ -219,7 +219,7 @@ public extension RxCocoaObjCRuntimeError { // MARK: Error binding policies -func bindingErrorToInterface(_ error: ErrorProtocol) { +func bindingErrorToInterface(_ error: Swift.Error) { let error = "Binding error to UI: \(error)" #if DEBUG rxFatalError(error) @@ -296,16 +296,18 @@ let delegateNotSet = "Delegate not set" // MARK: Conversions `NSError` > `RxCocoaObjCRuntimeError` -extension NSError { +extension Error { func rxCocoaErrorForTarget(_ target: AnyObject) -> RxCocoaObjCRuntimeError { - if domain == RXObjCRuntimeErrorDomain { - let errorCode = RXObjCRuntimeError(rawValue: self.code) ?? .unknown - + let error = self as NSError + + if error.domain == RXObjCRuntimeErrorDomain { + let errorCode = RXObjCRuntimeError(rawValue: error.code) ?? .unknown + switch errorCode { case .unknown: return .unknown(target: target) case .objectMessagesAlreadyBeingIntercepted: - let isKVO = (self.userInfo[RXObjCRuntimeErrorIsKVOKey] as? NSNumber)?.boolValue ?? false + let isKVO = (error.userInfo[RXObjCRuntimeErrorIsKVOKey] as? NSNumber)?.boolValue ?? false return .objectMessagesAlreadyBeingIntercepted(target: target, interceptionMechanism: isKVO ? .kvo : .unknown) case .selectorNotImplemented: return .selectorNotImplemented(target: target) @@ -323,7 +325,7 @@ extension NSError { return .observingMessagesWithUnsupportedReturnType(target: target) } } - + return RxCocoaObjCRuntimeError.unknown(target: target) } } diff --git a/RxCocoa/OSX/NSControl+Rx.swift b/RxCocoa/OSX/NSControl+Rx.swift index 13a099d9..e57674ff 100644 --- a/RxCocoa/OSX/NSControl+Rx.swift +++ b/RxCocoa/OSX/NSControl+Rx.swift @@ -29,7 +29,7 @@ extension Reactive where Base: NSControl { guard let control = control else { observer.on(.completed) - return NopDisposable.instance + return Disposables.create() } let observer = ControlTarget(control: control) { control in @@ -54,7 +54,7 @@ extension Reactive where Base: NSControl { return Observable.create { [weak weakControl = control] (observer: AnyObserver) in guard let control = weakControl else { observer.on(.completed) - return NopDisposable.instance + return Disposables.create() } observer.on(.next(getter(control))) diff --git a/RxCocoa/OSX/NSImageView+Rx.swift b/RxCocoa/OSX/NSImageView+Rx.swift index 53e973b7..15cbb299 100644 --- a/RxCocoa/OSX/NSImageView+Rx.swift +++ b/RxCocoa/OSX/NSImageView+Rx.swift @@ -18,7 +18,7 @@ extension Reactive where Base: NSImageView { Bindable sink for `image` property. */ public var image: AnyObserver { - return imageAnimated(nil) + return image(transitionType: nil) } /** @@ -26,6 +26,7 @@ extension Reactive where Base: NSImageView { - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) */ + @available(*, deprecated, renamed: "image(transitionType:)") public func imageAnimated(_ transitionType: String?) -> AnyObserver { return UIBindingObserver(UIElement: self.base) { control, value in if let transitionType = transitionType { @@ -43,5 +44,27 @@ extension Reactive where Base: NSImageView { control.image = value }.asObserver() } - + + /** + Bindable sink for `image` property. + + - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) + */ + public func image(transitionType: String? = nil) -> AnyObserver { + return UIBindingObserver(UIElement: self.base) { control, value in + if let transitionType = transitionType { + if value != nil { + let transition = CATransition() + transition.duration = 0.25 + transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + transition.type = transitionType + control.layer?.add(transition, forKey: kCATransition) + } + } + else { + control.layer?.removeAllAnimations() + } + control.image = value + }.asObserver() + } } diff --git a/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift b/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift index 8a4665cf..c23b5090 100644 --- a/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift +++ b/RxCocoa/iOS/Proxies/RxCollectionViewDataSourceProxy.swift @@ -19,8 +19,10 @@ let collectionViewDataSourceNotSet = CollectionViewDataSourceNotSet() class CollectionViewDataSourceNotSet : NSObject , UICollectionViewDataSource { + + func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { - rxAbstractMethodWithMessage(dataSourceNotSet) + return 0 } // The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath: diff --git a/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift b/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift index 9a6b9982..bbc41359 100644 --- a/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift +++ b/RxCocoa/iOS/Proxies/RxTableViewDataSourceProxy.swift @@ -19,12 +19,9 @@ let tableViewDataSourceNotSet = TableViewDataSourceNotSet() class TableViewDataSourceNotSet : NSObject , UITableViewDataSource { - func numberOfSections(in tableView: UITableView) -> Int { - rxAbstractMethodWithMessage(dataSourceNotSet) - } - + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { - rxAbstractMethodWithMessage(dataSourceNotSet) + return 0 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { @@ -59,13 +56,6 @@ public class RxTableViewDataSourceProxy // MARK: delegate - /** - Required delegate method implementation. - */ - public func numberOfSections(in tableView: UITableView) -> Int { - return (_requiredMethodsDataSource ?? tableViewDataSourceNotSet).numberOfSections?(in: tableView) ?? 1 - } - /** Required delegate method implementation. */ diff --git a/RxCocoa/iOS/UIBarButtonItem+Rx.swift b/RxCocoa/iOS/UIBarButtonItem+Rx.swift index 3699574d..bcbf62da 100644 --- a/RxCocoa/iOS/UIBarButtonItem+Rx.swift +++ b/RxCocoa/iOS/UIBarButtonItem+Rx.swift @@ -34,7 +34,7 @@ extension Reactive where Base: UIBarButtonItem { Observable.create { [weak control = self.base] observer in guard let control = control else { observer.on(.completed) - return NopDisposable.instance + return Disposables.create() } let target = BarButtonItemTarget(barButtonItem: control) { observer.on(.next()) diff --git a/RxCocoa/iOS/UICollectionView+Rx.swift b/RxCocoa/iOS/UICollectionView+Rx.swift index 99a3a950..987485af 100644 --- a/RxCocoa/iOS/UICollectionView+Rx.swift +++ b/RxCocoa/iOS/UICollectionView+Rx.swift @@ -42,6 +42,7 @@ extension Reactive where Base: UICollectionView { } .addDisposableTo(disposeBag) */ + @available(*, deprecated, renamed: "items(source:cellFactory:)") public func itemsWithCellFactory (_ source: O) -> (cellFactory: (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell) @@ -56,6 +57,41 @@ extension Reactive where Base: UICollectionView { /** Binds sequences of elements to collection view items. + - parameter source: Observable sequence of items. + - parameter cellFactory: Transform between sequence elements and view cells. + - returns: Disposable object that can be used to unbind. + + Example + + let items = Observable.just([ + 1, + 2, + 3 + ]) + + items + .bindTo(collectionView.rx.items) { (collectionView, row, element) in + let indexPath = IndexPath(forItem: row, inSection: 0) + let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell + cell.value?.text = "\(element) @ \(row)" + return cell + } + .addDisposableTo(disposeBag) + */ + public func items + (source: O) + -> (cellFactory: (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell) + -> Disposable { + return { cellFactory in + let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper(cellFactory: cellFactory) + return self.items(dataSource: dataSource)(source: source) + } + + } + + /** + Binds sequences of elements to collection view items. + - parameter cellIdentifier: Identifier used to dequeue cells. - parameter source: Observable sequence of items. - parameter configureCell: Transform between sequence elements and view cells. @@ -76,6 +112,7 @@ extension Reactive where Base: UICollectionView { } .addDisposableTo(disposeBag) */ + @available(*, deprecated, renamed: "items(cellIdentifier:cellType:source:configureCell:)") public func itemsWithCellIdentifier (_ cellIdentifier: String, cellType: Cell.Type = Cell.self) -> (source: O) @@ -94,6 +131,49 @@ extension Reactive where Base: UICollectionView { } } } + + /** + Binds sequences of elements to collection view items. + + - parameter cellIdentifier: Identifier used to dequeue cells. + - parameter source: Observable sequence of items. + - parameter configureCell: Transform between sequence elements and view cells. + - parameter cellType: Type of table view cell. + - returns: Disposable object that can be used to unbind. + + Example + + let items = Observable.just([ + 1, + 2, + 3 + ]) + + items + .bindTo(collectionView.rx.items(cellIdentifier: "Cell", cellType: NumberCell.self)) { (row, element, cell) in + cell.value?.text = "\(element) @ \(row)" + } + .addDisposableTo(disposeBag) + */ + public func items + (cellIdentifier: String, cellType: Cell.Type = Cell.self) + -> (source: O) + -> (configureCell: (Int, S.Iterator.Element, Cell) -> Void) + -> Disposable { + return { source in + return { configureCell in + let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper { (cv, i, item) in + let indexPath = IndexPath(item: i, section: 0) + let cell = cv.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! Cell + configureCell(i, item, cell) + return cell + } + + return self.items(dataSource: dataSource)(source: source) + } + } + } + /** Binds sequences of elements to collection view items using a custom reactive data used to perform the transformation. @@ -134,16 +214,80 @@ extension Reactive where Base: UICollectionView { .bindTo(collectionView.rx.itemsWithDataSource(dataSource)) .addDisposableTo(disposeBag) */ + @available(*, deprecated, renamed: "items(dataSource:source:)") public func itemsWithDataSource< - DataSource: protocol, + DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource, O: ObservableType where DataSource.Element == O.E > (_ dataSource: DataSource) -> (source: O) -> Disposable { return { source in - - return source.subscribeProxyDataSourceForObject(self.base, dataSource: dataSource, retainDataSource: true) { [weak collectionView = self.base] (_: RxCollectionViewDataSourceProxy, event) -> Void in + return source.subscribeProxyDataSource(ofObject: self.base, dataSource: dataSource, retainDataSource: true) { [weak collectionView = self.base] (_: RxCollectionViewDataSourceProxy, event) -> Void in + guard let collectionView = collectionView else { + return + } + dataSource.collectionView(collectionView, observedEvent: event) + } + } + } + + /** + Binds sequences of elements to collection view items using a custom reactive data used to perform the transformation. + + - parameter dataSource: Data source used to transform elements to view cells. + - parameter source: Observable sequence of items. + - returns: Disposable object that can be used to unbind. + + Example + + let dataSource = RxCollectionViewSectionedReloadDataSource>() + + let items = Observable.just([ + SectionModel(model: "First section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Second section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Third section", items: [ + 1.0, + 2.0, + 3.0 + ]) + ]) + + dataSource.configureCell = { (dataSource, cv, indexPath, element) in + let cell = cv.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell + cell.value?.text = "\(element) @ row \(indexPath.row)" + return cell + } + + items + .bindTo(collectionView.rx.items(dataSource: dataSource)) + .addDisposableTo(disposeBag) + */ + public func items< + DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource, + O: ObservableType where DataSource.Element == O.E + > + (dataSource: DataSource) + -> (source: O) + -> Disposable { + return { source in + // This is called for sideeffects only, and to make sure delegate proxy is in place when + // data source is being bound. + // This is needed because theoretically the data source subscription itself might + // call `self.rx_delegate`. If that happens, it might cause weird side effects since + // setting data source will set delegate, and UITableView might get into a weird state. + // Therefore it's better to set delegate proxy first, just to be sure. + _ = self.delegate + // Strong reference is needed because data source is in use until result subscription is disposed + return source.subscribeProxyDataSource(ofObject: self.base, dataSource: dataSource, retainDataSource: true) { [weak collectionView = self.base] (_: RxCollectionViewDataSourceProxy, event) -> Void in guard let collectionView = collectionView else { return } diff --git a/RxCocoa/iOS/UIControl+Rx.swift b/RxCocoa/iOS/UIControl+Rx.swift index 8911628c..39579a4f 100644 --- a/RxCocoa/iOS/UIControl+Rx.swift +++ b/RxCocoa/iOS/UIControl+Rx.swift @@ -45,7 +45,7 @@ extension Reactive where Base: UIControl { guard let control = control else { observer.on(.completed) - return NopDisposable.instance + return Disposables.create() } let controlTarget = ControlTarget(control: control, controlEvents: controlEvents) { @@ -53,9 +53,9 @@ extension Reactive where Base: UIControl { observer.on(.next()) } - return AnonymousDisposable(controlTarget.dispose) + return Disposables.create(with: controlTarget.dispose) }.takeUntil(deallocated) - + return ControlEvent(events: source) } @@ -67,7 +67,7 @@ extension Reactive where Base: UIControl { let source: Observable = Observable.create { [weak weakControl = control] observer in guard let control = weakControl else { observer.on(.completed) - return NopDisposable.instance + return Disposables.create() } observer.on(.next(getter(control))) @@ -78,7 +78,7 @@ extension Reactive where Base: UIControl { } } - return AnonymousDisposable(controlTarget.dispose) + return Disposables.create(with: controlTarget.dispose) } .takeUntil((control as! NSObject).rx.deallocated) diff --git a/RxCocoa/iOS/UIGestureRecognizer+Rx.swift b/RxCocoa/iOS/UIGestureRecognizer+Rx.swift index ae6a84da..4ea5052e 100644 --- a/RxCocoa/iOS/UIGestureRecognizer+Rx.swift +++ b/RxCocoa/iOS/UIGestureRecognizer+Rx.swift @@ -62,7 +62,7 @@ extension Reactive where Base: UIGestureRecognizer { guard let control = control else { observer.on(.completed) - return NopDisposable.instance + return Disposables.create() } let observer = GestureTarget(control) { diff --git a/RxCocoa/iOS/UIImageView+Rx.swift b/RxCocoa/iOS/UIImageView+Rx.swift index a7ea7663..495cc25d 100644 --- a/RxCocoa/iOS/UIImageView+Rx.swift +++ b/RxCocoa/iOS/UIImageView+Rx.swift @@ -20,7 +20,7 @@ extension Reactive where Base: UIImageView { Bindable sink for `image` property. */ public var image: AnyObserver { - return self.imageAnimated(nil) + return image(transitionType: nil) } /** @@ -28,8 +28,32 @@ extension Reactive where Base: UIImageView { - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) */ + @available(*, deprecated, renamed: "image(transitionType:)") public func imageAnimated(_ transitionType: String?) -> AnyObserver { - return UIBindingObserver(UIElement: self.base) { imageView, image in + return UIBindingObserver(UIElement: base) { imageView, image in + if let transitionType = transitionType { + if image != nil { + let transition = CATransition() + transition.duration = 0.25 + transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) + transition.type = transitionType + imageView.layer.add(transition, forKey: kCATransition) + } + } + else { + imageView.layer.removeAllAnimations() + } + imageView.image = image + }.asObserver() + } + + /** + Bindable sink for `image` property. + + - parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...) + */ + public func image(transitionType: String? = nil) -> AnyObserver { + return UIBindingObserver(UIElement: base) { imageView, image in if let transitionType = transitionType { if image != nil { let transition = CATransition() @@ -45,7 +69,6 @@ extension Reactive where Base: UIImageView { imageView.image = image }.asObserver() } - } #endif diff --git a/RxCocoa/iOS/UILabel+Rx.swift b/RxCocoa/iOS/UILabel+Rx.swift index 01d19981..2b8c880e 100644 --- a/RxCocoa/iOS/UILabel+Rx.swift +++ b/RxCocoa/iOS/UILabel+Rx.swift @@ -28,7 +28,7 @@ extension Reactive where Base: UILabel { /** Bindable sink for `attributedText` property. */ - public var attributedText: AnyObserver { + public var attributedText: AnyObserver { return UIBindingObserver(UIElement: self.base) { label, text in label.attributedText = text }.asObserver() diff --git a/RxCocoa/iOS/UITableView+Rx.swift b/RxCocoa/iOS/UITableView+Rx.swift index 20693619..9ed476c9 100644 --- a/RxCocoa/iOS/UITableView+Rx.swift +++ b/RxCocoa/iOS/UITableView+Rx.swift @@ -42,6 +42,7 @@ extension Reactive where Base: UITableView { .addDisposableTo(disposeBag) */ + @available(*, deprecated, renamed: "items(source:cellFactory:)") public func itemsWithCellFactory (_ source: O) -> (cellFactory: (UITableView, Int, S.Iterator.Element) -> UITableViewCell) @@ -49,13 +50,48 @@ extension Reactive where Base: UITableView { return { cellFactory in let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper(cellFactory: cellFactory) - return self.itemsWithDataSource(dataSource)(source: source) + return self.items(dataSource: dataSource)(source: source) } } /** Binds sequences of elements to table view rows. + - parameter source: Observable sequence of items. + - parameter cellFactory: Transform between sequence elements and view cells. + - returns: Disposable object that can be used to unbind. + + Example: + + let items = Observable.just([ + "First Item", + "Second Item", + "Third Item" + ]) + + items + .bindTo(tableView.items) { (tableView, row, element) in + let cell = tableView.dequeueReusableCellWithIdentifier("Cell")! + cell.textLabel?.text = "\(element) @ row \(row)" + return cell + } + .addDisposableTo(disposeBag) + + */ + public func items + (_ source: O) + -> (cellFactory: (UITableView, Int, S.Iterator.Element) -> UITableViewCell) + -> Disposable { + return { cellFactory in + let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper(cellFactory: cellFactory) + + return self.items(dataSource: dataSource)(source: source) + } + } + + /** + Binds sequences of elements to table view rows. + - parameter cellIdentifier: Identifier used to dequeue cells. - parameter source: Observable sequence of items. - parameter configureCell: Transform between sequence elements and view cells. @@ -76,6 +112,7 @@ extension Reactive where Base: UITableView { } .addDisposableTo(disposeBag) */ + @available(*, deprecated, renamed: "items(cellIdentifier:cellType:source:configureCell:)") public func itemsWithCellIdentifier (_ cellIdentifier: String, cellType: Cell.Type = Cell.self) -> (source: O) @@ -93,6 +130,48 @@ extension Reactive where Base: UITableView { } } } + + /** + Binds sequences of elements to table view rows. + + - parameter cellIdentifier: Identifier used to dequeue cells. + - parameter source: Observable sequence of items. + - parameter configureCell: Transform between sequence elements and view cells. + - parameter cellType: Type of table view cell. + - returns: Disposable object that can be used to unbind. + + Example: + + let items = Observable.just([ + "First Item", + "Second Item", + "Third Item" + ]) + + items + .bindTo(tableView.items(cellIdentifier: "Cell", cellType: UITableViewCell.self)) { (row, element, cell) in + cell.textLabel?.text = "\(element) @ row \(row)" + } + .addDisposableTo(disposeBag) + */ + public func items + (cellIdentifier: String, cellType: Cell.Type = Cell.self) + -> (source: O) + -> (configureCell: (Int, S.Iterator.Element, Cell) -> Void) + -> Disposable { + return { source in + return { configureCell in + let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper { (tv, i, item) in + let indexPath = IndexPath(item: i, section: 0) + let cell = tv.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! Cell + configureCell(i, item, cell) + return cell + } + return self.items(dataSource: dataSource)(source: source) + } + } + } + /** Binds sequences of elements to table view rows using a custom reactive data used to perform the transformation. @@ -137,8 +216,9 @@ extension Reactive where Base: UITableView { .bindTo(tableView.rx.itemsWithDataSource(dataSource)) .addDisposableTo(disposeBag) */ + @available(*, deprecated, renamed: "rx_items(dataSource:source:)") public func itemsWithDataSource< - DataSource: protocol, + DataSource: RxTableViewDataSourceType & UITableViewDataSource, O: ObservableType where DataSource.Element == O.E > (_ dataSource: DataSource) @@ -146,7 +226,7 @@ extension Reactive where Base: UITableView { -> Disposable { return { source in // There needs to be a strong retaining here because - return source.subscribeProxyDataSourceForObject(self.base, dataSource: dataSource, retainDataSource: true) { [weak tableView = self.base] (_: RxTableViewDataSourceProxy, event) -> Void in + return source.subscribeProxyDataSource(ofObject: self.base, dataSource: dataSource, retainDataSource: true) { [weak tableView = self.base] (_: RxTableViewDataSourceProxy, event) -> Void in guard let tableView = tableView else { return } @@ -154,6 +234,76 @@ extension Reactive where Base: UITableView { } } } + + + /** + Binds sequences of elements to table view rows using a custom reactive data used to perform the transformation. + This method will retain the data source for as long as the subscription isn't disposed (result `Disposable` + being disposed). + In case `source` observable sequence terminates sucessfully, the data source will present latest element + until the subscription isn't disposed. + + - parameter dataSource: Data source used to transform elements to view cells. + - parameter source: Observable sequence of items. + - returns: Disposable object that can be used to unbind. + + Example + + let dataSource = RxTableViewSectionedReloadDataSource>() + + let items = Observable.just([ + SectionModel(model: "First section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Second section", items: [ + 1.0, + 2.0, + 3.0 + ]), + SectionModel(model: "Third section", items: [ + 1.0, + 2.0, + 3.0 + ]) + ]) + + dataSource.configureCell = { (dataSource, tv, indexPath, element) in + let cell = tv.dequeueReusableCellWithIdentifier("Cell")! + cell.textLabel?.text = "\(element) @ row \(indexPath.row)" + return cell + } + + items + .bindTo(tableView.rx.items(dataSource: dataSource)) + .addDisposableTo(disposeBag) + */ + public func items< + DataSource: RxTableViewDataSourceType & UITableViewDataSource, + O: ObservableType where DataSource.Element == O.E + > + (dataSource: DataSource) + -> (source: O) + -> Disposable { + return { source in + // This is called for sideeffects only, and to make sure delegate proxy is in place when + // data source is being bound. + // This is needed because theoretically the data source subscription itself might + // call `self.rx_delegate`. If that happens, it might cause weird side effects since + // setting data source will set delegate, and UITableView might get into a weird state. + // Therefore it's better to set delegate proxy first, just to be sure. + _ = self.delegate + // Strong reference is needed because data source is in use until result subscription is disposed + return source.subscribeProxyDataSource(ofObject: self.base, dataSource: dataSource, retainDataSource: true) { [weak tableView = self.base] (_: RxTableViewDataSourceProxy, event) -> Void in + guard let tableView = tableView else { + return + } + dataSource.tableView(tableView, observedEvent: event) + } + } + } + } extension Reactive where Base: UITableView { @@ -283,7 +433,7 @@ extension Reactive where Base: UITableView { Reactive wrapper for `delegate` message `tableView:willDisplayCell:forRowAtIndexPath:`. */ public var willDisplayCell: ControlEvent { - let source: Observable = self.delegate.observe(#selector(UITableViewDelegate.tableView(_:willDisplay:forRowAt:))) + let source: Observable = self.delegate.observe(#selector(UITableViewDelegate.tableView(_:willDisplay:forRowAt:))) .map { a in return (try castOrThrow(UITableViewCell.self, a[1]), try castOrThrow(IndexPath.self, a[2])) } diff --git a/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift b/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift index 792436c5..76520887 100644 --- a/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift +++ b/RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift @@ -14,9 +14,9 @@ import RxCocoa #endif extension Reactive where Base: UITableView { - @available(*, deprecated:0.7, renamed:"rx_itemsWithDataSource", message:"You can just use normal `rx_itemsWithDataSource` extension.") + @available(*, deprecated:0.7, renamed:"itemsWithDataSource", message:"You can just use normal `rx_itemsWithDataSource` extension.") public func itemsAnimatedWithDataSource< - DataSource: protocol, + DataSource: RxTableViewDataSourceType & UITableViewDataSource, S: Sequence, O: ObservableType where @@ -34,9 +34,9 @@ extension Reactive where Base: UITableView { } extension Reactive where Base: UICollectionView { - @available(*, deprecated:0.7, renamed:"rx_itemsWithDataSource", message:"You can just use normal `rx_itemsWithDataSource` extension.") - public func rx_itemsAnimatedWithDataSource< - DataSource: protocol, + @available(*, deprecated:0.7, renamed:"itemsWithDataSource", message:"You can just use normal `rx_itemsWithDataSource` extension.") + public func itemsAnimatedWithDataSource< + DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource, S: Sequence, O: ObservableType where diff --git a/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift b/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift index c5a50bca..b2466798 100644 --- a/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift +++ b/RxExample/RxDataSources/DataSources/AnimatableSectionModel.swift @@ -8,7 +8,7 @@ import Foundation -public struct AnimatableSectionModel> +public struct AnimatableSectionModel : AnimatableSectionModelType , CustomStringConvertible { public typealias Item = ItemType diff --git a/RxExample/RxDataSources/DataSources/DataSources.swift b/RxExample/RxDataSources/DataSources/DataSources.swift index 4a39cf9a..7a7c7253 100644 --- a/RxExample/RxDataSources/DataSources/DataSources.swift +++ b/RxExample/RxDataSources/DataSources/DataSources.swift @@ -8,7 +8,7 @@ import Foundation -enum RxDataSourceError : ErrorProtocol { +enum RxDataSourceError : Error { case unwrappingOptional case preconditionFailed(message: String) } @@ -22,7 +22,7 @@ func rxPrecondition(_ condition: Bool, _ message: @autoclosure() -> String) thro throw RxDataSourceError.preconditionFailed(message: message()) } -func rxDebugFatalError(_ error: ErrorProtocol) { +func rxDebugFatalError(_ error: Error) { rxDebugFatalError("\(error)") } diff --git a/RxExample/RxDataSources/DataSources/Differentiator.swift b/RxExample/RxDataSources/DataSources/Differentiator.swift index e9979e79..9dcf13df 100644 --- a/RxExample/RxDataSources/DataSources/Differentiator.swift +++ b/RxExample/RxDataSources/DataSources/Differentiator.swift @@ -9,7 +9,7 @@ import Foundation public enum DifferentiatorError - : ErrorProtocol + : Error , CustomDebugStringConvertible { case duplicateItem(item: Any) case duplicateSection(section: Any) @@ -23,7 +23,7 @@ extension DifferentiatorError { return "Duplicate item \(item)" case let .duplicateSection(section): return "Duplicate section \(section)" - case let invalidInitializerImplementation(section, expectedItems, expectedIdentifier): + case let .invalidInitializerImplementation(section, expectedItems, expectedIdentifier): return "Wrong initializer implementation for: \(section)\n" + "Expected it should return items: \(expectedItems)\n" + "Expected it should have id: \(expectedIdentifier)" diff --git a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift index 29829182..856dfd2b 100644 --- a/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift +++ b/RxExample/RxDataSources/DataSources/TableViewSectionedDataSource.swift @@ -72,7 +72,8 @@ public class _TableViewSectionedDataSource public func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { return _rx_tableView(tableView, canMoveRowAtIndexPath: indexPath) } - + + #if os(iOS) func _sectionIndexTitlesForTableView(_ tableView: UITableView) -> [String]? { return nil } @@ -80,7 +81,7 @@ public class _TableViewSectionedDataSource public func sectionIndexTitles(for tableView: UITableView) -> [String]? { return _sectionIndexTitlesForTableView(tableView) } - + func _rx_tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int { return 0 } @@ -88,6 +89,7 @@ public class _TableViewSectionedDataSource public func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int { return _rx_tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index) } + #endif func _rx_tableView(_ tableView: UITableView, moveRowAtIndexPath sourceIndexPath: IndexPath, toIndexPath destinationIndexPath: IndexPath) { } @@ -195,6 +197,7 @@ public class RxTableViewSectionedDataSource public var rowAnimation: UITableViewRowAnimation = .automatic + #if os(iOS) public var sectionIndexTitles: ((RxTableViewSectionedDataSource) -> [String]?)? { didSet { #if DEBUG @@ -209,6 +212,7 @@ public class RxTableViewSectionedDataSource #endif } } + #endif public override init() { super.init() @@ -264,7 +268,8 @@ public class RxTableViewSectionedDataSource override func _rx_tableView(_ tableView: UITableView, moveRowAtIndexPath sourceIndexPath: IndexPath, toIndexPath destinationIndexPath: IndexPath) { self._sectionModels.moveFromSourceIndexPath(sourceIndexPath, destinationIndexPath: destinationIndexPath) } - + + #if os(iOS) override func _sectionIndexTitlesForTableView(_ tableView: UITableView) -> [String]? { guard let titles = sectionIndexTitles?(self) else { return super._sectionIndexTitlesForTableView(tableView) @@ -280,5 +285,5 @@ public class RxTableViewSectionedDataSource return section } - + #endif } diff --git a/RxExample/RxExample-iOSTests/TestScheduler+MarbleTests.swift b/RxExample/RxExample-iOSTests/TestScheduler+MarbleTests.swift index b749c17d..8f41a873 100644 --- a/RxExample/RxExample-iOSTests/TestScheduler+MarbleTests.swift +++ b/RxExample/RxExample-iOSTests/TestScheduler+MarbleTests.swift @@ -41,7 +41,7 @@ extension TestScheduler { - `|` marks sequence completed */ - func parseEventsAndTimes(timeline: String, values: [String: T], errors: [String: ErrorProtocol] = [:]) -> [[Recorded>]] { + func parseEventsAndTimes(timeline: String, values: [String: T], errors: [String: Swift.Error] = [:]) -> [[Recorded>]] { //print("parsing: \(timeline)") typealias RecordedEvent = Recorded> @@ -112,7 +112,7 @@ extension TestScheduler { - returns: Observable sequence specified by timeline and values. */ - func createObservable(timeline: String, values: [String: T], errors: [String: ErrorProtocol] = [:]) -> Observable { + func createObservable(timeline: String, values: [String: T], errors: [String: Swift.Error] = [:]) -> Observable { let events = self.parseEventsAndTimes(timeline: timeline, values: values, errors: errors) return createObservable(events) } @@ -150,13 +150,13 @@ extension TestScheduler { let scheduledEvents = events[attemptCount].map { event in return self.scheduleRelative((), dueTime: resolution * TimeInterval(event.time)) { _ in observer.on(event.value) - return NopDisposable.instance + return Disposables.create() } } attemptCount += 1 - return CompositeDisposable(disposables: scheduledEvents) + return Disposables.create(scheduledEvents) } } @@ -174,7 +174,7 @@ extension TestScheduler { - returns: Implementation of method that accepts arguments with parameter `Arg` and returns observable sequence with parameter `Ret`. */ - func mock(values: [String: Ret], errors: [String: ErrorProtocol] = [:], timelineSelector: (Arg) -> String) -> (Arg) -> Observable { + func mock(values: [String: Ret], errors: [String: Swift.Error] = [:], timelineSelector: (Arg) -> String) -> (Arg) -> Observable { return { (parameters: Arg) -> Observable in let timeline = timelineSelector(parameters) diff --git a/RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift b/RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift index bc17a656..37f50b28 100644 --- a/RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift +++ b/RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift @@ -63,9 +63,9 @@ class APIWrappersViewController: ViewController { // MARK: UIBarButtonItem bbitem.rx.tap - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UIBarButtonItem Tapped") - } + }) .addDisposableTo(disposeBag) // MARK: UISegmentedControl @@ -75,9 +75,9 @@ class APIWrappersViewController: ViewController { _ = segmentedControl.rx.value <-> segmentedValue segmentedValue.asObservable() - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UISegmentedControl value \(x)") - } + }) .addDisposableTo(disposeBag) @@ -88,9 +88,9 @@ class APIWrappersViewController: ViewController { _ = switcher.rx.value <-> switchValue switchValue.asObservable() - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UISwitch value \(x)") - } + }) .addDisposableTo(disposeBag) // MARK: UIActivityIndicatorView @@ -103,9 +103,9 @@ class APIWrappersViewController: ViewController { // MARK: UIButton button.rx.tap - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UIButton Tapped") - } + }) .addDisposableTo(disposeBag) @@ -116,9 +116,9 @@ class APIWrappersViewController: ViewController { _ = slider.rx.value <-> sliderValue sliderValue.asObservable() - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UISlider value \(x)") - } + }) .addDisposableTo(disposeBag) @@ -130,9 +130,9 @@ class APIWrappersViewController: ViewController { dateValue.asObservable() - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UIDatePicker date \(x)") - } + }) .addDisposableTo(disposeBag) @@ -143,18 +143,18 @@ class APIWrappersViewController: ViewController { _ = textField <-> textValue textValue.asObservable() - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UITextField text \(x)") - } + }) .addDisposableTo(disposeBag) // MARK: UIGestureRecognizer mypan.rx.event - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UIGestureRecognizer event \(x.state)") - } + }) .addDisposableTo(disposeBag) @@ -165,9 +165,9 @@ class APIWrappersViewController: ViewController { _ = textView! <-> textViewValue textViewValue.asObservable() - .subscribeNext { [weak self] x in + .subscribe(onNext: { [weak self] x in self?.debug("UITextView text \(x)") - } + }) .addDisposableTo(disposeBag) // MARK: CLLocationManager @@ -177,20 +177,20 @@ class APIWrappersViewController: ViewController { #endif manager.rx.didUpdateLocations - .subscribeNext { x in - print("rx.didUpdateLocations \(x)") - } + .subscribe(onNext: { x in + print("rx_didUpdateLocations \(x)") + }) .addDisposableTo(disposeBag) _ = manager.rx.didFailWithError - .subscribeNext { x in - print("rx.didFailWithError \(x)") - } + .subscribe(onNext: { x in + print("rx_didFailWithError \(x)") + }) manager.rx.didChangeAuthorizationStatus - .subscribeNext { status in + .subscribe(onNext: { status in print("Authorization status \(status)") - } + }) .addDisposableTo(disposeBag) manager.startUpdatingLocation() diff --git a/RxExample/RxExample/Examples/Calculator/CalculatorViewController.swift b/RxExample/RxExample/Examples/Calculator/CalculatorViewController.swift index ee6bd4f5..eac62b22 100644 --- a/RxExample/RxExample/Examples/Calculator/CalculatorViewController.swift +++ b/RxExample/RxExample/Examples/Calculator/CalculatorViewController.swift @@ -69,14 +69,13 @@ class CalculatorViewController: ViewController { nineButton.rx.tap.map { _ in .addNumber("9") } ] - commands - .toObservable() + Observable.from(commands) .merge() .scan(CalculatorState.CLEAR_STATE) { a, x in return a.tranformState(x) } .debug("debugging") - .subscribeNext { [weak self] calState in + .subscribe(onNext: { [weak self] calState in self?.resultLabel.text = calState.inScreen switch calState.action { case .operation(let operation): @@ -93,7 +92,7 @@ class CalculatorViewController: ViewController { default: self?.lastSignLabel.text = "" } - } + }) .addDisposableTo(disposeBag) } diff --git a/RxExample/RxExample/Examples/GeolocationExample/GeolocationViewController.swift b/RxExample/RxExample/Examples/GeolocationExample/GeolocationViewController.swift index b05eafb6..db0b4647 100644 --- a/RxExample/RxExample/Examples/GeolocationExample/GeolocationViewController.swift +++ b/RxExample/RxExample/Examples/GeolocationExample/GeolocationViewController.swift @@ -70,7 +70,7 @@ class GeolocationViewController: ViewController { } private func openAppPreferences() { - UIApplication.shared().openURL(URL(string: UIApplicationOpenSettingsURLString)!) + UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!) } } diff --git a/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift b/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift index f41dc717..4f77dce7 100644 --- a/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift +++ b/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesAPI.swift @@ -195,18 +195,18 @@ extension GitHubSearchRepositoriesAPI { extension GitHubSearchRepositoriesAPI { private static let parseLinksPattern = "\\s*,?\\s*<([^\\>]*)>\\s*;\\s*rel=\"([^\"]*)\"" - private static let linksRegex = try! RegularExpression(pattern: parseLinksPattern, options: [.allowCommentsAndWhitespace]) + private static let linksRegex = try! NSRegularExpression(pattern: parseLinksPattern, options: [.allowCommentsAndWhitespace]) private static func parseLinks(_ links: String) throws -> [String: String] { let length = (links as NSString).length - let matches = GitHubSearchRepositoriesAPI.linksRegex.matches(in: links, options: RegularExpression.MatchingOptions(), range: NSRange(location: 0, length: length)) + let matches = GitHubSearchRepositoriesAPI.linksRegex.matches(in: links, options: NSRegularExpression.MatchingOptions(), range: NSRange(location: 0, length: length)) var result: [String: String] = [:] for m in matches { let matches = (1 ..< m.numberOfRanges).map { rangeIndex -> String in - let range = m.range(at: rangeIndex) + let range = m.rangeAt(rangeIndex) let startIndex = links.characters.index(links.startIndex, offsetBy: range.location) let endIndex = links.characters.index(links.startIndex, offsetBy: range.location + range.length) let stringRange = startIndex ..< endIndex diff --git a/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesViewController.swift b/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesViewController.swift index e2ce5def..083401d5 100644 --- a/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesViewController.swift +++ b/RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesViewController.swift @@ -74,20 +74,20 @@ class GitHubSearchRepositoriesViewController: ViewController, UITableViewDelegat searchResult .map { [SectionModel(model: "Repositories", items: $0.repositories)] } - .drive(tableView.rx.itemsWithDataSource(dataSource)) + .drive(tableView.rx.items(dataSource: dataSource)) .addDisposableTo(disposeBag) searchResult .filter { $0.limitExceeded } - .driveNext { n in + .drive(onNext: { n in showAlert("Exceeded limit of 10 non authenticated requests per minute for GitHub API. Please wait a minute. :(\nhttps://developer.github.com/v3/#rate-limiting") - } + }) .addDisposableTo(disposeBag) // dismiss keyboard on scroll tableView.rx.contentOffset .subscribe { _ in - if self.searchBar.isFirstResponder() { + if self.searchBar.isFirstResponder { _ = self.searchBar.resignFirstResponder() } } @@ -100,7 +100,7 @@ class GitHubSearchRepositoriesViewController: ViewController, UITableViewDelegat // activity indicator in status bar // { GitHubSearchRepositoriesAPI.sharedAPI.activityIndicator - .drive(UIApplication.shared().rx.networkActivityIndicatorVisible) + .drive(UIApplication.shared.rx.networkActivityIndicatorVisible) .addDisposableTo(disposeBag) // } } diff --git a/RxExample/RxExample/Examples/GitHubSignup/BindingExtensions.swift b/RxExample/RxExample/Examples/GitHubSignup/BindingExtensions.swift index 1684e55b..27cd1bb7 100644 --- a/RxExample/RxExample/Examples/GitHubSignup/BindingExtensions.swift +++ b/RxExample/RxExample/Examples/GitHubSignup/BindingExtensions.swift @@ -30,7 +30,7 @@ extension ValidationResult: CustomStringConvertible { struct ValidationColors { static let okColor = UIColor(red: 138.0 / 255.0, green: 221.0 / 255.0, blue: 109.0 / 255.0, alpha: 1.0) - static let errorColor = UIColor.red() + static let errorColor = UIColor.red } extension ValidationResult { @@ -39,9 +39,9 @@ extension ValidationResult { case .ok: return ValidationColors.okColor case .empty: - return UIColor.black() + return UIColor.black case .validating: - return UIColor.black() + return UIColor.black case .failed: return ValidationColors.errorColor } diff --git a/RxExample/RxExample/Examples/GitHubSignup/UsingDriver/GitHubSignupViewController2.swift b/RxExample/RxExample/Examples/GitHubSignup/UsingDriver/GitHubSignupViewController2.swift index 13ac593a..2cf39c97 100644 --- a/RxExample/RxExample/Examples/GitHubSignup/UsingDriver/GitHubSignupViewController2.swift +++ b/RxExample/RxExample/Examples/GitHubSignup/UsingDriver/GitHubSignupViewController2.swift @@ -45,10 +45,10 @@ class GitHubSignupViewController2 : ViewController { // bind results to { viewModel.signupEnabled - .driveNext { [weak self] valid in + .drive(onNext: { [weak self] valid in self?.signupOutlet.isEnabled = valid self?.signupOutlet.alpha = valid ? 1.0 : 0.5 - } + }) .addDisposableTo(disposeBag) viewModel.validatedUsername @@ -68,17 +68,17 @@ class GitHubSignupViewController2 : ViewController { .addDisposableTo(disposeBag) viewModel.signedIn - .driveNext { signedIn in + .drive(onNext: { signedIn in print("User signed in \(signedIn)") - } + }) .addDisposableTo(disposeBag) //} let tapBackground = UITapGestureRecognizer() tapBackground.rx.event - .subscribeNext { [weak self] _ in + .subscribe(onNext: { [weak self] _ in self?.view.endEditing(true) - } + }) .addDisposableTo(disposeBag) view.addGestureRecognizer(tapBackground) } diff --git a/RxExample/RxExample/Examples/GitHubSignup/UsingVanillaObservables/GitHubSignupViewController1.swift b/RxExample/RxExample/Examples/GitHubSignup/UsingVanillaObservables/GitHubSignupViewController1.swift index 0abfed87..5a89b09b 100644 --- a/RxExample/RxExample/Examples/GitHubSignup/UsingVanillaObservables/GitHubSignupViewController1.swift +++ b/RxExample/RxExample/Examples/GitHubSignup/UsingVanillaObservables/GitHubSignupViewController1.swift @@ -45,10 +45,10 @@ class GitHubSignupViewController1 : ViewController { // bind results to { viewModel.signupEnabled - .subscribeNext { [weak self] valid in + .subscribe(onNext: { [weak self] valid in self?.signupOutlet.isEnabled = valid self?.signupOutlet.alpha = valid ? 1.0 : 0.5 - } + }) .addDisposableTo(disposeBag) viewModel.validatedUsername @@ -68,17 +68,17 @@ class GitHubSignupViewController1 : ViewController { .addDisposableTo(disposeBag) viewModel.signedIn - .subscribeNext { signedIn in + .subscribe(onNext: { signedIn in print("User signed in \(signedIn)") - } + }) .addDisposableTo(disposeBag) //} let tapBackground = UITapGestureRecognizer() tapBackground.rx.event - .subscribeNext { [weak self] _ in + .subscribe(onNext: { [weak self] _ in self?.view.endEditing(true) - } + }) .addDisposableTo(disposeBag) view.addGestureRecognizer(tapBackground) } diff --git a/RxExample/RxExample/Examples/ImagePicker/UIImagePickerController+RxCreate.swift b/RxExample/RxExample/Examples/ImagePicker/UIImagePickerController+RxCreate.swift index a3b29424..f4f9f1ba 100644 --- a/RxExample/RxExample/Examples/ImagePicker/UIImagePickerController+RxCreate.swift +++ b/RxExample/RxExample/Examples/ImagePicker/UIImagePickerController+RxCreate.swift @@ -14,7 +14,7 @@ import UIKit #endif func dismissViewController(_ viewController: UIViewController, animated: Bool) { - if viewController.isBeingDismissed() || viewController.isBeingPresented() { + if viewController.isBeingDismissed || viewController.isBeingPresented { DispatchQueue.main.async { dismissViewController(viewController, animated: animated) } @@ -31,9 +31,9 @@ extension Reactive where Base: UIImagePickerController { static func createWithParent(_ parent: UIViewController?, animated: Bool = true, configureImagePicker: (UIImagePickerController) throws -> () = { x in }) -> Observable { return Observable.create { [weak parent] observer in let imagePicker = UIImagePickerController() - let dismissDisposable = imagePicker - .rx.didCancel - .subscribeNext({ [weak imagePicker] in + let dismissDisposable = imagePicker.rx + .didCancel + .subscribe(onNext: { [weak imagePicker] in guard let imagePicker = imagePicker else { return } @@ -45,18 +45,18 @@ extension Reactive where Base: UIImagePickerController { } catch let error { observer.on(.error(error)) - return NopDisposable.instance + return Disposables.create() } guard let parent = parent else { observer.on(.completed) - return NopDisposable.instance + return Disposables.create() } parent.present(imagePicker, animated: animated, completion: nil) observer.on(.next(imagePicker)) - return CompositeDisposable(dismissDisposable, AnonymousDisposable { + return Disposables.create(dismissDisposable, Disposables.create { dismissViewController(imagePicker, animated: animated) }) } diff --git a/RxExample/RxExample/Examples/OSX simple example/IntroductionExampleViewController.swift b/RxExample/RxExample/Examples/OSX simple example/IntroductionExampleViewController.swift index 8dbb60cf..4728b9bd 100644 --- a/RxExample/RxExample/Examples/OSX simple example/IntroductionExampleViewController.swift +++ b/RxExample/RxExample/Examples/OSX simple example/IntroductionExampleViewController.swift @@ -46,35 +46,35 @@ class IntroductionExampleViewController : ViewController { .map { (a, b) in return "\(a) + \(b) = \(a + b)" } - .subscribeNext { result in + .subscribe(onNext: { result in if speech.isSpeaking { speech.stopSpeaking() } speech.startSpeaking(result) - } + }) .addDisposableTo(disposeBag) slider.rx.value - .subscribeNext { value in + .subscribe(onNext: { value in self.sliderValue.stringValue = "\(Int(value))" - } + }) .addDisposableTo(disposeBag) sliderValue.rx.text - .subscribeNext { value in + .subscribe(onNext: { value in let doubleValue = value.toDouble() ?? 0.0 self.slider.doubleValue = doubleValue self.sliderValue.stringValue = "\(Int(doubleValue))" - } + }) .addDisposableTo(disposeBag) disposeButton.rx.tap - .subscribeNext { [weak self] _ in + .subscribe(onNext: { [weak self] _ in print("Unbind everything") self?.disposeBag = DisposeBag() - } + }) .addDisposableTo(disposeBag) } } diff --git a/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift b/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift index 21bafa47..c320eccd 100644 --- a/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift +++ b/RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift @@ -26,24 +26,24 @@ class SimpleTableViewExampleViewController : ViewController { ]) items - .bindTo(tableView.rx.itemsWithCellIdentifier("Cell", cellType: UITableViewCell.self)) { (row, element, cell) in + .bindTo(tableView.rx.items(cellIdentifier: "Cell", cellType: UITableViewCell.self)) { (row, element, cell) in cell.textLabel?.text = "\(element) @ row \(row)" } .addDisposableTo(disposeBag) - tableView - .rx.modelSelected(String.self) - .subscribeNext { value in + tableView.rx + .modelSelected(String.self) + .subscribe(onNext: { value in DefaultWireframe.presentAlert("Tapped `\(value)`") - } + }) .addDisposableTo(disposeBag) - tableView - .rx.itemAccessoryButtonTapped - .subscribeNext { indexPath in + tableView.rx + .itemAccessoryButtonTapped + .subscribe(onNext: { indexPath in DefaultWireframe.presentAlert("Tapped Detail @ \(indexPath.section),\(indexPath.row)") - } + }) .addDisposableTo(disposeBag) } diff --git a/RxExample/RxExample/Examples/SimpleTableViewExampleSectioned/SimpleTableViewExampleSectionedViewController.swift b/RxExample/RxExample/Examples/SimpleTableViewExampleSectioned/SimpleTableViewExampleSectionedViewController.swift index 9f3dc361..7868e856 100644 --- a/RxExample/RxExample/Examples/SimpleTableViewExampleSectioned/SimpleTableViewExampleSectionedViewController.swift +++ b/RxExample/RxExample/Examples/SimpleTableViewExampleSectioned/SimpleTableViewExampleSectionedViewController.swift @@ -50,21 +50,21 @@ class SimpleTableViewExampleSectionedViewController } items - .bindTo(tableView.rx.itemsWithDataSource(dataSource)) + .bindTo(tableView.rx.items(dataSource: dataSource)) .addDisposableTo(disposeBag) - tableView - .rx.itemSelected + tableView.rx + .itemSelected .map { indexPath in return (indexPath, dataSource.itemAtIndexPath(indexPath)) } - .subscribeNext { indexPath, model in + .subscribe(onNext: { indexPath, model in DefaultWireframe.presentAlert("Tapped `\(model)` @ \(indexPath)") - } + }) .addDisposableTo(disposeBag) - tableView - .rx.setDelegate(self) + tableView.rx + .setDelegate(self) .addDisposableTo(disposeBag) } diff --git a/RxExample/RxExample/Examples/SimpleValidation/SimpleValidationViewController.swift b/RxExample/RxExample/Examples/SimpleValidation/SimpleValidationViewController.swift index fb8b8485..db0abe36 100644 --- a/RxExample/RxExample/Examples/SimpleValidation/SimpleValidationViewController.swift +++ b/RxExample/RxExample/Examples/SimpleValidation/SimpleValidationViewController.swift @@ -60,7 +60,7 @@ class SimpleValidationViewController : ViewController { .addDisposableTo(disposeBag) doSomethingOutlet.rx.tap - .subscribeNext { [weak self] in self?.showAlert() } + .subscribe(onNext: { [weak self] in self?.showAlert() }) .addDisposableTo(disposeBag) } diff --git a/RxExample/RxExample/Examples/TableViewPartialUpdates/PartialUpdatesViewController.swift b/RxExample/RxExample/Examples/TableViewPartialUpdates/PartialUpdatesViewController.swift index e6548849..13f30cc5 100644 --- a/RxExample/RxExample/Examples/TableViewPartialUpdates/PartialUpdatesViewController.swift +++ b/RxExample/RxExample/Examples/TableViewPartialUpdates/PartialUpdatesViewController.swift @@ -85,11 +85,11 @@ class PartialUpdatesViewController : ViewController { skinTableViewDataSource(reloadDataSource) self.sections.asObservable() - .bindTo(partialUpdatesTableViewOutlet.rx.itemsWithDataSource(tvAnimatedDataSource)) + .bindTo(partialUpdatesTableViewOutlet.rx.items(dataSource: tvAnimatedDataSource)) .addDisposableTo(disposeBag) self.sections.asObservable() - .bindTo(reloadTableViewOutlet.rx.itemsWithDataSource(reloadDataSource)) + .bindTo(reloadTableViewOutlet.rx.items(dataSource: reloadDataSource)) .addDisposableTo(disposeBag) // Collection view logic works, but when clicking fast because of internal bugs @@ -115,23 +115,23 @@ class PartialUpdatesViewController : ViewController { let cvReloadDataSource = RxCollectionViewSectionedReloadDataSource() skinCollectionViewDataSource(cvReloadDataSource) self.sections.asObservable() - .bindTo(partialUpdatesCollectionViewOutlet.rx.itemsWithDataSource(cvReloadDataSource)) + .bindTo(partialUpdatesCollectionViewOutlet.rx.items(dataSource: cvReloadDataSource)) .addDisposableTo(disposeBag) #endif // touches partialUpdatesCollectionViewOutlet.rx.itemSelected - .subscribeNext { [weak self] i in + .subscribe(onNext: { [weak self] i in print("Let me guess, it's .... It's \(self?.generator.sections[i.section].items[i.item]), isn't it? Yeah, I've got it.") - } + }) .addDisposableTo(disposeBag) Observable.of(partialUpdatesTableViewOutlet.rx.itemSelected, reloadTableViewOutlet.rx.itemSelected) .merge() - .subscribeNext { [weak self] i in + .subscribe(onNext: { [weak self] i in print("I have a feeling it's .... \(self?.generator.sections[i.section].items[i.item])?") - } + }) .addDisposableTo(disposeBag) } diff --git a/RxExample/RxExample/Examples/TableViewWithEditingCommands/TableViewWithEditingCommandsViewController.swift b/RxExample/RxExample/Examples/TableViewWithEditingCommands/TableViewWithEditingCommandsViewController.swift index f7922a35..79fb2e3e 100644 --- a/RxExample/RxExample/Examples/TableViewWithEditingCommands/TableViewWithEditingCommandsViewController.swift +++ b/RxExample/RxExample/Examples/TableViewWithEditingCommands/TableViewWithEditingCommandsViewController.swift @@ -62,7 +62,7 @@ class TableViewWithEditingCommandsViewController: ViewController, UITableViewDel override func viewDidLoad() { super.viewDidLoad() - self.navigationItem.rightBarButtonItem = self.editButtonItem() + self.navigationItem.rightBarButtonItem = self.editButtonItem let superMan = User( firstName: "Super", @@ -107,7 +107,7 @@ class TableViewWithEditingCommandsViewController: ViewController, UITableViewDel SectionModel(model: "Normal Users", items: $0.users) ] } - .bindTo(tableView.rx.itemsWithDataSource(dataSource)) + .bindTo(tableView.rx.items(dataSource: dataSource)) .addDisposableTo(disposeBag) tableView.rx.itemSelected @@ -115,9 +115,9 @@ class TableViewWithEditingCommandsViewController: ViewController, UITableViewDel let all = [viewModel.favoriteUsers, viewModel.users] return all[i.section][i.row] } - .subscribeNext { [weak self] user in + .subscribe(onNext: { [weak self] user in self?.showDetailsForUser(user) - } + }) .addDisposableTo(disposeBag) // customization using delegate @@ -139,8 +139,8 @@ class TableViewWithEditingCommandsViewController: ViewController, UITableViewDel let label = UILabel(frame: CGRect.zero) // hacky I know :) label.text = " \(title)" - label.textColor = UIColor.white() - label.backgroundColor = UIColor.darkGray() + label.textColor = UIColor.white + label.backgroundColor = UIColor.darkGray label.alpha = 0.9 return label diff --git a/RxExample/RxExample/Examples/TableViewWithEditingCommands/UIImageView+Extensions.swift b/RxExample/RxExample/Examples/TableViewWithEditingCommands/UIImageView+Extensions.swift index 79f17aea..553337e8 100644 --- a/RxExample/RxExample/Examples/TableViewWithEditingCommands/UIImageView+Extensions.swift +++ b/RxExample/RxExample/Examples/TableViewWithEditingCommands/UIImageView+Extensions.swift @@ -12,7 +12,7 @@ extension UIImageView { func makeRoundedCorners(_ radius: CGFloat) { self.layer.cornerRadius = self.frame.size.width / 2 - self.layer.borderColor = UIColor.darkGray().cgColor + self.layer.borderColor = UIColor.darkGray.cgColor self.layer.borderWidth = radius self.layer.masksToBounds = true } diff --git a/RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchCell.swift b/RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchCell.swift index 3d2f6270..cf8978ee 100644 --- a/RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchCell.swift +++ b/RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchCell.swift @@ -42,7 +42,7 @@ public class WikipediaSearchCell: UITableViewCell { let reachabilityService = Dependencies.sharedDependencies.reachabilityService viewModel.imageURLs - .drive(self.imagesOutlet.rx.itemsWithCellIdentifier("ImageCell", cellType: CollectionViewImageCell.self)) { [weak self] (_, url, cell) in + .drive(self.imagesOutlet.rx.items(cellIdentifier: "ImageCell", cellType: CollectionViewImageCell.self)) { [weak self] (_, url, cell) in cell.downloadableImage = self?.imageService.imageFromURL(url, reachabilityService: reachabilityService) ?? Observable.empty() } .addDisposableTo(disposeBag) diff --git a/RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchViewController.swift b/RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchViewController.swift index 3023a827..25a85525 100644 --- a/RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchViewController.swift +++ b/RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchViewController.swift @@ -78,7 +78,7 @@ class WikipediaSearchViewController: ViewController { .map { results in results.map(SearchResultViewModel.init) } - .drive(resultsTableView.rx.itemsWithCellIdentifier("WikipediaSearchCell", cellType: WikipediaSearchCell.self)) { (_, viewModel, cell) in + .drive(resultsTableView.rx.items(cellIdentifier: "WikipediaSearchCell", cellType: WikipediaSearchCell.self)) { (_, viewModel, cell) in cell.viewModel = viewModel } .addDisposableTo(disposeBag) @@ -91,13 +91,13 @@ class WikipediaSearchViewController: ViewController { resultsTableView.rx.contentOffset .asDriver() .filter { _ -> Bool in - return !searchController.isBeingPresented() + return !searchController.isBeingPresented } - .driveNext { _ in - if searchBar.isFirstResponder() { + .drive(onNext: { _ in + if searchBar.isFirstResponder { _ = searchBar.resignFirstResponder() } - } + }) .addDisposableTo(disposeBag) } @@ -106,9 +106,9 @@ class WikipediaSearchViewController: ViewController { resultsTableView.rx.modelSelected(SearchResultViewModel.self) .asDriver() - .driveNext { searchResult in + .drive(onNext: { searchResult in wireframe.open(url:searchResult.searchResult.URL) - } + }) .addDisposableTo(disposeBag) } @@ -118,7 +118,7 @@ class WikipediaSearchViewController: ViewController { DefaultImageService.sharedImageService.loadingImage ) { $0 || $1 } .distinctUntilChanged() - .drive(UIApplication.shared().rx.networkActivityIndicatorVisible) + .drive(UIApplication.shared.rx.networkActivityIndicatorVisible) .addDisposableTo(disposeBag) } } diff --git a/RxExample/RxExample/OSX/Main.storyboard b/RxExample/RxExample/OSX/Main.storyboard index 64e20818..3b0674fc 100644 --- a/RxExample/RxExample/OSX/Main.storyboard +++ b/RxExample/RxExample/OSX/Main.storyboard @@ -1,7 +1,7 @@ - + - + @@ -88,8 +88,8 @@ - - + + @@ -99,8 +99,8 @@ -