Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
zmian committed Feb 12, 2024
1 parent d3b5e02 commit 3001294
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Sources/Xcore/Cocoa/Blocks/UIControl+Blocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public protocol ControlTargetActionBlockRepresentable: AnyObject {
///
/// - Parameters:
/// - event: An event to add to `self`.
/// - handler: The block invoked whenever given event is triggered.
func addAction(_ event: UIControl.Event, _ handler: @escaping (_ sender: Sender) -> Void)
/// - action: The block invoked whenever given event is triggered.
func addAction(_ event: UIControl.Event, _ action: @escaping (_ sender: Sender) -> Void)

/// Stops the delivery of the given event from `self`.
///
Expand All @@ -31,12 +31,12 @@ extension UIControl: ControlTargetActionBlockRepresentable {
}

extension ControlTargetActionBlockRepresentable where Self: UIControl {
public func addAction(_ event: UIControl.Event, _ handler: @escaping (_ sender: Self) -> Void) {
public func addAction(_ event: UIControl.Event, _ action: @escaping (_ sender: Self) -> Void) {
let uniqueId = UIAction.Identifier("\(event.rawValue)")

let action = UIAction(identifier: uniqueId) {
guard let sender = $0.sender as? Self else { return }
handler(sender)
action(sender)
}

addAction(action, for: event)
Expand All @@ -51,14 +51,14 @@ extension ControlTargetActionBlockRepresentable where Self: UIControl {
extension ControlTargetActionBlockRepresentable where Self: UIButton {
/// Associates `.primaryActionTriggered` action method with the control.
///
/// - Parameter handler: The block invoked whenever `.primaryActionTriggered`
/// - Parameter action: The block invoked whenever `.primaryActionTriggered`
/// event is triggered.
public func action(_ handler: ((_ sender: Self) -> Void)?) {
guard let handler else {
public func action(_ action: ((_ sender: Self) -> Void)?) {
guard let action else {
removeAction(.primaryActionTriggered)
return
}

addAction(.primaryActionTriggered, handler)
addAction(.primaryActionTriggered, action)
}
}

0 comments on commit 3001294

Please sign in to comment.