Skip to content

Commit 760639d

Browse files
committed
Code cleanup (UIBarButtonItem doesn't exist on tvOS)
1 parent f635fed commit 760639d

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

UIBarButtonItem+Action.swift

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ObjectiveC
55

66
public extension UIBarButtonItem {
77

8-
/// Binds enabled state of action to button, and subscribes to rx_tap to execute action.
8+
/// Binds enabled state of action to bar button item, and subscribes to rx_tap to execute action.
99
/// These subscriptions are managed in a private, inaccessible dispose bag. To cancel
1010
/// them, set the rx_action to nil or another action.
1111
public var rx_action: CocoaAction? {
@@ -32,22 +32,8 @@ public extension UIBarButtonItem {
3232
.bindTo(self.rx_enabled)
3333
.addDisposableTo(self.actionDisposeBag)
3434

35-
// Technically, this file is only included on tv/iOS platforms,
36-
// so this optional will never be nil. But let's be safe 😉
37-
let lookupControlEvent: ControlEvent<Void>?
38-
39-
#if os(tvOS)
40-
lookupControlEvent = self.rx_primaryAction
41-
#elseif os(iOS)
42-
lookupControlEvent = self.rx_tap
43-
#endif
44-
45-
guard let controlEvent = lookupControlEvent else {
46-
return
47-
}
48-
49-
controlEvent
50-
.subscribeNext { _ -> Void in
35+
self.rx_tap
36+
.subscribeNext {
5137
action.execute()
5238
}
5339
.addDisposableTo(self.actionDisposeBag)

0 commit comments

Comments
 (0)