Skip to content

Commit 525e81a

Browse files
committed
Improving KVO code and KVO documentation.
1 parent d571769 commit 525e81a

File tree

11 files changed

+382
-63
lines changed

11 files changed

+382
-63
lines changed

Documentation/API.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,18 @@ extension NSObject {
102102
```swift
103103
extension NSObject {
104104

105-
public func rx_observe<Element>(keyPath: String) -> Observable<Element?> {}
106-
107-
public func rx_observe<Element>(keyPath: String, options: NSKeyValueObservingOptions) -> Observable<Element?> {}
108-
109-
public func rx_observe<Element>(keyPath: String, options: NSKeyValueObservingOptions, retainSelf: Bool) -> Observable<Element?> {}
105+
public func rx_observe<Element>(
106+
keyPath: String,
107+
options: NSKeyValueObservingOptions = .New | .Initial,
108+
retainSelf: Bool = true
109+
) -> Observable<Element?> {}
110110

111111
#if !DISABLE_SWIZZLING
112112

113-
public func rx_observeWeakly<Element>(keyPath: String) -> Observable<Element?> {}
114-
115-
public func rx_observeWeakly<Element>(keyPath: String, options: NSKeyValueObservingOptions) -> Observable<Element?> {}
113+
public func rx_observeWeakly<Element>(
114+
keyPath: String,
115+
options: NSKeyValueObservingOptions = .New | .Initial
116+
) -> Observable<Element?> {}
116117

117118
#endif
118119
}

Documentation/DesignRationale.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ What you really need is a generic way to prove traits for sequences (`Observable
3838
* sequence terminates in finite time (server side)
3939
* sequence contains only one element (if you are running some computation)
4040
* sequence doesn't error out, never terminates and elements are delivered on main scheduler (UI)
41-
* sequence doesn't error out, never terminates and elements are delivered on main scheduler, and have refcounted sharing (UI)
41+
* sequence doesn't error out, never terminates and elements are delivered on main scheduler, and has refcounted sharing (UI)
4242
* sequence doesn't error out, never terminates and elements are delivered on specific background scheduler (audio engine)
4343

4444
What you really want is a general compiler enforced system of traits for observable sequences, and a set of invariant operators for those wanted properties.

0 commit comments

Comments
 (0)