Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rac5 swift3 #153

Merged
merged 4 commits into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "ReactiveCocoa/ReactiveCocoa" "RAC5"
github "ReactiveCocoa/ReactiveCocoa" "master"
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "antitypical/Result" "8f1affd40bc2b10a15f56ff6cb7b00639e29cb35"
github "ReactiveCocoa/ReactiveCocoa" "8213f2e47c3228ad1895bf74c9b6dba541a45aa7"
github "antitypical/Result" "3.0.0-alpha.2"
github "ReactiveCocoa/ReactiveCocoa" "d98489ae97b020ccdd9a8c8ccad2b67429817669"
2 changes: 1 addition & 1 deletion Deprecations+Removals.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extension Data {
public static func rex_dataWithContentsOfURL(_ url: URL, options: Data.ReadingOptions = []) -> SignalProducer<Data, NSError> { fatalError() }
}

extension NSData {
extension Data {
@available(*, unavailable, renamed:"rex_data(contentsOf:options:)")
public static func rex_dataWithContentsOfURL(_ url: URL, options: NSData.ReadingOptions = []) -> SignalProducer<NSData, NSError> { fatalError() }
}
6 changes: 6 additions & 0 deletions Rex.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,11 @@
};
D83457131AFEE44E0070616A = {
CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0800;
};
D834571D1AFEE44E0070616A = {
CreatedOnToolsVersion = 6.3;
LastSwiftMigration = 0800;
};
D8715D931C210F97005F4191 = {
CreatedOnToolsVersion = 7.2;
Expand Down Expand Up @@ -1221,6 +1223,7 @@
PRODUCT_NAME = "$(PROJECT_NAME)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -1248,6 +1251,7 @@
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
Expand All @@ -1273,6 +1277,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "me.neilpa.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_VERSION = 3.0;
};
name = Debug;
};
Expand All @@ -1292,6 +1297,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
2 changes: 1 addition & 1 deletion Source/Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extension Data {
}
}

extension NSData {
extension Data {
/// Read the data at the URL, sending the result or an error.
public static func rex_data(contentsOf url: URL, options: NSData.ReadingOptions = []) -> SignalProducer<NSData, NSError> {
return Data.rex_data(contentsOf: url, options: options).map { $0 as NSData }
Expand Down
2 changes: 1 addition & 1 deletion Source/Foundation/UserDefaults.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension UserDefaults {
return SignalProducer<AnyObject?, NoError>(value: initial)
.concat(changes)
.skipRepeats { previous, next in
if let previous = previous as? NSObject, next = next as? NSObject {
if let previous = previous as? NSObject, let next = next as? NSObject {
return previous == next
}
return false
Expand Down
16 changes: 8 additions & 8 deletions Source/SignalProducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extension SignalProducerProtocol {
return SignalProducer<(Key, SignalProducer<Value, Error>), Error> { observer, disposable in
var groups: [Key: Signal<Value, Error>.Observer] = [:]

let lock = RecursiveLock()
let lock = NSRecursiveLock()
lock.name = "me.neilpa.rex.groupBy"

self.start { event in
Expand Down Expand Up @@ -96,7 +96,7 @@ extension SignalProducerProtocol {
}

/// Delays retrying on failure by `interval` up to `count` attempts.
public func deferredRetry(interval: TimeInterval, on scheduler: DateSchedulerProtocol, count: Int = .max) -> SignalProducer<Value, Error> {
public func deferredRetry(_ interval: TimeInterval, on scheduler: DateSchedulerProtocol, count: Int = .max) -> SignalProducer<Value, Error> {
precondition(count >= 0)

if count == 0 {
Expand Down Expand Up @@ -205,25 +205,25 @@ private final class ReplayBuffer<Value> {
private var values: [Value] = []
}

private struct BufferState<Value, Error: ErrorProtocol> {
private struct BufferState<V, E: Error> {
/// All values in the buffer.
var values: [Value] = []
var values: [V] = []

/// Any terminating event sent to the buffer.
///
/// This will be nil if termination has not occurred.
var terminationEvent: Event<Value, Error>?
var terminationEvent: Event<V, E>?

/// The observers currently attached to the buffered producer, or nil if the
/// producer was terminated.
var observers: Bag<Signal<Value, Error>.Observer>? = Bag()
var observers: Bag<Signal<V, E>.Observer>? = Bag()

/// The set of unused replay token identifiers.
var replayBuffers: Bag<ReplayBuffer<Value>> = Bag()
var replayBuffers: Bag<ReplayBuffer<V>> = Bag()

/// Appends a new value to the buffer, trimming it down to the given capacity
/// if necessary.
mutating func add(_ value: Value, upTo capacity: Int) {
mutating func add(_ value: V, upTo capacity: Int) {
precondition(capacity >= 0)

for buffer in replayBuffers {
Expand Down
3 changes: 1 addition & 2 deletions Source/UIKit/UIActivityIndicatorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ extension UIActivityIndicatorView {
/// Setting a new value to the property would call `startAnimating()` or
/// `stopAnimating()` depending on the value.
public var rex_animating: MutableProperty<Bool> {
return associatedProperty(self, key: &animatingKey, initial: { $0.isAnimating() }, setter: { host, animating in
return associatedProperty(self, key: &animatingKey, initial: { $0.isAnimating }, setter: { host, animating in
if animating {
host.startAnimating()
} else {
host.stopAnimating()
}
})
}

}

private var animatingKey: UInt8 = 0
2 changes: 1 addition & 1 deletion Source/UIKit/UILabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extension UILabel {
}

/// Wraps a label's `attributedText` value in a bindable property.
public var rex_attributedText: MutableProperty<AttributedString?> {
public var rex_attributedText: MutableProperty<NSAttributedString?> {
return associatedProperty(self, key: &attributedTextKey, initial: { $0.attributedText }, setter: { $0.attributedText = $1 })
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/ActionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import enum Result.NoError

final class ActionTests: XCTestCase {

enum TestError: ErrorProtocol {
enum TestError: Error {
case unknown
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Foundation/NSObjectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ final class NSObjectTests: XCTestCase {

func testObjectsWillBeDeallocatedSignal() {

let expectation = self.expectation(withDescription: "Expected timer to send `completed` event when object deallocates")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected timer to send `completed` event when object deallocates")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let object = Object()

Expand Down
4 changes: 2 additions & 2 deletions Tests/PropertyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final class PropertyTests: XCTestCase {
XCTAssertTrue(current!)

let (signal, pipe) = Signal<Bool, NoError>.pipe()
let and2 = and.and(AnyProperty(initial: false, then: signal))
let and2 = and.and(Property(initial: false, then: signal))
and2.producer.startWithNext { current = $0 }

XCTAssertFalse(and2.value)
Expand Down Expand Up @@ -62,7 +62,7 @@ final class PropertyTests: XCTestCase {
XCTAssertFalse(current!)

let (signal, pipe) = Signal<Bool, NoError>.pipe()
let or2 = or.or(AnyProperty(initial: true, then: signal))
let or2 = or.or(Property(initial: true, then: signal))
or2.producer.startWithNext { current = $0 }

XCTAssertTrue(or2.value)
Expand Down
4 changes: 2 additions & 2 deletions Tests/SignalProducerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ final class SignalProducerTests: XCTestCase {
var value = -1
var completed = false
producer
.deferredRetry(interval: 1, on: scheduler)
.deferredRetry(1, on: scheduler)
.start(Observer(
next: { value = $0 },
completed: { completed = true }
Expand Down Expand Up @@ -136,7 +136,7 @@ final class SignalProducerTests: XCTestCase {
var value = -1
var failed = false
producer
.deferredRetry(interval: 1, on: scheduler, count: 2)
.deferredRetry(1, on: scheduler, count: 2)
.start(Observer(
next: { value = $0 },
failed: { _ in failed = true }
Expand Down
2 changes: 1 addition & 1 deletion Tests/SignalTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ final class SignalTests: XCTestCase {
}
}

enum TestError: ErrorProtocol {
enum TestError: Error {
case `default`
}
4 changes: 2 additions & 2 deletions Tests/UIKit/UIActivityIndicatorViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class UIActivityIndicatorTests: XCTestCase {
indicatorView.rex_animating <~ SignalProducer(signal: pipeSignal)

observer.sendNext(true)
XCTAssertTrue(indicatorView.isAnimating())
XCTAssertTrue(indicatorView.isAnimating)
observer.sendNext(false)
XCTAssertFalse(indicatorView.isAnimating())
XCTAssertFalse(indicatorView.isAnimating)
}
}
4 changes: 2 additions & 2 deletions Tests/UIKit/UIDatePickerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class UIDatePickerTests: XCTestCase {
}

func testUpdatePropertyFromPicker() {
let expectation = self.expectation(withDescription: "Expected rex_date to send an event when picker's date value is changed by a UI event")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected rex_date to send an event when picker's date value is changed by a UI event")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

picker.rex_date.signal.observeNext { changedDate in
XCTAssertEqual(changedDate, self.date)
Expand Down
16 changes: 8 additions & 8 deletions Tests/UIKit/UILabelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ class UILabelTests: XCTestCase {
let label = UILabel(frame: CGRect.zero)
_label = label

label.rex_attributedText <~ SignalProducer(value: AttributedString(string: "Test"))
label.rex_attributedText <~ SignalProducer(value: NSAttributedString(string: "Test"))
XCTAssert(_label?.attributedText?.string == "Test")
}

func testAttributedTextProperty() {
let firstChange = AttributedString(string: "first")
let secondChange = AttributedString(string: "second")
let firstChange = NSAttributedString(string: "first")
let secondChange = NSAttributedString(string: "second")

let label = UILabel(frame: CGRect.zero)
label.attributedText = AttributedString(string: "")
label.attributedText = NSAttributedString(string: "")

let (pipeSignal, observer) = Signal<AttributedString?, NoError>.pipe()
let (pipeSignal, observer) = Signal<NSAttributedString?, NoError>.pipe()
label.rex_attributedText <~ SignalProducer(signal: pipeSignal)

observer.sendNext(firstChange)
Expand All @@ -71,13 +71,13 @@ class UILabelTests: XCTestCase {
}

func testTextColorProperty() {
let firstChange = UIColor.red()
let secondChange = UIColor.black()
let firstChange = UIColor.red
let secondChange = UIColor.black

let label = UILabel(frame: CGRect.zero)

let (pipeSignal, observer) = Signal<UIColor, NoError>.pipe()
label.textColor = UIColor.black()
label.textColor = UIColor.black
label.rex_textColor <~ SignalProducer(signal: pipeSignal)

observer.sendNext(firstChange)
Expand Down
4 changes: 2 additions & 2 deletions Tests/UIKit/UITextFieldTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import XCTest
class UITextFieldTests: XCTestCase {

func testTextProperty() {
let expectation = self.expectation(withDescription: "Expected `rex_text`'s value to equal to the textField's text")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected `rex_text`'s value to equal to the textField's text")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let textField = UITextField(frame: CGRect.zero)
textField.text = "Test"
Expand Down
4 changes: 2 additions & 2 deletions Tests/UIKit/UITextViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import XCTest
class UITextViewTests: XCTestCase {

func testTextProperty() {
let expectation = self.expectation(withDescription: "Expected `rex_text`'s value to equal to the textViews's text")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected `rex_text`'s value to equal to the textViews's text")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let textView = UITextView(frame: CGRect.zero)
textView.text = "Test"
Expand Down
24 changes: 12 additions & 12 deletions Tests/UIKit/UIViewControllerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class UIViewControllerTests: XCTestCase {

func testViewDidDisappear() {

let expectation = self.expectation(withDescription: "Expected rex_viewDidDisappear to be triggered")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected rex_viewDidDisappear to be triggered")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let viewController = UIViewController()
_viewController = viewController
Expand All @@ -37,8 +37,8 @@ class UIViewControllerTests: XCTestCase {

func testViewWillDisappear() {

let expectation = self.expectation(withDescription: "Expected rex_viewWillDisappear to be triggered")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected rex_viewWillDisappear to be triggered")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let viewController = UIViewController()
_viewController = viewController
Expand All @@ -52,8 +52,8 @@ class UIViewControllerTests: XCTestCase {

func testViewDidAppear() {

let expectation = self.expectation(withDescription: "Expected rex_viewDidAppear to be triggered")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected rex_viewDidAppear to be triggered")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let viewController = UIViewController()
_viewController = viewController
Expand All @@ -67,8 +67,8 @@ class UIViewControllerTests: XCTestCase {

func testViewWillAppear() {

let expectation = self.expectation(withDescription: "Expected rex_viewWillAppear to be triggered")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected rex_viewWillAppear to be triggered")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let viewController = UIViewController()
_viewController = viewController
Expand All @@ -82,8 +82,8 @@ class UIViewControllerTests: XCTestCase {

func testDismissViewController_via_property() {

let expectation = self.expectation(withDescription: "Expected rex_dismissModally to be triggered")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected rex_dismissModally to be triggered")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let viewController = UIViewController()
_viewController = viewController
Expand All @@ -97,8 +97,8 @@ class UIViewControllerTests: XCTestCase {

func testDismissViewController_via_cocoaDismiss() {

let expectation = self.expectation(withDescription: "Expected rex_dismissModally to be triggered")
defer { self.waitForExpectations(withTimeout: 2, handler: nil) }
let expectation = self.expectation(description: "Expected rex_dismissModally to be triggered")
defer { self.waitForExpectations(timeout: 2, handler: nil) }

let viewController = UIViewController()
_viewController = viewController
Expand Down