Merge branch 'develop' into uisearchbar-cancel

This commit is contained in:
Stephen H. Gerstacker 2016-03-22 06:57:56 -04:00
commit f91b86b8d2
49 changed files with 134 additions and 106 deletions

View File

@ -1,6 +1,6 @@
language: objective-c
osx_image: xcode7.2
osx_image: xcode7.3
notifications:
slack: rxswift:3ykt2Z61f8GkdvhCZTYPduOL

View File

@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
#### Anomalies
* Fixes anomaly with synchronization in disposable setter of `SingleAssignmentDisposable`.
* Improves `DelegateProxy` memory management.
* Fixes anomaly during two way binding of `UITextView` text value.
* Improves `single` operator so it handles reentrancy better.

View File

@ -47,7 +47,7 @@ let b /*: Observable<Int>*/ = Variable(2) // b = 2
// c = "\(a + b) is positive"
// }
// combines latest values of variables `a` and `b` using `+`
// combines latest values of variables `a` and `b` using `+`
let c = Observable.combineLatest(a.asObservable(), b.asObservable()) { $0 + $1 }
.filter { $0 >= 0 } // if `a + b >= 0` is true, `a + b` is passed to map operator
.map { "\($0) is positive" } // maps `a + b` to "\(a + b) is positive"
@ -89,7 +89,7 @@ b.value = -8 // doesn't print anything
```swift
let subscription/*: Disposable */ = primeTextField.rx_text // type is Observable<String>
.map { WolframAlphaIsPrime($0.toInt() ?? 0) } // type is Observable<Observable<Prime>>
.map { WolframAlphaIsPrime(Int($0) ?? 0) } // type is Observable<Observable<Prime>>
.concat() // type is Observable<Prime>
.map { "number \($0.n) is prime? \($0.isPrime)" } // type is Observable<String>
.bindTo(resultLabel.rx_text) // return Disposable that can be used to unbind everything
@ -126,7 +126,7 @@ self.usernameOutlet.rx_text
// Convenience for constructing synchronous result.
// In case there is mixed synchronous and asychronous code inside the same
// method, this will construct an async result that is resolved immediatelly.
return just((valid: false, message: "Username can't be empty."))
return Observable.just((valid: false, message: "Username can't be empty."))
}
...
@ -138,7 +138,8 @@ self.usernameOutlet.rx_text
// * true - is valid
// * false - not valid
// * nil - validation pending
let loadingValue = (valid: nil, message: "Checking availability ...")
typealias LoadingInfo = (valid : String?, message: String?)
let loadingValue : LoadingInfo = (valid: nil, message: "Checking availability ...")
// This will fire a server call to check if the username already exists.
// Guess what, its type is `Observable<ValidationResult>`

View File

@ -19,7 +19,7 @@ This project tries to be consistent with [ReactiveX.io](http://reactivex.io/). T
1. [KVO](#kvo)
1. [UI layer tips](#ui-layer-tips)
1. [Making HTTP requests](#making-http-requests)
1. [RxDataSourceStarterKit](#rxdatasourcestarterkit)
1. [RxDataSources](#rxdatasources)
1. [Driver](Units.md#driver-unit)
1. [Examples](Examples.md)
@ -1130,12 +1130,10 @@ public struct Logging {
}
```
## RxDataSourceStarterKit
## RxDataSources
... is a set of classes that implement fully functional reactive data sources for `UITableView`s and `UICollectionView`s.
Source code, more information and rationale why these classes are separated into their directory can be found [here](../RxExample/RxDataSourceStarterKit).
Using them should come down to just importing all of the files into your project.
RxDataSources are bundled [here](https://github.com/RxSwiftCommunity/RxDataSources).
Fully functional demonstration how to use them is included in the [RxExample](../RxExample) project.

View File

@ -67,8 +67,8 @@ If you want to create new scheduler that supports time based operations, then yo
```swift
public protocol Scheduler: ImmediateScheduler {
typealias TimeInterval
typealias Time
associatedtype TimeInterval
associatedtype Time
var now : Time {
get

View File

@ -1,7 +1,8 @@
<img src="assets/Rx_Logo_M.png" alt="Miss Electric Eel 2016" width="36" height="36"> RxSwift: ReactiveX for Swift
======================================
[![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux%28experimental%29-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg)
[![Travis CI](https://travis-ci.org/ReactiveX/RxSwift.svg?branch=master)](https://travis-ci.org/ReactiveX/RxSwift) ![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20OSX%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux%28experimental%29-333333.svg) ![pod](https://img.shields.io/cocoapods/v/RxSwift.svg) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
Xcode 7 Swift 2.1 required

View File

@ -29,7 +29,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didUpdateLocations: Observable<[CLLocation]> {
return rx_delegate.observe("locationManager:didUpdateLocations:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didUpdateLocations:)))
.map { a in
return try castOrThrow([CLLocation].self, a[1])
}
@ -39,7 +39,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didFailWithError: Observable<NSError> {
return rx_delegate.observe("locationManager:didFailWithError:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didFailWithError:)))
.map { a in
return try castOrThrow(NSError.self, a[1])
}
@ -50,7 +50,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didFinishDeferredUpdatesWithError: Observable<NSError?> {
return rx_delegate.observe("locationManager:didFinishDeferredUpdatesWithError:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didFinishDeferredUpdatesWithError:)))
.map { a in
return try castOptionalOrThrow(NSError.self, a[1])
}
@ -65,7 +65,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didPauseLocationUpdates: Observable<Void> {
return rx_delegate.observe("locationManagerDidPauseLocationUpdates:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManagerDidPauseLocationUpdates(_:)))
.map { _ in
return ()
}
@ -75,7 +75,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didResumeLocationUpdates: Observable<Void> {
return rx_delegate.observe("locationManagerDidResumeLocationUpdates:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManagerDidResumeLocationUpdates(_:)))
.map { _ in
return ()
}
@ -87,7 +87,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didUpdateHeading: Observable<CLHeading> {
return rx_delegate.observe("locationManager:didUpdateHeading:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didUpdateHeading:)))
.map { a in
return try castOrThrow(CLHeading.self, a[1])
}
@ -99,7 +99,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didEnterRegion: Observable<CLRegion> {
return rx_delegate.observe("locationManager:didEnterRegion:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didEnterRegion:)))
.map { a in
return try castOrThrow(CLRegion.self, a[1])
}
@ -109,7 +109,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didExitRegion: Observable<CLRegion> {
return rx_delegate.observe("locationManager:didExitRegion:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didExitRegion:)))
.map { a in
return try castOrThrow(CLRegion.self, a[1])
}
@ -124,7 +124,7 @@ extension CLLocationManager {
*/
@available(OSX 10.10, *)
public var rx_didDetermineStateForRegion: Observable<(state: CLRegionState, region: CLRegion)> {
return rx_delegate.observe("locationManager:didDetermineState:forRegion:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didDetermineState:forRegion:)))
.map { a in
let stateNumber = try castOrThrow(NSNumber.self, a[1])
let state = CLRegionState(rawValue: stateNumber.integerValue) ?? CLRegionState.Unknown
@ -137,7 +137,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_monitoringDidFailForRegionWithError: Observable<(region: CLRegion?, error: NSError)> {
return rx_delegate.observe("locationManager:monitoringDidFailForRegion:withError:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:monitoringDidFailForRegion:withError:)))
.map { a in
let region = try castOptionalOrThrow(CLRegion.self, a[1])
let error = try castOrThrow(NSError.self, a[2])
@ -149,7 +149,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didStartMonitoringForRegion: Observable<CLRegion> {
return rx_delegate.observe("locationManager:didStartMonitoringForRegion:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didStartMonitoringForRegion:)))
.map { a in
return try castOrThrow(CLRegion.self, a[1])
}
@ -165,7 +165,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didRangeBeaconsInRegion: Observable<(beacons: [CLBeacon], region: CLBeaconRegion)> {
return rx_delegate.observe("locationManager:didRangeBeacons:inRegion:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didRangeBeacons:inRegion:)))
.map { a in
let beacons = try castOrThrow([CLBeacon].self, a[1])
let region = try castOrThrow(CLBeaconRegion.self, a[2])
@ -177,7 +177,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_rangingBeaconsDidFailForRegionWithError: Observable<(region: CLBeaconRegion, error: NSError)> {
return rx_delegate.observe("locationManager:rangingBeaconsDidFailForRegion:withError:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:rangingBeaconsDidFailForRegion:withError:)))
.map { a in
let region = try castOrThrow(CLBeaconRegion.self, a[1])
let error = try castOrThrow(NSError.self, a[2])
@ -192,7 +192,7 @@ extension CLLocationManager {
*/
@available(iOS 8.0, *)
public var rx_didVisit: Observable<CLVisit> {
return rx_delegate.observe("locationManager:didVisit:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didVisit:)))
.map { a in
return try castOrThrow(CLVisit.self, a[1])
}
@ -206,7 +206,7 @@ extension CLLocationManager {
Reactive wrapper for `delegate` message.
*/
public var rx_didChangeAuthorizationStatus: Observable<CLAuthorizationStatus> {
return rx_delegate.observe("locationManager:didChangeAuthorizationStatus:")
return rx_delegate.observe(#selector(CLLocationManagerDelegate.locationManager(_:didChangeAuthorizationStatus:)))
.map { a in
let number = try castOrThrow(NSNumber.self, a[1])
return CLAuthorizationStatus(rawValue: Int32(number.integerValue)) ?? .NotDetermined

View File

@ -180,7 +180,7 @@ extension DriverConvertibleType {
- returns: An observable sequence whose events are printed to standard output.
*/
@warn_unused_result(message="http://git.io/rxs.uo")
public func debug(identifier: String? = nil, file: String = __FILE__, line: UInt = __LINE__, function: String = __FUNCTION__) -> Driver<E> {
public func debug(identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function) -> Driver<E> {
let source = self.asObservable()
.debug(identifier, file: file, line: line, function: function)
return Driver(source)

View File

@ -15,7 +15,7 @@ public protocol KVORepresentable {
/**
Associated KVO type.
*/
typealias KVOType
associatedtype KVOType
/**
Constructs `Self` using KVO value.

View File

@ -28,7 +28,7 @@ import RxSwift
class ControlTarget: RxTarget {
typealias Callback = (Control) -> Void
let selector: Selector = "eventHandler:"
let selector: Selector = #selector(GestureTarget.eventHandler(_:))
weak var control: Control?
#if os(iOS) || os(tvOS)

View File

@ -208,8 +208,8 @@ extension NSObject {
#endif
}
let deallocSelector = "dealloc" as Selector
let rxDeallocatingSelector = RX_selector("dealloc")
let deallocSelector = NSSelectorFromString("dealloc")
let rxDeallocatingSelector = RX_selector(deallocSelector)
let rxDeallocatingSelectorReference = RX_reference_from_selector(rxDeallocatingSelector)
extension NSObject {

View File

@ -30,7 +30,7 @@ extension NSTextStorage {
*/
public var rx_didProcessEditingRangeChangeInLength: Observable<(editedMask:NSTextStorageEditActions, editedRange:NSRange, delta:Int)> {
return rx_delegate
.observe("textStorage:didProcessEditing:range:changeInLength:")
.observe(#selector(NSTextStorageDelegate.textStorage(_:didProcessEditing:range:changeInLength:)))
.map { a in
let editedMask = NSTextStorageEditActions(rawValue: try castOrThrow(UInt.self, a[1]) )
let editedRange = try castOrThrow(NSValue.self, a[2]).rangeValue

View File

@ -22,7 +22,7 @@ public protocol RxCollectionViewDataSourceType /*: UICollectionViewDataSource*/
/**
Type of elements that can be bound to collection view.
*/
typealias Element
associatedtype Element
/**
New observable sequence event observed.

View File

@ -22,7 +22,7 @@ public protocol RxTableViewDataSourceType /*: UITableViewDataSource*/ {
/**
Type of elements that can be bound to table view.
*/
typealias Element
associatedtype Element
/**
New observable sequence event observed.

View File

@ -62,7 +62,7 @@ class BarButtonItemTarget: RxTarget {
self.callback = callback
super.init()
barButtonItem.target = self
barButtonItem.action = Selector("action:")
barButtonItem.action = #selector(BarButtonItemTarget.action(_:))
}
override func dispose() {

View File

@ -133,7 +133,7 @@ extension UICollectionView {
Reactive wrapper for `delegate` message `collectionView:didSelectItemAtIndexPath:`.
*/
public var rx_itemSelected: ControlEvent<NSIndexPath> {
let source = rx_delegate.observe("collectionView:didSelectItemAtIndexPath:")
let source = rx_delegate.observe(#selector(UICollectionViewDelegate.collectionView(_:didSelectItemAtIndexPath:)))
.map { a in
return a[1] as! NSIndexPath
}
@ -145,7 +145,7 @@ extension UICollectionView {
Reactive wrapper for `delegate` message `collectionView:didSelectItemAtIndexPath:`.
*/
public var rx_itemDeselected: ControlEvent<NSIndexPath> {
let source = rx_delegate.observe("collectionView:didDeselectItemAtIndexPath:")
let source = rx_delegate.observe(#selector(UICollectionViewDelegate.collectionView(_:didDeselectItemAtIndexPath:)))
.map { a in
return a[1] as! NSIndexPath
}

View File

@ -18,7 +18,7 @@ import RxSwift
class GestureTarget: RxTarget {
typealias Callback = (UIGestureRecognizer) -> Void
let selector = Selector("eventHandler:")
let selector = #selector(ControlTarget.eventHandler(_:))
weak var gestureRecognizer: UIGestureRecognizer?
var callback: Callback?

View File

@ -32,7 +32,7 @@ import Foundation
*/
public var rx_didFinishPickingMediaWithInfo: Observable<[String : AnyObject]> {
return rx_delegate
.observe("imagePickerController:didFinishPickingMediaWithInfo:")
.observe(#selector(UIImagePickerControllerDelegate.imagePickerController(_:didFinishPickingMediaWithInfo:)))
.map({ (a) in
return try castOrThrow(Dictionary<String, AnyObject>.self, a[1])
})
@ -43,7 +43,7 @@ import Foundation
*/
public var rx_didCancel: Observable<()> {
return rx_delegate
.observe("imagePickerControllerDidCancel:")
.observe(#selector(UIImagePickerControllerDelegate.imagePickerControllerDidCancel(_:)))
.map {_ in () }
}

View File

@ -34,7 +34,7 @@ extension UISearchBar {
let source: Observable<String> = Observable.deferred { [weak self] () -> Observable<String> in
let text = self?.text ?? ""
return (self?.rx_delegate.observe("searchBar:textDidChange:") ?? Observable.empty())
return (self?.rx_delegate.observe(#selector(UISearchBarDelegate.searchBar(_:textDidChange:))) ?? Observable.empty())
.map { a in
return a[1] as? String ?? ""
}
@ -55,7 +55,7 @@ extension UISearchBar {
let source: Observable<Int> = Observable.deferred { [weak self] () -> Observable<Int> in
let index = self?.selectedScopeButtonIndex ?? 0
return (self?.rx_delegate.observe("searchBar:selectedScopeButtonIndexDidChange:") ?? Observable.empty())
return (self?.rx_delegate.observe(#selector(UISearchBarDelegate.searchBar(_:selectedScopeButtonIndexDidChange:))) ?? Observable.empty())
.map { a in
return try castOrThrow(Int.self, a[1])
}

View File

@ -135,7 +135,7 @@ extension UITableView {
Reactive wrapper for `delegate` message `tableView:didSelectRowAtIndexPath:`.
*/
public var rx_itemSelected: ControlEvent<NSIndexPath> {
let source = rx_delegate.observe("tableView:didSelectRowAtIndexPath:")
let source = rx_delegate.observe(#selector(UITableViewDelegate.tableView(_:didSelectRowAtIndexPath:)))
.map { a in
return a[1] as! NSIndexPath
}
@ -147,7 +147,7 @@ extension UITableView {
Reactive wrapper for `delegate` message `tableView:didDeselectRowAtIndexPath:`.
*/
public var rx_itemDeselected: ControlEvent<NSIndexPath> {
let source = rx_delegate.observe("tableView:didDeselectRowAtIndexPath:")
let source = rx_delegate.observe(#selector(UITableViewDelegate.tableView(_:didDeselectRowAtIndexPath:)))
.map { a in
return a[1] as! NSIndexPath
}
@ -159,7 +159,7 @@ extension UITableView {
Reactive wrapper for `delegate` message `tableView:accessoryButtonTappedForRowWithIndexPath:`.
*/
public var rx_itemAccessoryButtonTapped: ControlEvent<NSIndexPath> {
let source: Observable<NSIndexPath> = rx_delegate.observe("tableView:accessoryButtonTappedForRowWithIndexPath:")
let source: Observable<NSIndexPath> = rx_delegate.observe(#selector(UITableViewDelegate.tableView(_:accessoryButtonTappedForRowWithIndexPath:)))
.map { a in
return a[1] as! NSIndexPath
}
@ -171,7 +171,7 @@ extension UITableView {
Reactive wrapper for `delegate` message `tableView:commitEditingStyle:forRowAtIndexPath:`.
*/
public var rx_itemInserted: ControlEvent<NSIndexPath> {
let source = rx_dataSource.observe("tableView:commitEditingStyle:forRowAtIndexPath:")
let source = rx_dataSource.observe(#selector(UITableViewDataSource.tableView(_:commitEditingStyle:forRowAtIndexPath:)))
.filter { a in
return UITableViewCellEditingStyle(rawValue: (a[1] as! NSNumber).integerValue) == .Insert
}
@ -186,7 +186,7 @@ extension UITableView {
Reactive wrapper for `delegate` message `tableView:commitEditingStyle:forRowAtIndexPath:`.
*/
public var rx_itemDeleted: ControlEvent<NSIndexPath> {
let source = rx_dataSource.observe("tableView:commitEditingStyle:forRowAtIndexPath:")
let source = rx_dataSource.observe(#selector(UITableViewDataSource.tableView(_:commitEditingStyle:forRowAtIndexPath:)))
.filter { a in
return UITableViewCellEditingStyle(rawValue: (a[1] as! NSNumber).integerValue) == .Delete
}
@ -201,7 +201,7 @@ extension UITableView {
Reactive wrapper for `delegate` message `tableView:moveRowAtIndexPath:toIndexPath:`.
*/
public var rx_itemMoved: ControlEvent<ItemMovedEvent> {
let source: Observable<ItemMovedEvent> = rx_dataSource.observe("tableView:moveRowAtIndexPath:toIndexPath:")
let source: Observable<ItemMovedEvent> = rx_dataSource.observe(#selector(UITableViewDataSource.tableView(_:moveRowAtIndexPath:toIndexPath:)))
.map { a in
return ((a[1] as! NSIndexPath), (a[2] as! NSIndexPath))
}

View File

@ -23,10 +23,12 @@ extension UITableView {
O.E == [Section]
>
(dataSource: DataSource)
(source: O)
-> (source: O)
-> Disposable {
let differences = source.differentiateForSectionedView()
return self.rx_itemsWithDataSource(dataSource)(source: differences)
return { source in
let differences = source.differentiateForSectionedView()
return self.rx_itemsWithDataSource(dataSource)(source: differences)
}
}
}
@ -40,9 +42,11 @@ extension UICollectionView {
O.E == [Section]
>
(dataSource: DataSource)
(source: O)
-> (source: O)
-> Disposable {
let differences = source.differentiateForSectionedView()
return self.rx_itemsWithDataSource(dataSource)(source: differences)
return { source in
let differences = source.differentiateForSectionedView()
return self.rx_itemsWithDataSource(dataSource)(source: differences)
}
}
}

View File

@ -12,7 +12,7 @@ public struct AnimatableSectionModel<Section: Hashable, ItemType: Hashable>
: Hashable
, AnimatableSectionModelType
, CustomStringConvertible {
public typealias Item = IdentitifiableValue<ItemType>
public typealias Item = IdentifiableValue<ItemType>
public typealias Identity = Section
public var model: Section
@ -25,7 +25,7 @@ public struct AnimatableSectionModel<Section: Hashable, ItemType: Hashable>
public init(model: Section, items: [ItemType]) {
self.model = model
self.items = items.map(IdentitifiableValue.init)
self.items = items.map(IdentifiableValue.init)
}
public init(original: AnimatableSectionModel, items: [Item]) {

View File

@ -11,7 +11,7 @@ import Foundation
public protocol AnimatableSectionModelType
: SectionModelType
, IdentifiableType {
typealias Item : IdentifiableType, Equatable
associatedtype Item : IdentifiableType, Equatable
init(original: Self, items: [Item])
}

View File

@ -8,6 +8,9 @@
import Foundation
import UIKit
#if !RX_NO_MODULE
import RxCocoa
#endif
public class _CollectionViewSectionedDataSource
: NSObject
@ -141,13 +144,18 @@ public class CollectionViewSectionedDataSource<S: SectionModelType>
}
override func _collectionView(collectionView: UICollectionView, canMoveItemAtIndexPath indexPath: NSIndexPath) -> Bool {
return canMoveItemAtIndexPath?(self, indexPath: indexPath) ??
super._collectionView(collectionView, canMoveItemAtIndexPath: indexPath)
guard let canMoveItem = canMoveItemAtIndexPath?(self, indexPath: indexPath) else {
return super._collectionView(collectionView, canMoveItemAtIndexPath: indexPath)
}
return canMoveItem
}
override func _collectionView(collectionView: UICollectionView, moveItemAtIndexPath sourceIndexPath: NSIndexPath, toIndexPath destinationIndexPath: NSIndexPath) {
return moveItem?(self, sourceIndexPath:sourceIndexPath, destinationIndexPath: destinationIndexPath) ??
guard let _ = moveItem?(self, sourceIndexPath:sourceIndexPath, destinationIndexPath: destinationIndexPath) else {
super._collectionView(collectionView, moveItemAtIndexPath: sourceIndexPath, toIndexPath: destinationIndexPath)
return
}
}
}

View File

@ -9,7 +9,7 @@
import Foundation
public protocol IdentifiableType {
typealias Identity: Hashable
associatedtype Identity: Hashable
var identity : Identity { get }
}

View File

@ -8,7 +8,7 @@
import Foundation
public struct IdentitifiableValue<Value: Hashable>
public struct IdentifiableValue<Value: Hashable>
: IdentifiableType
, Equatable
, CustomStringConvertible
@ -30,6 +30,6 @@ public struct IdentitifiableValue<Value: Hashable>
}
}
public func == <V: Hashable>(lhs: IdentitifiableValue<V>, rhs: IdentitifiableValue<V>) -> Bool {
public func == <V: Hashable>(lhs: IdentifiableValue<V>, rhs: IdentifiableValue<V>) -> Bool {
return lhs.value == rhs.value
}

View File

@ -9,7 +9,7 @@
import Foundation
public protocol SectionModelType {
typealias Item
associatedtype Item
var items: [Item] { get }
}

View File

@ -8,6 +8,9 @@
import Foundation
import UIKit
#if !RX_NO_MODULE
import RxCocoa
#endif
// objc monkey business
public class _TableViewSectionedDataSource
@ -176,22 +179,35 @@ public class RxTableViewSectionedDataSource<S: SectionModelType>
}
override func _tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return canEditRowAtIndexPath?(self, indexPath: indexPath) ??
super._tableView(tableView, canMoveRowAtIndexPath: indexPath)
guard let canEditRow = canEditRowAtIndexPath?(self, indexPath: indexPath) else {
return super._tableView(tableView, canMoveRowAtIndexPath: indexPath)
}
return canEditRow
}
override func _tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return canMoveRowAtIndexPath?(self, indexPath: indexPath) ??
super._tableView(tableView, canMoveRowAtIndexPath: indexPath)
guard let canMoveRow = canMoveRowAtIndexPath?(self, indexPath: indexPath) else {
return super._tableView(tableView, canMoveRowAtIndexPath: indexPath)
}
return canMoveRow
}
override func _sectionIndexTitlesForTableView(tableView: UITableView) -> [String]? {
return sectionIndexTitles?(self) ?? super._sectionIndexTitlesForTableView(tableView)
guard let titles = sectionIndexTitles?(self) else {
return super._sectionIndexTitlesForTableView(tableView)
}
return titles
}
override func _tableView(tableView: UITableView, sectionForSectionIndexTitle title: String, atIndex index: Int) -> Int {
return sectionForSectionIndexTitle?(self, title: title, index: index) ??
super._tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index)
guard let section = sectionForSectionIndexTitle?(self, title: title, index: index) else {
return super._tableView(tableView, sectionForSectionIndexTitle: title, atIndex: index)
}
return section
}
}

View File

@ -917,7 +917,7 @@
C8CC3EB01C95CB5300ABA17E /* RxTextViewDelegateProxy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTextViewDelegateProxy.swift; sourceTree = "<group>"; };
C8CC3EB11C95CB5300ABA17E /* UIActivityIndicatorView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIActivityIndicatorView+Rx.swift"; sourceTree = "<group>"; };
C8CC3EB21C95CB5300ABA17E /* UIApplication+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIApplication+Rx.swift"; sourceTree = "<group>"; };
C8CC3EB31C95CB5300ABA17E /* UIBarButtonItem+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Rx.swift"; sourceTree = "<group>"; };
C8CC3EB31C95CB5300ABA17E /* UIBarButtonItem+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIBarButtonItem+Rx.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
C8CC3EB41C95CB5300ABA17E /* UIButton+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIButton+Rx.swift"; sourceTree = "<group>"; };
C8CC3EB51C95CB5300ABA17E /* UICollectionView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UICollectionView+Rx.swift"; sourceTree = "<group>"; };
C8CC3EB61C95CB5300ABA17E /* UIControl+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIControl+Rx.swift"; sourceTree = "<group>"; };

View File

@ -19,7 +19,7 @@ import Foundation
let MB = 1024 * 1024
func exampleError(error: String, location: String = "\(__FILE__):\(__LINE__)") -> NSError {
func exampleError(error: String, location: String = "\(#file):\(#line)") -> NSError {
return NSError(domain: "ExampleError", code: -1, userInfo: [NSLocalizedDescriptionKey: "\(location): \(error)"])
}

View File

@ -202,7 +202,7 @@ extension GitHubSearchRepositoriesAPI {
let range = m.rangeAtIndex(rangeIndex)
let startIndex = links.startIndex.advancedBy(range.location)
let endIndex = startIndex.advancedBy(range.length)
let stringRange = Range(start: startIndex, end: endIndex)
let stringRange = startIndex ..< endIndex
return links.substringWithRange(stringRange)
}

View File

@ -74,7 +74,7 @@ class Randomizer {
if rng.get_random() % 2 == 0 {
let itemIndex = rng.get_random() % (itemCount + 1)
if insertItems {
sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: itemIndex)
sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: itemIndex)
}
else {
nextUnusedItems.append(unusedValue)
@ -83,14 +83,14 @@ class Randomizer {
// update
else {
if itemCount == 0 {
sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: 0)
sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: 0)
continue
}
let itemIndex = rng.get_random() % itemCount
if reloadItems {
nextUnusedItems.append(sections[sectionIndex].items.removeAtIndex(itemIndex).value)
sections[sectionIndex].items.insert(IdentitifiableValue(value: unusedValue), atIndex: itemIndex)
sections[sectionIndex].items.insert(IdentifiableValue(value: unusedValue), atIndex: itemIndex)
}
else {

View File

@ -9,7 +9,7 @@
import Foundation
protocol SynchronizedUnsubscribeType : class {
typealias DisposeKey
associatedtype DisposeKey
func synchronizedUnsubscribe(disposeKey: DisposeKey)
}

View File

@ -23,7 +23,7 @@ struct InfiniteSequence<E> : SequenceType {
func generate() -> Generator {
let repeatedValue = _repeatedValue
return anyGenerator {
return AnyGenerator {
return repeatedValue
}
}

View File

@ -156,7 +156,7 @@ public struct Queue<T>: SequenceType {
var i = dequeueIndex
var count = _count
return anyGenerator {
return AnyGenerator {
if count == 0 {
return nil
}

View File

@ -37,7 +37,7 @@ public class ScheduledDisposable : Cancelable {
- parameter scheduler: Scheduler where the disposable resource will be disposed on.
- parameter disposable: Disposable resource to dispose on the given scheduler.
*/
init(scheduler: ImmediateSchedulerType, disposable: Disposable) {
public init(scheduler: ImmediateSchedulerType, disposable: Disposable) {
self.scheduler = scheduler
_disposable = disposable
}

View File

@ -51,6 +51,7 @@ public class SingleAssignmentDisposable : DisposeBase, Disposable, Cancelable {
}
private func _setDisposable(newValue: Disposable) -> Disposable? {
_lock.lock(); defer { _lock.unlock() }
if _disposableSet {
rxFatalError("oldState.disposable != nil")
}

View File

@ -15,7 +15,7 @@ public protocol ObservableConvertibleType {
/**
Type of elements in sequence.
*/
typealias E
associatedtype E
/**
Converts `self` to `Observable` sequence.

View File

@ -15,7 +15,7 @@ public protocol ObservableType : ObservableConvertibleType {
/**
Type of elements in sequence.
*/
typealias E
associatedtype E
/**
Subscribes `observer` to receive events for this sequence.

View File

@ -21,7 +21,7 @@ extension ObservableType {
- returns: An observable sequence whose events are printed to standard output.
*/
@warn_unused_result(message="http://git.io/rxs.uo")
public func debug(identifier: String? = nil, file: String = __FILE__, line: UInt = __LINE__, function: String = __FUNCTION__)
public func debug(identifier: String? = nil, file: String = #file, line: UInt = #line, function: String = #function)
-> Observable<E> {
return Debug(source: self.asObservable(), identifier: identifier, file: file, line: line, function: function)
}

View File

@ -15,7 +15,7 @@ public protocol ObserverType {
/**
The type of elements in sequence that observer can observe.
*/
typealias E
associatedtype E
/**
Notify observer about sequence event.

View File

@ -139,6 +139,11 @@ public class CurrentThreadScheduler : ImmediateSchedulerType {
let scheduledItem = ScheduledItem(action: action, state: state)
queue.value.enqueue(scheduledItem)
return scheduledItem
// In Xcode 7.3, `return scheduledItem` causes segmentation fault 11 on release build.
// To workaround this compiler issue, returns AnonymousDisposable that disposes scheduledItem.
return AnonymousDisposable {
scheduledItem.dispose()
}
}
}

View File

@ -13,7 +13,7 @@ protocol InvocableType {
}
protocol InvocableWithValueType {
typealias Value
associatedtype Value
func invoke(value: Value)
}

View File

@ -15,12 +15,12 @@ public protocol VirtualTimeConverterType {
/**
Virtual time unit used that represents ticks of virtual clock.
*/
typealias VirtualTimeUnit
associatedtype VirtualTimeUnit
/**
Virtual time unit used to represent differences of virtual times.
*/
typealias VirtualTimeIntervalUnit
associatedtype VirtualTimeIntervalUnit
/**
Converts virtual time to real time.

View File

@ -17,7 +17,7 @@ public protocol SubjectType : ObservableType {
Usually this type is type of subject itself, but it doesn't have to be.
*/
typealias SubjectObserverType : ObserverType
associatedtype SubjectObserverType : ObserverType
/**
Returns observer interface for subject.

View File

@ -58,7 +58,7 @@ Event is considered equal if:
- parameter lhs: first set of events.
- parameter lhs: second set of events.
*/
public func XCTAssertEqual<T: Equatable>(lhs: [Event<T>], _ rhs: [Event<T>], file: String = __FILE__, line: UInt = __LINE__) {
public func XCTAssertEqual<T: Equatable>(lhs: [Event<T>], _ rhs: [Event<T>], file: StaticString = #file, line: UInt = #line) {
let leftEquatable = lhs.map { AnyEquatable(target: $0, comparer: ==) }
let rightEquatable = rhs.map { AnyEquatable(target: $0, comparer: ==) }
#if os(Linux)
@ -86,7 +86,7 @@ Event is considered equal if:
- parameter lhs: first set of events.
- parameter lhs: second set of events.
*/
public func XCTAssertEqual<T: Equatable>(lhs: [Recorded<Event<T>>], _ rhs: [Recorded<Event<T>>], file: String = __FILE__, line: UInt = __LINE__) {
public func XCTAssertEqual<T: Equatable>(lhs: [Recorded<Event<T>>], _ rhs: [Recorded<Event<T>>], file: StaticString = #file, line: UInt = #line) {
let leftEquatable = lhs.map { AnyEquatable(target: $0, comparer: ==) }
let rightEquatable = rhs.map { AnyEquatable(target: $0, comparer: ==) }
#if os(Linux)

View File

@ -166,7 +166,7 @@ extension ObservableBlockingTest {
func testLast_independent() {
for i in 0 ..< 10 {
let scheduler = ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .Default)
let scheduler = ConcurrentDispatchQueueScheduler(globalConcurrentQueueQOS: .Background)
func operation1()->Observable<Int>{
return Observable.just(1).subscribeOn(scheduler)

View File

@ -91,9 +91,10 @@ extension RxTest {
func tearDownActions() {
#if TRACE_RESOURCES
// give 5 sec to clean up resources
for _ in 0..<10 {
for _ in 0..<30 {
if self.startResourceCount < resourceCount {
// main schedulers need to finish work
print("Waiting for resource cleanup ...")
NSRunLoop.currentRunLoop().runMode(NSDefaultRunLoopMode, beforeDate: NSDate(timeIntervalSinceNow: 0.05))
}
else {

View File

@ -23,7 +23,7 @@ BOLDWHITE="\033[1m\033[37m"
DEFAULT_IOS7_SIMULATOR=RxSwiftTest/iPhone-4s/iOS/7.1
DEFAULT_IOS8_SIMULATOR=RxSwiftTest/iPhone-6/iOS/8.4
DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.2
DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.3
DEFAULT_WATCHOS2_SIMULATOR=RxSwiftTest/Apple-Watch-38mm/watchOS/2.1
DEFAULT_TVOS_SIMULATOR=RxSwiftTest/Apple-TV-1080p/tvOS/9.1
@ -90,14 +90,6 @@ function ensure_simulator_available() {
xcrun simctl create "${SIMULATOR}" "com.apple.CoreSimulator.SimDeviceType.${DEVICE}" "${RUNTIME}"
}
if runtime_available "com.apple.CoreSimulator.SimRuntime.iOS-9-2"; then
DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.2
elif runtime_available "com.apple.CoreSimulator.SimRuntime.iOS-9-1"; then
DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.1
else
DEFAULT_IOS9_SIMULATOR=RxSwiftTest/iPhone-6/iOS/9.0
fi
BUILD_DIRECTORY=build
function rx() {
@ -139,7 +131,7 @@ function action() {
-configuration "${CONFIGURATION}" \
-derivedDataPath "${BUILD_DIRECTORY}" \
-destination "$DESTINATION" \
$ACTION | xcpretty -c; STATUS=${PIPESTATUS[0]}
$ACTION | tee build/last-build-output.txt | xcpretty -c; STATUS=${PIPESTATUS[0]}
set +x
if [ $STATUS -ne 0 ]; then