// // Clickable.swift // VDS // // Created by Matt Bruce on 3/29/23. // import Foundation import UIKit import Combine public protocol Clickable: Handlerable where Self: UIControl { var touchUpInsideCount: Int { get set } var onClickSubscriber: AnyCancellable? { get set } } extension Clickable { public var onClick: ((Self) -> ())? { get { return nil } set { if let newValue { onClickSubscriber = publisher(for: .touchUpInside) .sink { c in newValue(c) } } else { onClickSubscriber?.cancel() onClickSubscriber = nil } } } }