Skip to content

Commit c62ca31

Browse files
committed
Idiomatification of Swift syntax.
1 parent 4ee527f commit c62ca31

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

Demo/ViewController.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ class ViewController: UIViewController {
8383
})
8484
.addDisposableTo(self.disposableBag)
8585

86-
button1.rx.bindToAction(sharedAction, input: .button("Button 1"))
86+
button1.rx.bindTo(action: sharedAction, input: .button("Button 1"))
8787

88-
button2.rx.bindToAction(sharedAction) { _ in
88+
button2.rx.bindTo(action: sharedAction) { _ in
8989
return .button("Button 2")
9090
}
91-
self.navigationItem.leftBarButtonItem?.rx.bindToAction(sharedAction, input: .barButton)
91+
self.navigationItem.leftBarButtonItem?.rx.bindTo(action: sharedAction, input: .barButton)
9292

9393
sharedAction.executing.debounce(0, scheduler: MainScheduler.instance).subscribe(onNext: { [weak self] executing in
9494
if (executing) {

Sources/Action/UIKitExtensions/UIBarButtonItem+Action.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public extension Reactive where Base: UIBarButtonItem {
3838
}
3939
}
4040

41-
public func bindToAction<Input, Output>(_ action: Action<Input, Output>?, _ inputTransform: @escaping (Base) -> (Input)) {
41+
public func bindTo<Input, Output>(action: Action<Input, Output>?, inputTransform: @escaping (Base) -> (Input)) {
4242
self.base.resetActionDisposeBag()
4343

4444
guard let action = action else {
@@ -56,8 +56,8 @@ public extension Reactive where Base: UIBarButtonItem {
5656
.addDisposableTo(self.base.actionDisposeBag)
5757
}
5858

59-
public func bindToAction<Input, Output>(_ action: Action<Input,Output>?, input: Input) {
60-
self.bindToAction(action) { _ in input}
59+
public func bindTo<Input, Output>(action: Action<Input,Output>?, input: Input) {
60+
self.bindTo(action: action) { _ in input}
6161
}
6262

6363
}

Sources/Action/UIKitExtensions/UIButton+Rx.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public extension Reactive where Base: UIButton {
5555
/// Binds enabled state of action to button, and subscribes to rx_tap to execute action with given input transform.
5656
/// These subscriptions are managed in a private, inaccessible dispose bag. To cancel
5757
/// them, call bindToAction with another action or nil.
58-
public func bindToAction<Input, Output>(_ action:Action<Input,Output>?, _ inputTransform: @escaping (Base) -> (Input)) {
58+
public func bindTo<Input, Output>(action:Action<Input,Output>?, inputTransform: @escaping (Base) -> (Input)) {
5959
// This effectively disposes of any existing subscriptions.
6060

6161
// Technically, this file is only included on tv/iOS platforms,
@@ -71,14 +71,14 @@ public extension Reactive where Base: UIButton {
7171
guard let controlEvent = lookupControlEvent else {
7272
return
7373
}
74-
self.bindToAction(action, controlEvent: controlEvent, inputTransform)
74+
self.bindTo(action: action, controlEvent: controlEvent, inputTransform: inputTransform)
7575
}
7676

7777
/// Binds enabled state of action to button, and subscribes to rx_tap to execute action with given input value.
7878
/// These subscriptions are managed in a private, inaccessible dispose bag. To cancel
7979
/// them, call bindToAction with another action or nil.
80-
public func bindToAction<Input, Output>(_ action:Action<Input,Output>?, input:Input) {
81-
self.bindToAction(action) { _ in return input }
80+
public func bindTo<Input, Output>(action: Action<Input,Output>?, input: Input) {
81+
self.bindTo(action: action) { _ in input }
8282
}
8383
}
8484
#endif

Sources/Action/UIKitExtensions/UIControl+Rx.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public extension Reactive where Base: UIControl {
77
/// Binds enabled state of action to control, and subscribes action's execution to provided controlEvents.
88
/// These subscriptions are managed in a private, inaccessible dispose bag. To cancel
99
/// them, set the rx.action to nil or another action.
10-
public func bindToAction <Input,Output>(_ action: Action<Input,Output>?, controlEvent: ControlEvent<Void>, _ inputTransform: @escaping (Base) -> (Input)) {
10+
public func bindTo<Input,Output>(action: Action<Input,Output>?, controlEvent: ControlEvent<Void>, inputTransform: @escaping (Base) -> (Input)) {
1111
// This effectively disposes of any existing subscriptions.
1212
self.base.resetActionDisposeBag()
1313

Tests/ActionTests/BindToTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class BindToTests: QuickSpec {
2626
called = true
2727
return .empty()
2828
})
29-
button.rx.bindToAction(action, input: "Hi there!")
29+
button.rx.bindTo(action: action, input: "Hi there!")
3030
// Setting the action has an asynchronous effect of adding a target.
3131
expect(button.allTargets).toEventuallyNot( beEmpty() )
3232

@@ -42,7 +42,7 @@ class BindToTests: QuickSpec {
4242
called = true
4343
return .empty()
4444
})
45-
button.rx.bindToAction(action, controlEvent: button.rx.tap, { input in "\(input)" })
45+
button.rx.bindTo(action: action, controlEvent: button.rx.tap, inputTransform: { input in "\(input)" })
4646
// Setting the action has an asynchronous effect of adding a target.
4747
expect(button.allTargets).toEventuallyNot( beEmpty() )
4848

@@ -58,7 +58,7 @@ class BindToTests: QuickSpec {
5858
called = true
5959
return .empty()
6060
})
61-
item.rx.bindToAction(action, input: "Hi there!")
61+
item.rx.bindTo(action: action, input: "Hi there!")
6262

6363
_ = item.target!.perform(item.action!, with: item)
6464

0 commit comments

Comments
 (0)