Skip to content

Commit 947f990

Browse files
committed
Merge branch 'master' into reactive-swift
# Conflicts: # ReactiveCocoa.xcodeproj/project.pbxproj # ReactiveCocoa/Swift/Lifetime.swift # ReactiveSwiftTests/PropertySpec.swift
2 parents 3bcd165 + 0859e13 commit 947f990

File tree

14 files changed

+535
-440
lines changed

14 files changed

+535
-440
lines changed

Cartfile.private

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
github "jspahrsummers/xcconfigs" "1ef9763"
1+
github "jspahrsummers/xcconfigs" "3d9d996"
22
github "norio-nomura/Quick" "nn-swift-3-compatibility"
33
github "norio-nomura/Nimble" "nn-swift-3-compatibility"

Cartfile.resolved

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
github "norio-nomura/Nimble" "3d82a185b49e8fc9f40e7b72feeb279c778f0935"
22
github "norio-nomura/Quick" "4a7f1d0a7db637c3ca15b8f198a516fbc5581f87"
33
github "antitypical/Result" "3.0.0-alpha.4"
4-
github "jspahrsummers/xcconfigs" "1ef97639ffbe041da0b1392b2114fa19b922a7a1"
4+
github "jspahrsummers/xcconfigs" "3d9d99634cae6d586e272543d527681283b33eb0"

Carthage/Checkouts/xcconfigs

ReactiveCocoa.xcodeproj/project.pbxproj

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@
825825
7A7065831A3F8967001E8354 /* RACKVOProxySpec.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RACKVOProxySpec.m; sourceTree = "<group>"; };
826826
7DFBED031CDB8C9500EE435B /* ReactiveCocoaTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ReactiveCocoaTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
827827
9A1E72B91D4DE96500CC20C3 /* KeyValueObservingSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyValueObservingSpec.swift; sourceTree = "<group>"; };
828+
9A694EF21D5CE02E009B05BD /* UnidirectionalBinding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnidirectionalBinding.swift; sourceTree = "<group>"; };
828829
9ABCB1841D2A5B5A00BCA243 /* Deprecations+Removals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Deprecations+Removals.swift"; sourceTree = "<group>"; };
829830
9AD0F0691D48BA4800ADFAB7 /* NSObject+KeyValueObserving.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSObject+KeyValueObserving.swift"; sourceTree = "<group>"; };
830831
A97451331B3A935E00F48E55 /* watchOS-Application.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "watchOS-Application.xcconfig"; sourceTree = "<group>"; };
@@ -2279,6 +2280,7 @@
22792280
57A4D1F81BA13D7A00F7D4B1 /* RACSignalSequence.m in Sources */,
22802281
57A4D1F91BA13D7A00F7D4B1 /* RACStream.m in Sources */,
22812282
57A4D1FA1BA13D7A00F7D4B1 /* RACStringSequence.m in Sources */,
2283+
9A694EF61D5CE02E009B05BD /* UnidirectionalBinding.swift in Sources */,
22822284
CD0C45E11CC9A288009F5BF0 /* DynamicProperty.swift in Sources */,
22832285
57A4D1FB1BA13D7A00F7D4B1 /* RACSubject.m in Sources */,
22842286
57A4D1FC1BA13D7A00F7D4B1 /* RACSubscriber.m in Sources */,
@@ -2401,6 +2403,7 @@
24012403
A9B3158D1B3940750001CB9C /* RACKVOTrampoline.m in Sources */,
24022404
A9B3158E1B3940750001CB9C /* RACMulticastConnection.m in Sources */,
24032405
C7142DBE1CDEA194009F402D /* CocoaAction.swift in Sources */,
2406+
9A694EF51D5CE02E009B05BD /* UnidirectionalBinding.swift in Sources */,
24042407
A9B315901B3940750001CB9C /* RACPassthroughSubscriber.m in Sources */,
24052408
A9B315911B3940750001CB9C /* RACQueueScheduler.m in Sources */,
24062409
A9B315921B3940750001CB9C /* RACReplaySubject.m in Sources */,
@@ -2941,8 +2944,6 @@
29412944
baseConfigurationReference = D047262919E49FE8006002AA /* Debug.xcconfig */;
29422945
buildSettings = {
29432946
BITCODE_GENERATION_MODE = bitcode;
2944-
CLANG_WARN_INFINITE_RECURSION = YES;
2945-
CLANG_WARN_SUSPICIOUS_MOVE = YES;
29462947
CODE_SIGNING_REQUIRED = NO;
29472948
CURRENT_PROJECT_VERSION = 1;
29482949
ENABLE_BITCODE = NO;
@@ -2965,8 +2966,6 @@
29652966
baseConfigurationReference = D047262B19E49FE8006002AA /* Release.xcconfig */;
29662967
buildSettings = {
29672968
BITCODE_GENERATION_MODE = bitcode;
2968-
CLANG_WARN_INFINITE_RECURSION = YES;
2969-
CLANG_WARN_SUSPICIOUS_MOVE = YES;
29702969
CODE_SIGNING_REQUIRED = NO;
29712970
CURRENT_PROJECT_VERSION = 1;
29722971
ENABLE_BITCODE = NO;
@@ -3096,8 +3095,6 @@
30963095
baseConfigurationReference = D047262A19E49FE8006002AA /* Profile.xcconfig */;
30973096
buildSettings = {
30983097
BITCODE_GENERATION_MODE = bitcode;
3099-
CLANG_WARN_INFINITE_RECURSION = YES;
3100-
CLANG_WARN_SUSPICIOUS_MOVE = YES;
31013098
CODE_SIGNING_REQUIRED = NO;
31023099
CURRENT_PROJECT_VERSION = 1;
31033100
ENABLE_BITCODE = NO;
@@ -3172,8 +3169,6 @@
31723169
baseConfigurationReference = D047262C19E49FE8006002AA /* Test.xcconfig */;
31733170
buildSettings = {
31743171
BITCODE_GENERATION_MODE = bitcode;
3175-
CLANG_WARN_INFINITE_RECURSION = YES;
3176-
CLANG_WARN_SUSPICIOUS_MOVE = YES;
31773172
CODE_SIGNING_REQUIRED = NO;
31783173
CURRENT_PROJECT_VERSION = 1;
31793174
ENABLE_BITCODE = NO;

ReactiveCocoa/Objective-C/RACCompoundDisposable.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ - (instancetype)initWithDisposables:(NSArray *)otherDisposables {
9494

9595
#if RACCompoundDisposableInlineCount
9696
[otherDisposables enumerateObjectsUsingBlock:^(RACDisposable *disposable, NSUInteger index, BOOL *stop) {
97-
_inlineDisposables[index] = disposable;
97+
self->_inlineDisposables[index] = disposable;
9898

9999
// Stop after this iteration if we've reached the end of the inlined
100100
// array.

ReactiveCocoa/Swift/DynamicProperty.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public final class DynamicProperty<Value>: MutablePropertyProtocol {
3737
}
3838
}
3939

40+
/// The lifetime of the property.
41+
public var lifetime: Lifetime {
42+
return object?.rac_lifetime ?? .empty
43+
}
44+
4045
/// A producer that will create a Key-Value Observer for the given object,
4146
/// send its initial value then all changes over time, and then complete
4247
/// when the observed object has deallocated.

ReactiveCocoaTests/Swift/DynamicPropertySpec.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,21 @@ class DynamicPropertySpec: QuickSpec {
179179
dynamicProperty.value = UnbridgedObject("foo")
180180
expect(object.rac_reference.value) == "foo"
181181
}
182+
183+
it("should expose a lifetime that ends upon the deinitialization of its underlying object") {
184+
var isEnded = false
185+
property!.lifetime.ended.observeCompleted {
186+
isEnded = true
187+
}
188+
189+
expect(isEnded) == false
190+
191+
property = nil
192+
expect(isEnded) == false
193+
194+
object = nil
195+
expect(isEnded) == true
196+
}
182197
}
183198

184199
describe("binding") {

ReactiveSwift.xcodeproj/project.pbxproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@
7272
A9F793341B60D0140026BCBA /* Optional.swift in Sources */ = {isa = PBXBuildFile; fileRef = D871D69E1B3B29A40070F16C /* Optional.swift */; };
7373
B696FB811A7640C00075236D /* TestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B696FB801A7640C00075236D /* TestError.swift */; };
7474
B696FB821A7640C00075236D /* TestError.swift in Sources */ = {isa = PBXBuildFile; fileRef = B696FB801A7640C00075236D /* TestError.swift */; };
75+
BE9CF3951D751B6B003AE479 /* UnidirectionalBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE9CF3941D751B6B003AE479 /* UnidirectionalBinding.swift */; };
76+
BE9CF3961D751B70003AE479 /* UnidirectionalBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE9CF3941D751B6B003AE479 /* UnidirectionalBinding.swift */; };
77+
BE9CF3971D751B71003AE479 /* UnidirectionalBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE9CF3941D751B6B003AE479 /* UnidirectionalBinding.swift */; };
78+
BE9CF3981D751B71003AE479 /* UnidirectionalBinding.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE9CF3941D751B6B003AE479 /* UnidirectionalBinding.swift */; };
7579
BFA6B94D1A7604D400C846D1 /* SignalProducerNimbleMatchers.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA6B94A1A76044800C846D1 /* SignalProducerNimbleMatchers.swift */; };
7680
BFA6B94E1A7604D500C846D1 /* SignalProducerNimbleMatchers.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA6B94A1A76044800C846D1 /* SignalProducerNimbleMatchers.swift */; };
7781
C79B64741CD38B2B003F2376 /* TestLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = C79B64731CD38B2B003F2376 /* TestLogger.swift */; };
@@ -223,6 +227,7 @@
223227
A97451361B3A935E00F48E55 /* watchOS-StaticLibrary.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = "watchOS-StaticLibrary.xcconfig"; sourceTree = "<group>"; };
224228
A9B315541B3940610001CB9C /* ReactiveSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ReactiveSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
225229
B696FB801A7640C00075236D /* TestError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestError.swift; sourceTree = "<group>"; };
230+
BE9CF3941D751B6B003AE479 /* UnidirectionalBinding.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UnidirectionalBinding.swift; sourceTree = "<group>"; };
226231
BFA6B94A1A76044800C846D1 /* SignalProducerNimbleMatchers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SignalProducerNimbleMatchers.swift; sourceTree = "<group>"; };
227232
C79B64731CD38B2B003F2376 /* TestLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestLogger.swift; sourceTree = "<group>"; };
228233
C79B647B1CD52E23003F2376 /* EventLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EventLogger.swift; sourceTree = "<group>"; };
@@ -379,6 +384,7 @@
379384
D08C54B01A69A2AC00AD8286 /* Property.swift */,
380385
D08C54B11A69A2AC00AD8286 /* Signal.swift */,
381386
D08C54B21A69A2AC00AD8286 /* SignalProducer.swift */,
387+
BE9CF3941D751B6B003AE479 /* UnidirectionalBinding.swift */,
382388
);
383389
name = Signals;
384390
sourceTree = "<group>";
@@ -858,6 +864,7 @@
858864
EBCC7DBF1BBF01E200A2AE92 /* Observer.swift in Sources */,
859865
C79B64801CD52E4E003F2376 /* EventLogger.swift in Sources */,
860866
4A0E11021D2A92720065D310 /* Lifetime.swift in Sources */,
867+
BE9CF3981D751B71003AE479 /* UnidirectionalBinding.swift in Sources */,
861868
);
862869
runOnlyForDeploymentPostprocessing = 0;
863870
};
@@ -905,6 +912,7 @@
905912
EBCC7DBE1BBF01E200A2AE92 /* Observer.swift in Sources */,
906913
C79B647F1CD52E4D003F2376 /* EventLogger.swift in Sources */,
907914
4A0E11011D2A92720065D310 /* Lifetime.swift in Sources */,
915+
BE9CF3971D751B71003AE479 /* UnidirectionalBinding.swift in Sources */,
908916
);
909917
runOnlyForDeploymentPostprocessing = 0;
910918
};
@@ -929,6 +937,7 @@
929937
C79B647C1CD52E23003F2376 /* EventLogger.swift in Sources */,
930938
9ABCB1851D2A5B5A00BCA243 /* Deprecations+Removals.swift in Sources */,
931939
D08C54B81A69A9D000AD8286 /* SignalProducer.swift in Sources */,
940+
BE9CF3951D751B6B003AE479 /* UnidirectionalBinding.swift in Sources */,
932941
);
933942
runOnlyForDeploymentPostprocessing = 0;
934943
};
@@ -976,6 +985,7 @@
976985
D0C312E819EF2A5800984962 /* Scheduler.swift in Sources */,
977986
D0C312D019EF2A5800984962 /* Bag.swift in Sources */,
978987
D0D11ABA1A6AE87700C1F8B1 /* Action.swift in Sources */,
988+
BE9CF3961D751B70003AE479 /* UnidirectionalBinding.swift in Sources */,
979989
);
980990
runOnlyForDeploymentPostprocessing = 0;
981991
};

ReactiveSwift/Lifetime.swift

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,28 @@ import enum Result.NoError
44
/// Represents the lifetime of an object, and provides a hook to observe when
55
/// the object deinitializes.
66
public final class Lifetime {
7-
/// A signal that sends a Completed event when the lifetime ends.
7+
/// MARK: Type properties and methods
8+
9+
/// A `Lifetime` that has already ended.
10+
public static var empty: Lifetime {
11+
return Lifetime(ended: .empty)
12+
}
13+
14+
/// MARK: Instance properties
15+
16+
/// A signal that sends a `completed` event when the lifetime ends.
817
public let ended: Signal<(), NoError>
918

19+
/// MARK: Initializers
20+
21+
/// Initialize a `Lifetime` object with the supplied ended signal.
22+
///
23+
/// - parameters:
24+
/// - signal: The ended signal.
25+
private init(ended signal: Signal<(), NoError>) {
26+
ended = signal
27+
}
28+
1029
/// Initialize a `Lifetime` from a lifetime token, which is expected to be
1130
/// associated with an object.
1231
///
@@ -16,8 +35,8 @@ public final class Lifetime {
1635
/// - parameters:
1736
/// - token: A lifetime token for detecting the deinitialization of the
1837
/// associated object.
19-
public init(_ token: Token) {
20-
ended = token.ended
38+
public convenience init(_ token: Token) {
39+
self.init(ended: token.ended)
2140
}
2241

2342
/// A token object which completes its signal when it deinitializes.

0 commit comments

Comments
 (0)