Skip to content

Commit

Permalink
Merge pull request #73 from neilpa/docs
Browse files Browse the repository at this point in the history
Few missing docs
  • Loading branch information
neilpa committed Dec 16, 2015
2 parents 590b569 + 357513f commit 28c6d23
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Source/Foundation/NSData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import Foundation
import ReactiveCocoa

extension NSData {
/// Read the data at the URL.
/// Sends the data or the error.
/// Read the data at the URL, sending the result or an error.
public class func rex_dataWithContentsOfURL(url: NSURL, options: NSDataReadingOptions = NSDataReadingOptions()) -> SignalProducer<NSData, NSError> {
return SignalProducer<NSData, NSError> { observer, disposable in
do {
Expand Down
13 changes: 13 additions & 0 deletions Source/Property.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,33 @@
import ReactiveCocoa

extension PropertyType where Value == Bool {
/// The conjunction of `self` and `other`.
public func and<P: PropertyType where P.Value == Bool>(other: P) -> AndProperty {
return AndProperty(terms: [AnyProperty(self), AnyProperty(other)])
}

/// The conjunction of `self` and `other`.
public func and(other: AnyProperty<Bool>) -> AndProperty {
return AndProperty(terms: [AnyProperty(self), other])
}

/// The disjunction of `self` and `other`.
public func or<P: PropertyType where P.Value == Bool>(other: P) -> OrProperty {
return OrProperty(terms: [AnyProperty(self), AnyProperty(other)])
}

/// The disjunction of `self` and `other`.
public func or(other: AnyProperty<Bool>) -> OrProperty {
return OrProperty(terms: [AnyProperty(self), other])
}

/// A negated property of `self`.
public func not() -> NotProperty {
return NotProperty(source: AnyProperty(self), invert: true)
}
}

/// Specialized `PropertyType` for the conjuction of a set of boolean properties.
public struct AndProperty: PropertyType {
public let terms: [AnyProperty<Bool>]

Expand All @@ -44,10 +50,12 @@ public struct AndProperty: PropertyType {
}
}

/// Creates a new property with an additional conjunctive term.
public func and<P : PropertyType where P.Value == Bool>(other: P) -> AndProperty {
return AndProperty(terms: terms + [AnyProperty(other)])
}

/// Creates a new property with an additional conjunctive term.
public func and(other: AnyProperty<Bool>) -> AndProperty {
return AndProperty(terms: terms + [other])
}
Expand All @@ -57,6 +65,7 @@ public struct AndProperty: PropertyType {
}
}

/// Specialized `PropertyType` for the disjunction of a set of boolean properties.
public struct OrProperty: PropertyType {
public let terms: [AnyProperty<Bool>]

Expand All @@ -71,10 +80,12 @@ public struct OrProperty: PropertyType {
}
}

/// Creates a new property with an additional disjunctive term.
public func or<P : PropertyType where P.Value == Bool>(other: P) -> OrProperty {
return OrProperty(terms: terms + [AnyProperty(other)])
}

/// Creates a new property with an additional disjunctive term.
public func or(other: AnyProperty<Bool>) -> OrProperty {
return OrProperty(terms: terms + [other])
}
Expand All @@ -84,6 +95,7 @@ public struct OrProperty: PropertyType {
}
}

/// Specialized `PropertyType` for the negation of a boolean property.
public struct NotProperty: PropertyType {
private let source: AnyProperty<Bool>
private let invert: Bool
Expand All @@ -96,6 +108,7 @@ public struct NotProperty: PropertyType {
return source.producer.map { $0 != self.invert }
}

/// A negated property of `self`.
public func not() -> NotProperty {
return NotProperty(source: source, invert: !invert)
}
Expand Down
3 changes: 2 additions & 1 deletion Source/UIKit/UILabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ extension UILabel {
public var rex_text: MutableProperty<String> {
return associatedProperty(self, keyPath: "text")
}


/// Wraps a label's `textColor` value in a bindable property.
public var rex_textColor: MutableProperty<UIColor> {
return associatedProperty(self, key: &textColor, initial: { $0.textColor }, setter: { $0.textColor = $1 })
}
Expand Down

0 comments on commit 28c6d23

Please sign in to comment.