Merge branch 'swift-3.0' into swift-3.0-removing-rx_-prefix

Conflicts:
	RxCocoa/Common/Observables/NSNotificationCenter+Rx.swift
	RxCocoa/OSX/NSImageView+Rx.swift
	RxCocoa/iOS/UICollectionView+Rx.swift
	RxCocoa/iOS/UIControl+Rx.swift
	RxCocoa/iOS/UIImageView+Rx.swift
	RxCocoa/iOS/UILabel+Rx.swift
	RxCocoa/iOS/UITableView+Rx.swift
	RxExample/RxDataSources/DataSources+Rx/UISectionedViewType+RxAnimatedDataSource.swift
	RxExample/RxExample/Examples/APIWrappers/APIWrappersViewController.swift
	RxExample/RxExample/Examples/GitHubSearchRepositories/GitHubSearchRepositoriesViewController.swift
	RxExample/RxExample/Examples/GitHubSignup/UsingDriver/GitHubSignupViewController2.swift
	RxExample/RxExample/Examples/GitHubSignup/UsingVanillaObservables/GitHubSignupViewController1.swift
	RxExample/RxExample/Examples/ImagePicker/UIImagePickerController+RxCreate.swift
	RxExample/RxExample/Examples/OSX simple example/IntroductionExampleViewController.swift
	RxExample/RxExample/Examples/SimpleTableViewExample/SimpleTableViewExampleViewController.swift
	RxExample/RxExample/Examples/SimpleTableViewExampleSectioned/SimpleTableViewExampleSectionedViewController.swift
	RxExample/RxExample/Examples/SimpleValidation/SimpleValidationViewController.swift
	RxExample/RxExample/Examples/TableViewPartialUpdates/PartialUpdatesViewController.swift
	RxExample/RxExample/Examples/TableViewWithEditingCommands/TableViewWithEditingCommandsViewController.swift
	RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchCell.swift
	RxExample/RxExample/Examples/WikipediaImageSearch/Views/WikipediaSearchViewController.swift
	Tests/RxCocoaTests/DelegateProxyTest.swift
	Tests/RxCocoaTests/KVOObservableTests.swift
	Tests/RxCocoaTests/RxTest+Controls.swift
	Tests/RxCocoaTests/UICollectionView+RxTests.swift
	Tests/RxCocoaTests/UIScrollView+RxTests.swift
	Tests/RxCocoaTests/UITableView+RxTests.swift
This commit is contained in:
Jérôme Alves 2016-08-15 11:14:11 +02:00
commit e4e422c4f1
216 changed files with 2081 additions and 1439 deletions

View File

@ -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,

View File

@ -79,7 +79,7 @@ Sequences in Rx are described by a push interface (aka callback).
```swift
enum Event<Element> {
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<E>(element: E) -> Observable<E> {
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<E>(sequence: [E]) -> Observable<E> {
}
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<Int> {
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<MagicBeing> = 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<Int>.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)

View File

@ -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.

View File

@ -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.

View File

@ -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)
```

View File

@ -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

View File

@ -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. <br />[![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. <br />[![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)

View File

@ -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("🏈")

View File

@ -23,11 +23,11 @@ func sampleWithoutConnectableOperators() {
let interval = Observable<Int>.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<Int>()
_ = subject
.subscribeNext { print("Subject: \($0)") }
.subscribe(onNext: { print("Subject: \($0)") })
let intSequence = Observable<Int>.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)") })
}
}

View File

@ -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<Int>.error(Error.test)
Observable<Int>.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.

View File

@ -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

View File

@ -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_

View File

@ -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)
//:

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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) }
}

View File

@ -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()
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='osx' display-mode='rendered' last-migration='0800'>
<playground version='6.0' target-platform='osx' display-mode='raw' last-migration='0800'>
<pages>
<page name='Table_of_Contents'/>
<page name='Introduction'/>

View File

@ -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 = "<group>"; };
C8093C581B8A72BE0088E94D /* DisposeBag.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisposeBag.swift; sourceTree = "<group>"; };
C8093C591B8A72BE0088E94D /* DisposeBase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DisposeBase.swift; sourceTree = "<group>"; };
C8093C5A1B8A72BE0088E94D /* NAryDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NAryDisposable.swift; sourceTree = "<group>"; };
C8093C5B1B8A72BE0088E94D /* NAryDisposable.tt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NAryDisposable.tt; sourceTree = "<group>"; };
C8093C5C1B8A72BE0088E94D /* NopDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NopDisposable.swift; sourceTree = "<group>"; };
C8093C5D1B8A72BE0088E94D /* ScheduledDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScheduledDisposable.swift; sourceTree = "<group>"; };
C8093C5F1B8A72BE0088E94D /* SerialDisposable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SerialDisposable.swift; sourceTree = "<group>"; };
@ -1451,7 +1453,7 @@
C8093C641B8A72BE0088E94D /* Event.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Event.swift; sourceTree = "<group>"; };
C8093C651B8A72BE0088E94D /* ImmediateSchedulerType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImmediateSchedulerType.swift; sourceTree = "<group>"; };
C8093C661B8A72BE0088E94D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C8093C671B8A72BE0088E94D /* Observable+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "Observable+Extensions.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
C8093C671B8A72BE0088E94D /* ObservableType+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "ObservableType+Extensions.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
C8093C681B8A72BE0088E94D /* Observable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Observable.swift; sourceTree = "<group>"; };
C8093C6B1B8A72BE0088E94D /* Amb.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Amb.swift; sourceTree = "<group>"; };
C8093C6E1B8A72BE0088E94D /* Catch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Catch.swift; sourceTree = "<group>"; };
@ -1724,6 +1726,7 @@
C8C4B4C01C17727000828BD5 /* MessageSentObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MessageSentObserver.swift; sourceTree = "<group>"; };
C8D132431C42D15E00B59FFF /* SectionedViewDataSourceType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SectionedViewDataSourceType.swift; sourceTree = "<group>"; };
C8D132521C42DA7F00B59FFF /* SectionedViewDataSourceMock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SectionedViewDataSourceMock.swift; sourceTree = "<group>"; };
C8D2C1501D4F3CD6006E2431 /* Rx.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = Rx.playground; sourceTree = "<group>"; };
C8DB967D1BF7496C0084BD53 /* KVORepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KVORepresentable.swift; sourceTree = "<group>"; };
C8DB96821BF754C80084BD53 /* NSObject+Rx+KVORepresentable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSObject+Rx+KVORepresentable.swift"; sourceTree = "<group>"; };
C8DB96871BF756F40084BD53 /* KVORepresentable+CoreGraphics.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "KVORepresentable+CoreGraphics.swift"; sourceTree = "<group>"; };
@ -1740,6 +1743,7 @@
C8E3A7301C2606A900643FE6 /* Event+Equatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Event+Equatable.swift"; sourceTree = "<group>"; };
C8E3A7351C26088C00643FE6 /* Any+Equatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Any+Equatable.swift"; sourceTree = "<group>"; };
C8E7B3681C30C6B800B34368 /* TestableObservable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestableObservable.swift; sourceTree = "<group>"; };
C8E9E42A1D43B26C0049644E /* Observable+DebugTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+DebugTest.swift"; sourceTree = "<group>"; };
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 = "<group>"; };
CB883B491BE369AA000AC2EE /* AddRef.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddRef.swift; sourceTree = "<group>"; };
CBEE771E1BD649A000AD584C /* ToArray.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToArray.swift; sourceTree = "<group>"; };
CDDEF1691D4FB40000CA8546 /* Disposables.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Disposables.swift; sourceTree = "<group>"; };
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 = "<group>"; };
D22B6D251BC8504A00BCE0AB /* SkipWhile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SkipWhile.swift; sourceTree = "<group>"; };
@ -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 = "<group>";
@ -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";

View File

@ -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'

View File

@ -22,7 +22,7 @@ extension BlockingObservable {
public func toArray() throws -> [E] {
var elements: [E] = Array<E>()
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 {

View File

@ -43,7 +43,7 @@ class RunLoopLock {
if CurrentThreadScheduler.isScheduleRequired {
_ = CurrentThreadScheduler.instance.schedule(()) { _ in
action()
return NopDisposable.instance
return Disposables.create()
}
}
else {

View File

@ -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'

View File

@ -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<E>) -> Void)
-> Driver<E> {
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<E> {
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<E> {
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<E> {
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<E> {
let source = self.asObservable()
.doOn(onNext: onNext, onError: onError, onCompleted: onCompleted)
return Driver(source)
}
}

View File

@ -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)
}
}

View File

@ -145,7 +145,7 @@ extension Driver {
*/
// @warn_unused_result(message:"http://git.io/rxs.uo")
public static func of(_ elements: E ...) -> Driver<E> {
let source = elements.toObservable(driverSubscribeOnScheduler)
let source = Observable.from(elements, scheduler: driverSubscribeOnScheduler)
return Driver(raw: source)
}
}

View File

@ -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<E>) -> Driver<E> {
public func asDriver(onErrorRecover: (error: Swift.Error) -> Driver<E>) -> Driver<E> {
let source = self
.asObservable()
.observeOn(driverObserveOnScheduler)

View File

@ -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<P: DelegateProxyType>(_ object: AnyObject, dataSource: AnyObject, retainDataSource: Bool, binding: (P, Event<E>) -> Void)
func subscribeProxyDataSource<P: DelegateProxyType>(ofObject object: AnyObject, dataSource: AnyObject, retainDataSource: Bool, binding: (P, Event<E>) -> 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)
}
}

View File

@ -42,7 +42,7 @@ class KVOObservable<Element>
observer.on(.next(value as? Element))
}
return AnonymousDisposable(observer.dispose)
return Disposables.create(with: observer.dispose)
}
}

View File

@ -26,7 +26,7 @@ extension Reactive where Base: NotificationCenter {
observer.on(.next(notification))
}
return AnonymousDisposable {
return Disposables.create {
self.base.removeObserver(nsObserver)
}
}

View File

@ -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)
}
}

View File

@ -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)

View File

@ -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<T>) in
guard let control = weakControl else {
observer.on(.completed)
return NopDisposable.instance
return Disposables.create()
}
observer.on(.next(getter(control)))

View File

@ -18,7 +18,7 @@ extension Reactive where Base: NSImageView {
Bindable sink for `image` property.
*/
public var image: AnyObserver<NSImage?> {
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<NSImage?> {
return UIBindingObserver(UIElement: self.base) { control, value in
if let transitionType = transitionType {
@ -44,4 +45,26 @@ extension Reactive where Base: NSImageView {
}.asObserver()
}
/**
Bindable sink for `image` property.
- parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...)
*/
public func image(transitionType: String? = nil) -> AnyObserver<NSImage?> {
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()
}
}

View File

@ -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:

View File

@ -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.
*/

View File

@ -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())

View File

@ -42,6 +42,7 @@ extension Reactive where Base: UICollectionView {
}
.addDisposableTo(disposeBag)
*/
@available(*, deprecated, renamed: "items(source:cellFactory:)")
public func itemsWithCellFactory<S: Sequence, O: ObservableType where O.E == S>
(_ 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<S: Sequence, O: ObservableType where O.E == S>
(source: O)
-> (cellFactory: (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell)
-> Disposable {
return { cellFactory in
let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper<S>(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<S: Sequence, Cell: UICollectionViewCell, O : ObservableType where O.E == S>
(_ cellIdentifier: String, cellType: Cell.Type = Cell.self)
-> (source: O)
@ -95,6 +132,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<S: Sequence, Cell: UICollectionViewCell, O : ObservableType where O.E == S>
(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<S> { (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<RxCollectionViewDataSourceType, UICollectionViewDataSource>,
DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource,
O: ObservableType where DataSource.Element == O.E
>
(_ dataSource: DataSource)
-> (source: O)
-> Disposable {
return { source 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)
}
}
}
return source.subscribeProxyDataSourceForObject(self.base, dataSource: dataSource, retainDataSource: true) { [weak collectionView = self.base] (_: RxCollectionViewDataSourceProxy, event) -> Void in
/**
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<SectionModel<String, Double>>()
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
}

View File

@ -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,7 +53,7 @@ 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<T> = 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)

View File

@ -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) {

View File

@ -20,7 +20,7 @@ extension Reactive where Base: UIImageView {
Bindable sink for `image` property.
*/
public var image: AnyObserver<UIImage?> {
return self.imageAnimated(nil)
return image(transitionType: nil)
}
/**
@ -28,8 +28,9 @@ 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<UIImage?> {
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()
@ -46,6 +47,28 @@ extension Reactive where Base: UIImageView {
}.asObserver()
}
/**
Bindable sink for `image` property.
- parameter transitionType: Optional transition type while setting the image (kCATransitionFade, kCATransitionMoveIn, ...)
*/
public func image(transitionType: String? = nil) -> AnyObserver<UIImage?> {
return UIBindingObserver(UIElement: base) { imageView, image in
if let transitionType = transitionType {
if image != nil {
let transition = CATransition()
transition.duration = 0.25
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = transitionType
imageView.layer.add(transition, forKey: kCATransition)
}
}
else {
imageView.layer.removeAllAnimations()
}
imageView.image = image
}.asObserver()
}
}
#endif

View File

@ -28,7 +28,7 @@ extension Reactive where Base: UILabel {
/**
Bindable sink for `attributedText` property.
*/
public var attributedText: AnyObserver<AttributedString?> {
public var attributedText: AnyObserver<NSAttributedString?> {
return UIBindingObserver(UIElement: self.base) { label, text in
label.attributedText = text
}.asObserver()

View File

@ -42,6 +42,7 @@ extension Reactive where Base: UITableView {
.addDisposableTo(disposeBag)
*/
@available(*, deprecated, renamed: "items(source:cellFactory:)")
public func itemsWithCellFactory<S: Sequence, O: ObservableType where O.E == S>
(_ source: O)
-> (cellFactory: (UITableView, Int, S.Iterator.Element) -> UITableViewCell)
@ -49,13 +50,48 @@ extension Reactive where Base: UITableView {
return { cellFactory in
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<S>(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<S: Sequence, O: ObservableType where O.E == S>
(_ source: O)
-> (cellFactory: (UITableView, Int, S.Iterator.Element) -> UITableViewCell)
-> Disposable {
return { cellFactory in
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<S>(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<S: Sequence, Cell: UITableViewCell, O : ObservableType where O.E == S>
(_ cellIdentifier: String, cellType: Cell.Type = Cell.self)
-> (source: O)
@ -94,6 +131,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<S: Sequence, Cell: UITableViewCell, O : ObservableType where O.E == S>
(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<S> { (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.
This method will retain the data source for as long as the subscription isn't disposed (result `Disposable`
@ -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<RxTableViewDataSourceType, UITableViewDataSource>,
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<SectionModel<String, Double>>()
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<WillDisplayCellEvent> {
let source: Observable<DidEndDisplayingCellEvent> = self.delegate.observe(#selector(UITableViewDelegate.tableView(_:willDisplay:forRowAt:)))
let source: Observable<WillDisplayCellEvent> = self.delegate.observe(#selector(UITableViewDelegate.tableView(_:willDisplay:forRowAt:)))
.map { a in
return (try castOrThrow(UITableViewCell.self, a[1]), try castOrThrow(IndexPath.self, a[2]))
}

View File

@ -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<RxTableViewDataSourceType, UITableViewDataSource>,
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<RxCollectionViewDataSourceType, UICollectionViewDataSource>,
@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

View File

@ -8,7 +8,7 @@
import Foundation
public struct AnimatableSectionModel<Section: IdentifiableType, ItemType: protocol<IdentifiableType, Equatable>>
public struct AnimatableSectionModel<Section: IdentifiableType, ItemType: IdentifiableType & Equatable>
: AnimatableSectionModelType
, CustomStringConvertible {
public typealias Item = ItemType

View File

@ -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)")
}

View File

@ -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)"

View File

@ -73,6 +73,7 @@ public class _TableViewSectionedDataSource
return _rx_tableView(tableView, canMoveRowAtIndexPath: indexPath)
}
#if os(iOS)
func _sectionIndexTitlesForTableView(_ tableView: UITableView) -> [String]? {
return nil
}
@ -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<S: SectionModelType>
public var rowAnimation: UITableViewRowAnimation = .automatic
#if os(iOS)
public var sectionIndexTitles: ((RxTableViewSectionedDataSource<S>) -> [String]?)? {
didSet {
#if DEBUG
@ -209,6 +212,7 @@ public class RxTableViewSectionedDataSource<S: SectionModelType>
#endif
}
}
#endif
public override init() {
super.init()
@ -265,6 +269,7 @@ public class RxTableViewSectionedDataSource<S: SectionModelType>
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<S: SectionModelType>
return section
}
#endif
}

View File

@ -41,7 +41,7 @@ extension TestScheduler {
- `|` marks sequence completed
*/
func parseEventsAndTimes<T>(timeline: String, values: [String: T], errors: [String: ErrorProtocol] = [:]) -> [[Recorded<Event<T>>]] {
func parseEventsAndTimes<T>(timeline: String, values: [String: T], errors: [String: Swift.Error] = [:]) -> [[Recorded<Event<T>>]] {
//print("parsing: \(timeline)")
typealias RecordedEvent = Recorded<Event<T>>
@ -112,7 +112,7 @@ extension TestScheduler {
- returns: Observable sequence specified by timeline and values.
*/
func createObservable<T>(timeline: String, values: [String: T], errors: [String: ErrorProtocol] = [:]) -> Observable<T> {
func createObservable<T>(timeline: String, values: [String: T], errors: [String: Swift.Error] = [:]) -> Observable<T> {
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<Arg, Ret>(values: [String: Ret], errors: [String: ErrorProtocol] = [:], timelineSelector: (Arg) -> String) -> (Arg) -> Observable<Ret> {
func mock<Arg, Ret>(values: [String: Ret], errors: [String: Swift.Error] = [:], timelineSelector: (Arg) -> String) -> (Arg) -> Observable<Ret> {
return { (parameters: Arg) -> Observable<Ret> in
let timeline = timelineSelector(parameters)

View File

@ -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()

View File

@ -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)
}

View File

@ -70,7 +70,7 @@ class GeolocationViewController: ViewController {
}
private func openAppPreferences() {
UIApplication.shared().openURL(URL(string: UIApplicationOpenSettingsURLString)!)
UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)
}
}

View File

@ -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

View File

@ -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)
// }
}

View File

@ -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
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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<UIImagePickerController> {
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)
})
}

View File

@ -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)
}
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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<NumberSection>()
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)
}

View File

@ -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

View File

@ -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
}

View File

@ -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)

View File

@ -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)
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11185.3" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11185.3"/>
</dependencies>
<scenes>
<!--Application-->
@ -88,8 +88,8 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OPN-Cj-AXY">
<rect key="frame" x="440" y="320" width="43" height="17"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="OPN-Cj-AXY">
<rect key="frame" x="440" y="320" width="42" height="17"/>
<constraints>
<constraint firstAttribute="height" constant="17" id="ep0-fb-x50"/>
</constraints>
@ -99,8 +99,8 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="GIP-PK-nj4">
<rect key="frame" x="221" y="252" width="153" height="32"/>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="GIP-PK-nj4">
<rect key="frame" x="221" y="252" width="152" height="32"/>
<buttonCell key="cell" type="push" title="Unbind everything" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="OfL-Xk-Jww">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
@ -121,19 +121,19 @@
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uvp-P6-I33">
<rect key="frame" x="94" y="228" width="407" height="17"/>
<rect key="frame" x="93" y="228" width="407" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Everything is unbound when `Unbind everything` button is clicked" id="oNm-CU-Uq7">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<slider verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Wbs-Vv-RvG">
<rect key="frame" x="54" y="156" width="502" height="20"/>
<slider verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Wbs-Vv-RvG">
<rect key="frame" x="54" y="157" width="502" height="20"/>
<sliderCell key="cell" continuous="YES" state="on" alignment="left" maxValue="100" doubleValue="50" tickMarkPosition="above" sliderType="linear" id="0FL-dG-a0V"/>
</slider>
<textField verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="35N-M1-mEj">
<rect key="frame" x="208" y="122" width="96" height="22"/>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="35N-M1-mEj">
<rect key="frame" x="208" y="123" width="96" height="22"/>
<constraints>
<constraint firstAttribute="width" constant="96" id="UjJ-QN-7sX"/>
<constraint firstAttribute="height" constant="22" id="p0d-PC-IYH"/>
@ -144,8 +144,8 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uJU-xc-Cnn">
<rect key="frame" x="56" y="125" width="136" height="17"/>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="uJU-xc-Cnn">
<rect key="frame" x="56" y="126" width="136" height="17"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Slider Value (0 - 100):" id="Pbz-ZR-CzF">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>

View File

@ -69,7 +69,7 @@ func <-> (textInput: RxTextInput, variable: Variable<String>) -> Disposable {
bindToUIDisposable.dispose()
})
return StableCompositeDisposable.create(bindToUIDisposable, bindToVariable)
return Disposables.create(bindToUIDisposable, bindToVariable)
}
func <-> <T>(property: ControlProperty<T>, variable: Variable<T>) -> Disposable {
@ -92,7 +92,7 @@ func <-> <T>(property: ControlProperty<T>, variable: Variable<T>) -> Disposable
bindToUIDisposable.dispose()
})
return StableCompositeDisposable.create(bindToUIDisposable, bindToVariable)
return Disposables.create(bindToUIDisposable, bindToVariable)
}
// }

View File

@ -18,7 +18,7 @@ private struct ActivityToken<E> : ObservableConvertibleType, Disposable {
init(source: Observable<E>, disposeAction: () -> ()) {
_source = source
_dispose = AnonymousDisposable(disposeAction)
_dispose = Disposables.create(with: disposeAction)
}
func dispose() {
@ -39,7 +39,7 @@ When all activities complete `false` will be sent.
public class ActivityIndicator : DriverConvertibleType {
public typealias E = Bool
private let _lock = RecursiveLock()
private let _lock = NSRecursiveLock()
private let _variable = Variable(0)
private let _loading: Driver<Bool>

View File

@ -9,7 +9,7 @@
import Foundation
func parseImageURLsfromHTML(_ html: NSString) throws -> [URL] {
let regularExpression = try RegularExpression(pattern: "<img[^>]*src=\"([^\"]+)\"[^>]*>", options: [])
let regularExpression = try NSRegularExpression(pattern: "<img[^>]*src=\"([^\"]+)\"[^>]*>", options: [])
let matches = regularExpression.matches(in: html as String, options: [], range: NSMakeRange(0, html.length))
@ -18,7 +18,7 @@ func parseImageURLsfromHTML(_ html: NSString) throws -> [URL] {
return nil
}
let url = html.substring(with: match.range(at: 1))
let url = html.substring(with: match.rangeAt(1))
var absoluteURLString = url
if url.hasPrefix("//") {
@ -31,6 +31,6 @@ func parseImageURLsfromHTML(_ html: NSString) throws -> [URL] {
func parseImageURLsfromHTMLSuitableForDisplay(_ html: NSString) throws -> [URL] {
return try parseImageURLsfromHTML(html).filter {
return $0.absoluteString?.range(of: ".svg.") == nil
return $0.absoluteString.range(of: ".svg.") == nil
}
}

View File

@ -29,10 +29,10 @@ class DefaultImageService: ImageService {
let $: Dependencies = Dependencies.sharedDependencies
// 1st level cache
private let _imageCache = Cache<AnyObject, AnyObject>()
private let _imageCache = NSCache<AnyObject, AnyObject>()
// 2nd level cache
private let _imageDataCache = Cache<AnyObject, AnyObject>()
private let _imageDataCache = NSCache<AnyObject, AnyObject>()
let loadingImage = ActivityIndicator()

View File

@ -28,7 +28,7 @@ POSSIBILITY OF SUCH DAMAGE.
import SystemConfiguration
import Foundation
enum ReachabilityError: ErrorProtocol {
enum ReachabilityError: Swift.Error {
case failedToCreateWithAddress(sockaddr_in)
case failedToCreateWithHostname(String)
case unableToSetCallback
@ -224,7 +224,7 @@ public class Reachability: NSObject {
private var notifierRunning = false
private var reachabilityRef: SCNetworkReachability?
private let reachabilitySerialQueue = DispatchQueue(label: "uk.co.ashleymills.reachability", attributes: DispatchQueueAttributes.serial)
private let reachabilitySerialQueue = DispatchQueue(label: "uk.co.ashleymills.reachability")
private func reachabilityChanged(_ flags: SCNetworkReachabilityFlags) {
if isReachableWithFlags(flags) {

View File

@ -47,7 +47,7 @@ class DefaultReachabilityService
let reachabilitySubject = BehaviorSubject<ReachabilityStatus>(value: .unreachable)
// so main thread isn't blocked when reachability via WiFi is checked
let backgroundQueue = DispatchQueue(label: "reachability.wificheck", attributes: DispatchQueueAttributes.serial)
let backgroundQueue = DispatchQueue(label: "reachability.wificheck")
reachabilityRef.whenReachable = { reachability in
backgroundQueue.async {

View File

@ -33,7 +33,7 @@ class DefaultWireframe: Wireframe {
func open(url: URL) {
#if os(iOS)
UIApplication.shared().openURL(url)
UIApplication.shared.openURL(url)
#elseif os(OSX)
NSWorkspace.shared().open(url)
#endif
@ -42,7 +42,7 @@ class DefaultWireframe: Wireframe {
#if os(iOS)
private static func rootViewController() -> UIViewController {
// cheating, I know
return UIApplication.shared().keyWindow!.rootViewController!
return UIApplication.shared.keyWindow!.rootViewController!
}
#endif
@ -71,7 +71,7 @@ class DefaultWireframe: Wireframe {
DefaultWireframe.rootViewController().present(alertView, animated: true, completion: nil)
return AnonymousDisposable {
return Disposables.create {
alertView.dismiss(animated:false, completion: nil)
}
}

View File

@ -53,9 +53,9 @@ class ViewController: OSViewController {
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
*/
_ = Observable<Int>.interval(1, scheduler: MainScheduler.instance)
.subscribeNext { _ in
.subscribe(onNext: { _ in
print("Resource count \(RxSwift.resourceCount)")
}
})
Most efficient way to test for memory leaks is:
* navigate to your screen and use it
@ -79,8 +79,9 @@ class ViewController: OSViewController {
If somebody knows more about why this delay happens, you can make a PR with explanation here.
*/
let when = DispatchTime.now() + DispatchTimeInterval.milliseconds(2)
mainQueue.after(when: when) {
let when = DispatchTime.now() + DispatchTimeInterval.milliseconds(20)
mainQueue.asyncAfter (deadline: when) {
/*
Some small additional period to clean things up. In case there were async operations fired,

View File

@ -23,11 +23,11 @@ public class RootViewController : UITableViewController {
_ = DefaultWireframe.sharedInstance
_ = MainScheduler.instance
let geoService = GeolocationService.instance
geoService.authorized.driveNext { _ in
geoService.authorized.drive(onNext: { _ in
}.dispose()
geoService.location.driveNext { _ in
}).dispose()
geoService.location.drive(onNext: { _ in
}.dispose()
}).dispose()
}
}

View File

@ -28,7 +28,7 @@ gitDiff().grep("bug").less // sequences of swift objects
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'

View File

@ -15,5 +15,14 @@ public protocol Cancelable : Disposable {
/**
- returns: Was resource disposed.
*/
var disposed: Bool { get }
var isDisposed: Bool { get }
}
public extension Cancelable {
@available(*, deprecated, renamed: "isDisposed")
var disposed: Bool {
return isDisposed
}
}

View File

@ -59,10 +59,10 @@ protocol Lock {
#else
// https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000321.html
typealias SpinLock = RecursiveLock
typealias SpinLock = NSRecursiveLock
#endif
extension RecursiveLock : Lock {
extension NSRecursiveLock : Lock {
func performLocked( _ action: @noescape() -> Void) {
lock(); defer { unlock() }
action()

View File

@ -9,7 +9,7 @@
import Foundation
protocol LockOwnerType : class, Lock {
var _lock: RecursiveLock { get }
var _lock: NSRecursiveLock { get }
}
extension LockOwnerType {

View File

@ -16,14 +16,14 @@ When dispose method is called, disposal action will be dereferenced.
public final class AnonymousDisposable : DisposeBase, Cancelable {
public typealias DisposeAction = () -> Void
private var _disposed: AtomicInt = 0
private var _isDisposed: AtomicInt = 0
private var _disposeAction: DisposeAction?
/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed == 1
public var isDisposed: Bool {
return _isDisposed == 1
}
/**
@ -31,19 +31,26 @@ public final class AnonymousDisposable : DisposeBase, Cancelable {
- parameter disposeAction: Disposal action which will be run upon calling `dispose`.
*/
@available(*, deprecated, renamed: "Disposables.create")
public init(_ disposeAction: DisposeAction) {
_disposeAction = disposeAction
super.init()
}
// Non-deprecated version of the constructor, used by `Disposables.create(with:)`
private init(disposeAction: DisposeAction) {
_disposeAction = disposeAction
super.init()
}
/**
Calls the disposal action if and only if the current instance hasn't been disposed yet.
After invoking disposal action, disposal action will be dereferenced.
*/
public func dispose() {
if AtomicCompareAndSwap(0, 1, &_disposed) {
assert(_disposed == 1)
if AtomicCompareAndSwap(0, 1, &_isDisposed) {
assert(_isDisposed == 1)
if let action = _disposeAction {
_disposeAction = nil
@ -52,3 +59,16 @@ public final class AnonymousDisposable : DisposeBase, Cancelable {
}
}
}
public extension Disposables {
/**
Constructs a new disposable with the given action used for disposal.
- parameter dispose: Disposal action which will be run upon calling `dispose`.
*/
static func create(with dispose: () -> ()) -> Cancelable {
return AnonymousDisposable(disposeAction: dispose)
}
}

View File

@ -11,9 +11,9 @@ import Foundation
/**
Represents two disposable resources that are disposed together.
*/
public final class BinaryDisposable : DisposeBase, Cancelable {
private final class BinaryDisposable : DisposeBase, Cancelable {
private var _disposed: AtomicInt = 0
private var _isDisposed: AtomicInt = 0
// state
private var _disposable1: Disposable?
@ -22,8 +22,8 @@ public final class BinaryDisposable : DisposeBase, Cancelable {
/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed > 0
var isDisposed: Bool {
return _isDisposed > 0
}
/**
@ -43,8 +43,8 @@ public final class BinaryDisposable : DisposeBase, Cancelable {
After invoking disposal action, disposal action will be dereferenced.
*/
public func dispose() {
if AtomicCompareAndSwap(0, 1, &_disposed) {
func dispose() {
if AtomicCompareAndSwap(0, 1, &_isDisposed) {
_disposable1?.dispose()
_disposable2?.dispose()
_disposable1 = nil
@ -52,3 +52,14 @@ public final class BinaryDisposable : DisposeBase, Cancelable {
}
}
}
public extension Disposables {
/**
Creates a disposable with the given disposables.
*/
static func create(_ disposable1: Disposable, _ disposable2: Disposable) -> Cancelable {
return BinaryDisposable(disposable1, disposable2)
}
}

View File

@ -11,10 +11,10 @@ import Foundation
/**
Represents a disposable resource that can be checked for disposal status.
*/
public class BooleanDisposable : Disposable, Cancelable {
public final class BooleanDisposable : Disposable, Cancelable {
internal static let BooleanDisposableTrue = BooleanDisposable(disposed: true)
private var _disposed = false
internal static let BooleanDisposableTrue = BooleanDisposable(isDisposed: true)
private var _isDisposed = false
/**
Initializes a new instance of the `BooleanDisposable` class
@ -25,21 +25,21 @@ public class BooleanDisposable : Disposable, Cancelable {
/**
Initializes a new instance of the `BooleanDisposable` class with given value
*/
public init(disposed: Bool) {
self._disposed = disposed
public init(isDisposed: Bool) {
self._isDisposed = isDisposed
}
/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed
public var isDisposed: Bool {
return _isDisposed
}
/**
Sets the status to disposed, which can be observer through the `disposed` property.
Sets the status to disposed, which can be observer through the `isDisposed` property.
*/
public func dispose() {
_disposed = true
_isDisposed = true
}
}

View File

@ -11,7 +11,7 @@ import Foundation
/**
Represents a group of disposable resources that are disposed together.
*/
public class CompositeDisposable : DisposeBase, Disposable, Cancelable {
public final class CompositeDisposable : DisposeBase, Disposable, Cancelable {
public typealias DisposeKey = Bag<Disposable>.KeyType
private var _lock = SpinLock()
@ -19,7 +19,7 @@ public class CompositeDisposable : DisposeBase, Disposable, Cancelable {
// state
private var _disposables: Bag<Disposable>? = Bag()
public var disposed: Bool {
public var isDisposed: Bool {
_lock.lock(); defer { _lock.unlock() }
return _disposables == nil
}

View File

@ -0,0 +1,61 @@
//
// Disposables.swift
// Rx
//
// Created by Mohsen Ramezanpoor on 01/08/2016.
// Copyright © 2016 Mohsen Ramezanpoor. All rights reserved.
//
import Foundation
/**
A collection of utility methods for common disposable operations.
*/
public struct Disposables {
private init() {}
}
public extension Disposables {
private static let noOp: Disposable = NopDisposable()
/**
Creates a disposable that does nothing on disposal.
*/
static func create() -> Disposable {
return noOp
}
/**
Creates a disposable with the given disposables.
*/
static func create(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable) -> Cancelable {
return CompositeDisposable(disposable1, disposable2, disposable3)
}
/**
Creates a disposable with the given disposables.
*/
static func create(_ disposable1: Disposable, _ disposable2: Disposable, _ disposable3: Disposable, _ disposables: Disposable ...) -> Cancelable {
var disposables = disposables
disposables.append(disposable1)
disposables.append(disposable2)
disposables.append(disposable3)
return CompositeDisposable(disposables: disposables)
}
/**
Creates a disposable with the given disposables.
*/
static func create(_ disposables: [Disposable]) -> Cancelable {
switch disposables.count {
case 2:
return Disposables.create(disposables[0], disposables[1])
default:
return CompositeDisposable(disposables: disposables)
}
}
}

View File

@ -31,13 +31,13 @@ or create a new one in its place.
In case explicit disposal is necessary, there is also `CompositeDisposable`.
*/
public class DisposeBag: DisposeBase {
public final class DisposeBag: DisposeBase {
private var _lock = SpinLock()
// state
private var _disposables = [Disposable]()
private var _disposed = false
private var _isDisposed = false
/**
Constructs new empty dispose bag.
@ -67,7 +67,7 @@ public class DisposeBag: DisposeBase {
private func _insert(_ disposable: Disposable) -> Disposable? {
_lock.lock(); defer { _lock.unlock() }
if _disposed {
if _isDisposed {
return disposable
}
@ -93,7 +93,7 @@ public class DisposeBag: DisposeBase {
let disposables = _disposables
_disposables.removeAll(keepingCapacity: false)
_disposed = true
_isDisposed = true
return disposables
}

View File

@ -1,10 +0,0 @@
// This file is autogenerated. Take a look at `Preprocessor` target in RxSwift project
//
// NAryDisposable.swift
// RxSwift
//
// Created by Krunoslav Zaher on 8/20/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation

View File

@ -1,9 +0,0 @@
//
// NAryDisposable.swift
// RxSwift
//
// Created by Krunoslav Zaher on 8/20/15.
// Copyright © 2015 Krunoslav Zaher. All rights reserved.
//
import Foundation

View File

@ -18,6 +18,7 @@ public struct NopDisposable : Disposable {
/**
Singleton instance of `NopDisposable`.
*/
@available(*, deprecated, renamed: "Disposables.empty()")
public static let instance: Disposable = NopDisposable()
init() {

View File

@ -11,7 +11,7 @@ import Foundation
/**
Represents a disposable resource that only disposes its underlying disposable resource when all dependent disposable objects have been disposed.
*/
public class RefCountDisposable : DisposeBase, Cancelable {
public final class RefCountDisposable : DisposeBase, Cancelable {
private var _lock = SpinLock()
private var _disposable = nil as Disposable?
private var _primaryDisposed = false
@ -20,7 +20,7 @@ public class RefCountDisposable : DisposeBase, Cancelable {
/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
public var isDisposed: Bool {
_lock.lock(); defer { _lock.unlock() }
return _disposable == nil
}
@ -50,7 +50,7 @@ public class RefCountDisposable : DisposeBase, Cancelable {
return RefCountInnerDisposable(self)
} else {
return NopDisposable.instance
return Disposables.create()
}
}
}
@ -110,7 +110,7 @@ public class RefCountDisposable : DisposeBase, Cancelable {
internal final class RefCountInnerDisposable: DisposeBase, Disposable
{
private let _parent: RefCountDisposable
private var _disposed: AtomicInt = 0
private var _isDisposed: AtomicInt = 0
init(_ parent: RefCountDisposable)
{
@ -120,7 +120,7 @@ internal final class RefCountInnerDisposable: DisposeBase, Disposable
internal func dispose()
{
if AtomicCompareAndSwap(0, 1, &_disposed) {
if AtomicCompareAndSwap(0, 1, &_isDisposed) {
_parent.release()
}
}

View File

@ -10,16 +10,16 @@ import Foundation
private let disposeScheduledDisposable: (ScheduledDisposable) -> Disposable = { sd in
sd.disposeInner()
return NopDisposable.instance
return Disposables.create()
}
/**
Represents a disposable resource whose disposal invocation will be scheduled on the specified scheduler.
*/
public class ScheduledDisposable : Cancelable {
public final class ScheduledDisposable : Cancelable {
public let scheduler: ImmediateSchedulerType
private var _disposed: AtomicInt = 0
private var _isDisposed: AtomicInt = 0
// state
private var _disposable: Disposable?
@ -27,8 +27,8 @@ public class ScheduledDisposable : Cancelable {
/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed == 1
public var isDisposed: Bool {
return _isDisposed == 1
}
/**
@ -50,7 +50,7 @@ public class ScheduledDisposable : Cancelable {
}
func disposeInner() {
if AtomicCompareAndSwap(0, 1, &_disposed) {
if AtomicCompareAndSwap(0, 1, &_isDisposed) {
_disposable!.dispose()
_disposable = nil
}

View File

@ -11,18 +11,18 @@ import Foundation
/**
Represents a disposable resource whose underlying disposable resource can be replaced by another disposable resource, causing automatic disposal of the previous underlying disposable resource.
*/
public class SerialDisposable : DisposeBase, Cancelable {
public final class SerialDisposable : DisposeBase, Cancelable {
private var _lock = SpinLock()
// state
private var _current = nil as Disposable?
private var _disposed = false
private var _isDisposed = false
/**
- returns: Was resource disposed.
*/
public var disposed: Bool {
return _disposed
public var isDisposed: Bool {
return _isDisposed
}
/**
@ -47,7 +47,7 @@ public class SerialDisposable : DisposeBase, Cancelable {
}
set (newDisposable) {
let disposable: Disposable? = _lock.calculateLocked {
if _disposed {
if _isDisposed {
return newDisposable
}
else {
@ -72,11 +72,11 @@ public class SerialDisposable : DisposeBase, Cancelable {
private func _dispose() -> Disposable? {
_lock.lock(); defer { _lock.unlock() }
if _disposed {
if _isDisposed {
return nil
}
else {
_disposed = true
_isDisposed = true
let current = _current
_current = nil
return current

View File

@ -17,15 +17,15 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
private var _lock = SpinLock()
// state
private var _disposed = false
private var _isDisposed = false
private var _disposableSet = false
private var _disposable = nil as Disposable?
/**
- returns: A value that indicates whether the object is disposed.
*/
public var disposed: Bool {
return _disposed
public var isDisposed: Bool {
return _isDisposed
}
/**
@ -43,7 +43,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
public var disposable: Disposable {
get {
_lock.lock(); defer { _lock.unlock() }
return _disposable ?? NopDisposable.instance
return _disposable ?? Disposables.create()
}
set {
_setDisposable(newValue)?.dispose()
@ -58,7 +58,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
_disposableSet = true
if _disposed {
if _isDisposed {
return newValue
}
@ -71,7 +71,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
Disposes the underlying disposable.
*/
public func dispose() {
if _disposed {
if _isDisposed {
return
}
_dispose()?.dispose()
@ -80,7 +80,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
private func _dispose() -> Disposable? {
_lock.lock(); defer { _lock.unlock() }
_disposed = true
_isDisposed = true
let disposable = _disposable
_disposable = nil

View File

@ -9,7 +9,8 @@
import Foundation
public final class StableCompositeDisposable {
@available(*, deprecated, renamed: "Disposables.create")
public static func create(_ disposable1: Disposable, _ disposable2: Disposable) -> Disposable {
return BinaryDisposable(disposable1, disposable2)
return Disposables.create(disposable1, disposable2)
}
}

View File

@ -15,7 +15,7 @@ let RxCompositeFailures = "RxCompositeFailures"
Generic Rx error codes.
*/
public enum RxError
: ErrorProtocol
: Swift.Error
, CustomDebugStringConvertible {
/**
Unknown error occured.

View File

@ -19,7 +19,7 @@ public enum Event<Element> {
case next(Element)
/// Sequence terminated with an error.
case error(ErrorProtocol)
case error(Swift.Error)
/// Sequence completed successfully.
case completed
@ -57,7 +57,7 @@ extension Event {
}
/// - returns: If `Error` event, returns error.
public var error: ErrorProtocol? {
public var error: Swift.Error? {
if case .error(let error) = self {
return error
}

View File

@ -35,6 +35,6 @@ extension ImmediateSchedulerType {
recursiveScheduler.schedule(state)
return AnonymousDisposable(recursiveScheduler.dispose)
return Disposables.create(with: recursiveScheduler.dispose)
}
}

View File

@ -1,5 +1,5 @@
//
// Observable+Extensions.swift
// ObservableType+Extensions.swift
// Rx
//
// Created by Krunoslav Zaher on 2/21/15.
@ -24,6 +24,7 @@ extension ObservableType {
return self.subscribeSafe(observer)
}
#if DEBUG
/**
Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable sequence.
@ -35,16 +36,62 @@ extension ObservableType {
- returns: Subscription object used to unsubscribe from the observable sequence.
*/
// @warn_unused_result(message: "http://git.io/rxs.ud")
public func subscribe(onNext: ((E) -> Void)? = nil, onError: ((ErrorProtocol) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil)
public func subscribe(file: String = #file, line: UInt = #line, function: String = #function, onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil)
-> Disposable {
let disposable: Disposable
if let disposed = onDisposed {
disposable = AnonymousDisposable(disposed)
disposable = Disposables.create(with: disposed)
}
else {
disposable = NopDisposable.instance
disposable = Disposables.create()
}
let observer = AnonymousObserver<E> { e in
switch e {
case .next(let value):
onNext?(value)
case .error(let e):
if let onError = onError {
onError(e)
}
else {
print("Received unhandled error: \(file):\(line):\(function) -> \(e)")
}
disposable.dispose()
case .completed:
onCompleted?()
disposable.dispose()
}
}
return Disposables.create(
self.subscribeSafe(observer),
disposable
)
}
#else
/**
Subscribes an element handler, an error handler, a completion handler and disposed handler to an observable sequence.
- parameter onNext: Action to invoke for each element in the observable sequence.
- parameter onError: Action to invoke upon errored termination of the observable sequence.
- parameter onCompleted: Action to invoke upon graceful termination of the observable sequence.
- parameter onDisposed: Action to invoke upon any type of termination of sequence (if the sequence has
gracefully completed, errored, or if the generation is cancelled by disposing subscription).
- returns: Subscription object used to unsubscribe from the observable sequence.
*/
// @warn_unused_result(message: "http://git.io/rxs.ud")
public func subscribe(onNext: ((E) -> Void)? = nil, onError: ((Swift.Error) -> Void)? = nil, onCompleted: (() -> Void)? = nil, onDisposed: (() -> Void)? = nil)
-> Disposable {
let disposable: Disposable
if let disposed = onDisposed {
disposable = Disposables.create(with: disposed)
}
else {
disposable = Disposables.create()
}
let observer = AnonymousObserver<E> { e in
@ -59,11 +106,12 @@ extension ObservableType {
disposable.dispose()
}
}
return BinaryDisposable(
return Disposables.create(
self.subscribeSafe(observer),
disposable
)
}
#endif
/**
Subscribes an element handler to an observable sequence.
@ -72,6 +120,7 @@ extension ObservableType {
- returns: Subscription object used to unsubscribe from the observable sequence.
*/
// @warn_unused_result(message: "http://git.io/rxs.ud")
@available(*, deprecated, renamed: "subscribe(onNext:)")
public func subscribeNext(_ onNext: (E) -> Void)
-> Disposable {
let observer = AnonymousObserver<E> { e in
@ -89,7 +138,8 @@ extension ObservableType {
- returns: Subscription object used to unsubscribe from the observable sequence.
*/
// @warn_unused_result(message: "http://git.io/rxs.ud")
public func subscribeError(_ onError: (ErrorProtocol) -> Void)
@available(*, deprecated, renamed: "subscribe(onError:)")
public func subscribeError(_ onError: (Swift.Error) -> Void)
-> Disposable {
let observer = AnonymousObserver<E> { e in
if case .error(let error) = e {
@ -106,6 +156,7 @@ extension ObservableType {
- returns: Subscription object used to unsubscribe from the observable sequence.
*/
// @warn_unused_result(message: "http://git.io/rxs.ud")
@available(*, deprecated, renamed: "subscribe(onCompleted:)")
public func subscribeCompleted(_ onCompleted: () -> Void)
-> Disposable {
let observer = AnonymousObserver<E> { e in

Some files were not shown because too many files have changed in this diff Show More