Skip to content

Commit 9f2171b

Browse files
authored
Merge pull request #472 from Igor-Palaguta/AndWithMutableProperty
MutableProperty can be right operand in logical operations
2 parents 9af532e + f375ddb commit 9f2171b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Sources/Property.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ extension PropertyProtocol where Value == Bool {
383383
/// - property: Property to be combined with `self`.
384384
///
385385
/// - returns: A property that contains the logial AND results.
386-
public func and(_ property: Property<Value>) -> Property<Value> {
386+
public func and<P: PropertyProtocol>(_ property: P) -> Property<Value> where P.Value == Value {
387387
return self.lift(SignalProducer.and)(property)
388388
}
389389

@@ -394,7 +394,7 @@ extension PropertyProtocol where Value == Bool {
394394
/// - property: Property to be combined with `self`.
395395
///
396396
/// - returns: A property that contains the logial OR results.
397-
public func or(_ property: Property<Value>) -> Property<Value> {
397+
public func or<P: PropertyProtocol>(_ property: P) -> Property<Value> where P.Value == Value {
398398
return self.lift(SignalProducer.or)(property)
399399
}
400400
}

Tests/ReactiveSwiftTests/PropertySpec.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,27 +1571,27 @@ class PropertySpec: QuickSpec {
15711571
describe("and attribute") {
15721572
it("should emit true when both properties contains the same value") {
15731573
let property1 = MutableProperty(true)
1574-
let property2 = Property(MutableProperty(true))
1574+
let property2 = MutableProperty(true)
15751575
expect(property1.and(property2).value).to(beTrue())
15761576
}
15771577

15781578
it("should emit false when both properties contains opposite values") {
15791579
let property1 = MutableProperty(true)
1580-
let property2 = Property(MutableProperty(false))
1580+
let property2 = MutableProperty(false)
15811581
expect(property1.and(property2).value).to(beFalse())
15821582
}
15831583
}
15841584

15851585
describe("or attribute") {
15861586
it("should emit true when at least one of the properties contains true") {
15871587
let property1 = MutableProperty(true)
1588-
let property2 = Property(MutableProperty(false))
1588+
let property2 = MutableProperty(false)
15891589
expect(property1.or(property2).value).to(beTrue())
15901590
}
15911591

15921592
it("should emit false when both properties contains false") {
15931593
let property1 = MutableProperty(false)
1594-
let property2 = Property(MutableProperty(false))
1594+
let property2 = MutableProperty(false)
15951595
expect(property1.or(property2).value).to(beFalse())
15961596
}
15971597
}

0 commit comments

Comments
 (0)