vds_ios/VDS/Protocols/Handlerable.swift
Matt Bruce 1e046fa336 removed / replaced anything to do with model
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
2022-10-20 15:41:41 -05:00

34 lines
749 B
Swift

//
// Handlerable.swift
// VDS
//
// Created by Matt Bruce on 7/22/22.
//
import Foundation
import Combine
import UIKit
public protocol Handlerable: AnyObject, Initable, Disabling, Surfaceable {
var subject: PassthroughSubject<Void, Never> { get set }
var subscribers: Set<AnyCancellable> { get set }
func updateView()
}
extension Handlerable {
public func handlerPublisher() -> AnyPublisher<Void, Never> {
subject
.eraseToAnyPublisher()
.debounce(for: .seconds(Constants.StateDebounce), scheduler: RunLoop.main)
.eraseToAnyPublisher()
}
}
extension Handlerable where Self: UIView {
public func didChange() {
subject.send()
setNeedsLayout()
}
}