added back subject into the flow
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
270bf89b9f
commit
1934da2543
@ -16,6 +16,7 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Combine Properties
|
// MARK: - Combine Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var subject = PassthroughSubject<Void, Never>()
|
||||||
|
|
||||||
/// Set of Subscribers for any Publishers for this Control
|
/// Set of Subscribers for any Publishers for this Control
|
||||||
public var subscribers = Set<AnyCancellable>()
|
public var subscribers = Set<AnyCancellable>()
|
||||||
@ -84,18 +85,18 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// Override to deal with setNeedsUpdate()
|
/// Override to deal with setNeedsUpdate()
|
||||||
// open override var isEnabled: Bool {
|
open override var isEnabled: Bool {
|
||||||
// get { !disabled }
|
get { !disabled }
|
||||||
// set {
|
set {
|
||||||
// if disabled != !newValue {
|
if disabled != !newValue {
|
||||||
// disabled = !newValue
|
disabled = !newValue
|
||||||
// }
|
}
|
||||||
// isUserInteractionEnabled = isEnabled
|
isUserInteractionEnabled = isEnabled
|
||||||
// setNeedsUpdate()
|
setNeedsUpdate()
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -123,7 +124,8 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab
|
|||||||
if !initialSetupPerformed {
|
if !initialSetupPerformed {
|
||||||
initialSetupPerformed = true
|
initialSetupPerformed = true
|
||||||
setup()
|
setup()
|
||||||
setNeedsUpdate()
|
setupNeedsUpdateEvent()
|
||||||
|
updateView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Combine Properties
|
// MARK: - Combine Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var subject = PassthroughSubject<Void, Never>()
|
||||||
public var subscribers = Set<AnyCancellable>()
|
public var subscribers = Set<AnyCancellable>()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -63,7 +64,8 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
if !initialSetupPerformed {
|
if !initialSetupPerformed {
|
||||||
initialSetupPerformed = true
|
initialSetupPerformed = true
|
||||||
setup()
|
setup()
|
||||||
setNeedsUpdate()
|
setupNeedsUpdateEvent()
|
||||||
|
updateView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Combine Properties
|
// MARK: - Combine Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var subject = PassthroughSubject<Void, Never>()
|
||||||
public var subscribers = Set<AnyCancellable>()
|
public var subscribers = Set<AnyCancellable>()
|
||||||
public var onClickSubscriber: AnyCancellable? {
|
public var onClickSubscriber: AnyCancellable? {
|
||||||
willSet {
|
willSet {
|
||||||
@ -123,7 +124,8 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
|||||||
translatesAutoresizingMaskIntoConstraints = false
|
translatesAutoresizingMaskIntoConstraints = false
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
setup()
|
setup()
|
||||||
setNeedsUpdate()
|
setupNeedsUpdateEvent()
|
||||||
|
updateView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,6 +16,7 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Combine Properties
|
// MARK: - Combine Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
public var subject = PassthroughSubject<Void, Never>()
|
||||||
public var subscribers = Set<AnyCancellable>()
|
public var subscribers = Set<AnyCancellable>()
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -84,7 +85,8 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
|||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
accessibilityTraits = .staticText
|
accessibilityTraits = .staticText
|
||||||
setup()
|
setup()
|
||||||
setNeedsUpdate()
|
setupNeedsUpdateEvent()
|
||||||
|
updateView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,12 +10,26 @@ import Combine
|
|||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
public protocol Handlerable: AnyObject, Initable, Disabling, Surfaceable {
|
public protocol Handlerable: AnyObject, Initable, Disabling, Surfaceable {
|
||||||
|
var subject: PassthroughSubject<Void, Never> { get set }
|
||||||
var subscribers: Set<AnyCancellable> { get set }
|
var subscribers: Set<AnyCancellable> { get set }
|
||||||
var shouldUpdateView: Bool { get set }
|
var shouldUpdateView: Bool { get set }
|
||||||
func updateView()
|
func updateView()
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Handlerable {
|
extension Handlerable {
|
||||||
|
public func setupNeedsUpdateEvent() {
|
||||||
|
handlerPublisher().sink { [weak self] _ in
|
||||||
|
self?.updateView()
|
||||||
|
}.store(in: &subscribers)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func handlerPublisher() -> AnyPublisher<Void, Never> {
|
||||||
|
subject
|
||||||
|
.eraseToAnyPublisher()
|
||||||
|
.debounce(for: .milliseconds(50), scheduler: RunLoop.main)
|
||||||
|
.eraseToAnyPublisher()
|
||||||
|
}
|
||||||
|
|
||||||
public func setNeedsUpdate() {
|
public func setNeedsUpdate() {
|
||||||
if shouldUpdateView {
|
if shouldUpdateView {
|
||||||
shouldUpdateView = false
|
shouldUpdateView = false
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user