Skip to content

Commit f20c35a

Browse files
committed
Publicly exposes controlProperty.
1 parent 61261f2 commit f20c35a

17 files changed

+334
-216
lines changed

Rx.xcodeproj/project.pbxproj

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,6 @@
664664
C834F6C41DB394E100C29244 /* Observable+BlockingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = C834F6C11DB394E100C29244 /* Observable+BlockingTest.swift */; };
665665
C834F6C61DB3950600C29244 /* NSControl+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C834F6C51DB3950600C29244 /* NSControl+RxTests.swift */; };
666666
C83508C81C386F6F0027C24C /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C8A56AD71AD7424700B4673B /* RxSwift.framework */; };
667-
C835092D1C38706E0027C24C /* Control+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DC1C38706D0027C24C /* Control+RxTests.swift */; };
668667
C835092E1C38706E0027C24C /* ControlEventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DD1C38706D0027C24C /* ControlEventTests.swift */; };
669668
C835092F1C38706E0027C24C /* ControlPropertyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DE1C38706D0027C24C /* ControlPropertyTests.swift */; };
670669
C83509311C38706E0027C24C /* DelegateProxyTest+UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508E01C38706D0027C24C /* DelegateProxyTest+UIKit.swift */; };
@@ -709,11 +708,8 @@
709708
C835097E1C38726E0027C24C /* RxMutableBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8093CB01B8A72BE0088E94D /* RxMutableBox.swift */; };
710709
C83509891C38740E0027C24C /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D2EA280C1BB9B5A200880ED3 /* RxSwift.framework */; };
711710
C83509991C38742C0027C24C /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C88BB8711B07E5ED0064D411 /* RxSwift.framework */; };
712-
C83509B51C3875050027C24C /* Control+RxTests+Cocoa.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DA1C38706D0027C24C /* Control+RxTests+Cocoa.swift */; };
713-
C83509B71C38750D0027C24C /* Control+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DC1C38706D0027C24C /* Control+RxTests.swift */; };
714711
C83509B81C38750D0027C24C /* ControlEventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DD1C38706D0027C24C /* ControlEventTests.swift */; };
715712
C83509B91C38750D0027C24C /* ControlPropertyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DE1C38706D0027C24C /* ControlPropertyTests.swift */; };
716-
C83509BB1C38750D0027C24C /* Control+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DC1C38706D0027C24C /* Control+RxTests.swift */; };
717713
C83509BC1C38750D0027C24C /* ControlEventTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DD1C38706D0027C24C /* ControlEventTests.swift */; };
718714
C83509BD1C38750D0027C24C /* ControlPropertyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DE1C38706D0027C24C /* ControlPropertyTests.swift */; };
719715
C83509BE1C3875100027C24C /* DelegateProxyTest+Cocoa.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DF1C38706D0027C24C /* DelegateProxyTest+Cocoa.swift */; };
@@ -928,6 +924,7 @@
928924
C86B1E221D42BF5200130546 /* SchedulerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C86B1E211D42BF5200130546 /* SchedulerTests.swift */; };
929925
C86B1E231D42BF5200130546 /* SchedulerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C86B1E211D42BF5200130546 /* SchedulerTests.swift */; };
930926
C86B1E241D42BF5200130546 /* SchedulerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C86B1E211D42BF5200130546 /* SchedulerTests.swift */; };
927+
C8802DD41F8CD47F001D677E /* UIControl+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8802DD31F8CD47F001D677E /* UIControl+RxTests.swift */; };
931928
C88254161B8A752B00B02D69 /* RxCollectionViewReactiveArrayDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88253F11B8A752B00B02D69 /* RxCollectionViewReactiveArrayDataSource.swift */; };
932929
C88254171B8A752B00B02D69 /* RxTableViewReactiveArrayDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88253F21B8A752B00B02D69 /* RxTableViewReactiveArrayDataSource.swift */; };
933930
C88254181B8A752B00B02D69 /* ItemEvents.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88253F41B8A752B00B02D69 /* ItemEvents.swift */; };
@@ -972,8 +969,6 @@
972969
C88F76831CE5341700D5A014 /* TextInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88F76801CE5341700D5A014 /* TextInput.swift */; };
973970
C88F76841CE5341700D5A014 /* TextInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = C88F76801CE5341700D5A014 /* TextInput.swift */; };
974971
C89046581DC5F6F70041C7D8 /* UISearchBar+RxTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8B2908C1C94D6C500E923D0 /* UISearchBar+RxTests.swift */; };
975-
C89046591DC5F7120041C7D8 /* Control+RxTests+UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DB1C38706D0027C24C /* Control+RxTests+UIKit.swift */; };
976-
C890465A1DC5F7130041C7D8 /* Control+RxTests+UIKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = C83508DB1C38706D0027C24C /* Control+RxTests+UIKit.swift */; };
977972
C8941BDF1BD5695C00A0E874 /* BlockingObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8941BDE1BD5695C00A0E874 /* BlockingObservable.swift */; };
978973
C8941BE01BD5695C00A0E874 /* BlockingObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8941BDE1BD5695C00A0E874 /* BlockingObservable.swift */; };
979974
C8941BE11BD5695C00A0E874 /* BlockingObservable.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8941BDE1BD5695C00A0E874 /* BlockingObservable.swift */; };
@@ -1951,9 +1946,6 @@
19511946
C834F6C11DB394E100C29244 /* Observable+BlockingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Observable+BlockingTest.swift"; sourceTree = "<group>"; };
19521947
C834F6C51DB3950600C29244 /* NSControl+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSControl+RxTests.swift"; sourceTree = "<group>"; };
19531948
C83508C31C386F6F0027C24C /* AllTests-iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "AllTests-iOS.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
1954-
C83508DA1C38706D0027C24C /* Control+RxTests+Cocoa.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Control+RxTests+Cocoa.swift"; sourceTree = "<group>"; };
1955-
C83508DB1C38706D0027C24C /* Control+RxTests+UIKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Control+RxTests+UIKit.swift"; sourceTree = "<group>"; };
1956-
C83508DC1C38706D0027C24C /* Control+RxTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Control+RxTests.swift"; sourceTree = "<group>"; };
19571949
C83508DD1C38706D0027C24C /* ControlEventTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlEventTests.swift; sourceTree = "<group>"; };
19581950
C83508DE1C38706D0027C24C /* ControlPropertyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ControlPropertyTests.swift; sourceTree = "<group>"; };
19591951
C83508DF1C38706D0027C24C /* DelegateProxyTest+Cocoa.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = "DelegateProxyTest+Cocoa.swift"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
@@ -2054,6 +2046,7 @@
20542046
C86781951DB823B500B2029A /* NSTextField+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSTextField+Rx.swift"; sourceTree = "<group>"; };
20552047
C86781961DB823B500B2029A /* NSView+Rx.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSView+Rx.swift"; sourceTree = "<group>"; };
20562048
C86B1E211D42BF5200130546 /* SchedulerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SchedulerTests.swift; sourceTree = "<group>"; };
2049+
C8802DD31F8CD47F001D677E /* UIControl+RxTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIControl+RxTests.swift"; sourceTree = "<group>"; };
20572050
C88253F11B8A752B00B02D69 /* RxCollectionViewReactiveArrayDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxCollectionViewReactiveArrayDataSource.swift; sourceTree = "<group>"; };
20582051
C88253F21B8A752B00B02D69 /* RxTableViewReactiveArrayDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RxTableViewReactiveArrayDataSource.swift; sourceTree = "<group>"; };
20592052
C88253F41B8A752B00B02D69 /* ItemEvents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ItemEvents.swift; sourceTree = "<group>"; };
@@ -2693,9 +2686,6 @@
26932686
C8D970E11F532FD20058F2FE /* SharedSequence+Extensions.swift */,
26942687
C8D970DE1F532FD20058F2FE /* Driver+Test.swift */,
26952688
C8D970E21F532FD30058F2FE /* SharedSequence+OperatorTest.swift */,
2696-
C83508DC1C38706D0027C24C /* Control+RxTests.swift */,
2697-
C83508DA1C38706D0027C24C /* Control+RxTests+Cocoa.swift */,
2698-
C83508DB1C38706D0027C24C /* Control+RxTests+UIKit.swift */,
26992689
C83508DD1C38706D0027C24C /* ControlEventTests.swift */,
27002690
C83508DE1C38706D0027C24C /* ControlPropertyTests.swift */,
27012691
C83508E11C38706D0027C24C /* DelegateProxyTest.swift */,
@@ -2724,6 +2714,7 @@
27242714
C8C4F16A1DE9D4C100003FA7 /* UIAlertAction+RxTests.swift */,
27252715
C8C4F15C1DE9CAEE00003FA7 /* UIBarButtonItem+RxTests.swift */,
27262716
C8379EF31D1DD326003EF8FC /* UIButton+RxTests.swift */,
2717+
C8802DD31F8CD47F001D677E /* UIControl+RxTests.swift */,
27272718
C8C217D61CB710200038A2E6 /* UICollectionView+RxTests.swift */,
27282719
C8C4F16C1DE9D4F400003FA7 /* UIDatePicker+RxTests.swift */,
27292720
C8C4F1641DE9D3FB00003FA7 /* UIGestureRecognizer+RxTests.swift */,
@@ -4291,6 +4282,7 @@
42914282
C8F03F4F1DBBAE9400AECC4C /* DispatchQueue+Extensions.swift in Sources */,
42924283
C835094B1C38706E0027C24C /* Observable+Tests.swift in Sources */,
42934284
C8C217D51CB7100E0038A2E6 /* UITableView+RxTests.swift in Sources */,
4285+
C8802DD41F8CD47F001D677E /* UIControl+RxTests.swift in Sources */,
42944286
C835092E1C38706E0027C24C /* ControlEventTests.swift in Sources */,
42954287
844BC8BB1CE5024500F5C7CB /* UIPickerView+RxTests.swift in Sources */,
42964288
C801DE361F6EAD3C008DB060 /* SingleTest.swift in Sources */,
@@ -4381,7 +4373,6 @@
43814373
4613456F1D9A4467001ABAF2 /* UIWebView+RxTests.swift in Sources */,
43824374
C820A9BA1EB5097700D431BC /* Observable+TakeTests.swift in Sources */,
43834375
C835094C1C38706E0027C24C /* AssumptionsTest.swift in Sources */,
4384-
C835092D1C38706E0027C24C /* Control+RxTests.swift in Sources */,
43854376
C8D970F21F532FD30058F2FE /* SharedSequence+OperatorTest.swift in Sources */,
43864377
C834F6C21DB394E100C29244 /* Observable+BlockingTest.swift in Sources */,
43874378
C8BAA78D1E34F8D400EEC727 /* RecursiveLockTest.swift in Sources */,
@@ -4399,7 +4390,6 @@
43994390
C8C4F15F1DE9CC5B00003FA7 /* UISwitch+RxTests.swift in Sources */,
44004391
ECBBA5A11DF8C0FF00DDDC2E /* UITabBarController+RxTests.swift in Sources */,
44014392
C820A9A61EB5056C00D431BC /* Observable+SkipUntilTests.swift in Sources */,
4402-
C890465A1DC5F7130041C7D8 /* Control+RxTests+UIKit.swift in Sources */,
44034393
88718D011CE5DE2600D88D60 /* UITabBar+RxTests.swift in Sources */,
44044394
C8D970EC1F532FD30058F2FE /* SectionedViewDataSourceMock.swift in Sources */,
44054395
C822BACE1DB424EC00F98810 /* Reactive+Tests.swift in Sources */,
@@ -4451,11 +4441,9 @@
44514441
C896A68C1E6B7DC60073A3A8 /* Observable+CombineLatestTests.swift in Sources */,
44524442
C83509F31C38755D0027C24C /* AssumptionsTest.swift in Sources */,
44534443
C83509ED1C3875580027C24C /* MySubject.swift in Sources */,
4454-
C89046591DC5F7120041C7D8 /* Control+RxTests+UIKit.swift in Sources */,
44554444
C83509C61C3875220027C24C /* NSObject+RxTests.swift in Sources */,
44564445
C820A9871EB4FB5B00D431BC /* Observable+DebugTests.swift in Sources */,
44574446
C8C4F1881DE9DF0200003FA7 /* UITableView+RxTests.swift in Sources */,
4458-
C83509BB1C38750D0027C24C /* Control+RxTests.swift in Sources */,
44594447
C820A9FF1EB5110E00D431BC /* Observable+DematerializeTests.swift in Sources */,
44604448
C83509EE1C3875580027C24C /* Observable.Extensions.swift in Sources */,
44614449
C83509BD1C38750D0027C24C /* ControlPropertyTests.swift in Sources */,
@@ -4627,7 +4615,6 @@
46274615
C820AA101EB5140100D431BC /* Observable+TimeoutTests.swift in Sources */,
46284616
C81B6AAC1DB2C15C0047CF86 /* Platform.Darwin.swift in Sources */,
46294617
C8350A2B1C3875B60027C24C /* RxMutableBox.swift in Sources */,
4630-
C83509B71C38750D0027C24C /* Control+RxTests.swift in Sources */,
46314618
C8350A071C38755E0027C24C /* MainSchedulerTests.swift in Sources */,
46324619
C8D970F41F532FD30058F2FE /* SharedSequence+OperatorTest.swift in Sources */,
46334620
C820A9F01EB50EA100D431BC /* Observable+ScanTests.swift in Sources */,
@@ -4737,7 +4724,6 @@
47374724
C8D970E51F532FD30058F2FE /* Signal+Test.swift in Sources */,
47384725
C801DE381F6EAD3C008DB060 /* SingleTest.swift in Sources */,
47394726
C81B6AAF1DB2C15C0047CF86 /* Platform.Linux.swift in Sources */,
4740-
C83509B51C3875050027C24C /* Control+RxTests+Cocoa.swift in Sources */,
47414727
C801DE3C1F6EAD48008DB060 /* MaybeTest.swift in Sources */,
47424728
C8C4F1771DE9D84900003FA7 /* NSButton+RxTests.swift in Sources */,
47434729
C820A9A81EB5056C00D431BC /* Observable+SkipUntilTests.swift in Sources */,

RxCocoa/iOS/UIBarButtonItem+Rx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extension Reactive where Base: UIBarButtonItem {
3333

3434
/// Reactive wrapper for target action pattern on `self`.
3535
public var tap: ControlEvent<()> {
36-
let source = lazyInstanceObservable(&rx_tap_key) { () -> Observable<Void> in
36+
let source = lazyInstanceObservable(&rx_tap_key) { () -> Observable<()> in
3737
Observable.create { [weak control = self.base] observer in
3838
guard let control = control else {
3939
observer.on(.completed)

RxCocoa/iOS/UIControl+Rx.swift

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,74 +32,73 @@ extension Reactive where Base: UIControl {
3232
/// Reactive wrapper for target action pattern.
3333
///
3434
/// - parameter controlEvents: Filter for observed event types.
35-
public func controlEvent(_ controlEvents: UIControlEvents) -> ControlEvent<Void> {
35+
public func controlEvent(_ controlEvents: UIControlEvents) -> ControlEvent<()> {
3636
let source: Observable<Void> = Observable.create { [weak control = self.base] observer in
37-
MainScheduler.ensureExecutingOnScheduler()
37+
MainScheduler.ensureExecutingOnScheduler()
3838

39-
guard let control = control else {
40-
observer.on(.completed)
41-
return Disposables.create()
42-
}
39+
guard let control = control else {
40+
observer.on(.completed)
41+
return Disposables.create()
42+
}
4343

44-
let controlTarget = ControlTarget(control: control, controlEvents: controlEvents) {
45-
control in
46-
observer.on(.next(()))
44+
let controlTarget = ControlTarget(control: control, controlEvents: controlEvents) {
45+
control in
46+
observer.on(.next(()))
47+
}
48+
49+
return Disposables.create(with: controlTarget.dispose)
4750
}
48-
49-
return Disposables.create(with: controlTarget.dispose)
50-
}.takeUntil(deallocated)
51+
.takeUntil(deallocated)
5152

5253
return ControlEvent(events: source)
5354
}
5455

55-
/// This is internal convenience method
56-
/// https://github.com/ReactiveX/RxSwift/issues/681
57-
/// In case similar behavior is externally needed, one can use the following snippet
56+
/// Creates a `ControlProperty` that is triggered by target/action pattern value updates.
5857
///
59-
/// ```swift
60-
/// extension UIControl {
61-
/// static func valuePublic<T, ControlType: UIControl>(_ control: ControlType, getter: @escaping (ControlType) -> T, setter: @escaping (ControlType, T) -> ()) -> ControlProperty<T> {
62-
/// let values: Observable<T> = Observable.deferred { [weak control] in
63-
/// guard let existingSelf = control else {
64-
/// return Observable.empty()
65-
/// }
66-
///
67-
/// return (existingSelf as UIControl).rx.controlEvent([.allEditingEvents, .valueChanged])
68-
/// .flatMap { _ in
69-
/// return control.map { Observable.just(getter($0)) } ?? Observable.empty()
70-
/// }
71-
/// .startWith(getter(existingSelf))
72-
/// }
73-
/// return ControlProperty(values: values, valueSink: UIBindingObserver(UIElement: control) { control, value in
74-
/// setter(control, value)
75-
/// })
76-
/// }
77-
///}
78-
///```
79-
static func value<C: UIControl, T>(_ control: C, getter: @escaping (C) -> T, setter: @escaping (C, T) -> Void) -> ControlProperty<T> {
80-
let source: Observable<T> = Observable.create { [weak weakControl = control] observer in
58+
/// - parameter controlEvents: Events that trigger value update sequence elements.
59+
/// - parameter getter: Property value getter.
60+
/// - parameter setter: Property value setter.
61+
public func controlProperty<T>(
62+
editingEvents: UIControlEvents,
63+
getter: @escaping (Base) -> T,
64+
setter: @escaping (Base, T) -> ()
65+
) -> ControlProperty<T> {
66+
let source: Observable<T> = Observable.create { [weak weakControl = base] observer in
8167
guard let control = weakControl else {
8268
observer.on(.completed)
8369
return Disposables.create()
8470
}
8571

8672
observer.on(.next(getter(control)))
8773

88-
let controlTarget = ControlTarget(control: control, controlEvents: [.allEditingEvents, .valueChanged]) { _ in
74+
let controlTarget = ControlTarget(control: control, controlEvents: editingEvents) { _ in
8975
if let control = weakControl {
9076
observer.on(.next(getter(control)))
9177
}
9278
}
9379

9480
return Disposables.create(with: controlTarget.dispose)
9581
}
96-
.takeUntil((control as NSObject).rx.deallocated)
82+
.takeUntil(deallocated)
9783

98-
let bindingObserver = Binder(control, binding: setter)
84+
let bindingObserver = Binder(base, binding: setter)
9985

10086
return ControlProperty<T>(values: source, valueSink: bindingObserver)
10187
}
10288

89+
/// This is a separate method is to better communicate to public consumers that
90+
/// an `editingEvent` needs to fire for control property to be updated.
91+
internal func controlPropertyWithDefaultEvents<T>(
92+
editingEvents: UIControlEvents = [.allEditingEvents, .valueChanged],
93+
getter: @escaping (Base) -> T,
94+
setter: @escaping (Base, T) -> ()
95+
) -> ControlProperty<T> {
96+
return controlProperty(
97+
editingEvents: [.allEditingEvents, .valueChanged],
98+
getter: getter,
99+
setter: setter
100+
)
101+
}
103102
}
104103

105104
#endif

RxCocoa/iOS/UIDatePicker+Rx.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ extension Reactive where Base: UIDatePicker {
2121

2222
/// Reactive wrapper for `date` property.
2323
public var value: ControlProperty<Date> {
24-
return UIControl.rx.value(
25-
self.base,
24+
return base.rx.controlPropertyWithDefaultEvents(
2625
getter: { datePicker in
2726
datePicker.date
2827
}, setter: { datePicker, value in
@@ -33,8 +32,7 @@ extension Reactive where Base: UIDatePicker {
3332

3433
/// Reactive wrapper for `countDownDuration` property.
3534
public var countDownDuration: ControlProperty<TimeInterval> {
36-
return UIControl.rx.value(
37-
self.base,
35+
return base.rx.controlPropertyWithDefaultEvents(
3836
getter: { datePicker in
3937
datePicker.countDownDuration
4038
}, setter: { datePicker, value in

RxCocoa/iOS/UISegmentedControl+Rx.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ extension Reactive where Base: UISegmentedControl {
2222

2323
/// Reactive wrapper for `selectedSegmentIndex` property.
2424
public var value: ControlProperty<Int> {
25-
return UIControl.rx.value(
26-
self.base,
25+
return base.rx.controlPropertyWithDefaultEvents(
2726
getter: { segmentedControl in
2827
segmentedControl.selectedSegmentIndex
2928
}, setter: { segmentedControl, value in

0 commit comments

Comments
 (0)