CocoaAction

public final class CocoaAction<Sender>: NSObject

CocoaAction wraps an Action for use by a GUI control (such as NSControl or UIControl), with KVO, or with Cocoa Bindings.

  • The selector for message senders.

    Declaration

    Swift

    public static var selector: Selector
  • Whether the action is enabled.

    This property will only change on the main thread, and will generate a KVO notification for every change.

    Declaration

    Swift

    public let isEnabled: Property<Bool>
  • Whether the action is executing.

    This property will only change on the main thread, and will generate a KVO notification for every change.

    Declaration

    Swift

    public let isExecuting: Property<Bool>
  • Initialize a CocoaAction that invokes the given Action by mapping the sender to the input type of the Action.

    • parameters:
      • action: The Action.
      • inputTransform: A closure that maps Sender to the input type of the Action.

    Declaration

    Swift

    public init<Input, Output, Error>(_ action: Action<Input, Output, Error>, _ inputTransform: @escaping (Sender) -> Input)

    Parameters

    action

    The Action.

    inputTransform

    A closure that maps Sender to the input type of the Action.

  • Initialize a CocoaAction that invokes the given Action.

    • parameters:
      • action: The Action.

    Declaration

    Swift

    public convenience init<Output, Error>(_ action: Action<(), Output, Error>)

    Parameters

    action

    The Action.

  • Initialize a CocoaAction that invokes the given Action with the given constant.

    • parameters:
      • action: The Action.
      • input: The constant value as the input to the action.

    Declaration

    Swift

    public convenience init<Input, Output, Error>(_ action: Action<Input, Output, Error>, input: Input)

    Parameters

    action

    The Action.

    input

    The constant value as the input to the action.

  • Attempt to execute the underlying action with the given input, subject to the behavior described by the initializer that was used.

    • parameters:
      • sender: The sender which initiates the attempt.

    Declaration

    Swift

    @IBAction public func execute(_ sender: Any?)

    Parameters

    sender

    The sender which initiates the attempt.