refactored out ModelHandlerPublishable and moved into the handler

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-12 15:27:50 -05:00
parent 24a33a0b9e
commit 552e0416d3
6 changed files with 10 additions and 13 deletions

View File

@ -298,9 +298,9 @@
children = (
EAF7F0B8289C139800B287F5 /* ColorConfiguration.swift */,
EAF7F09D289AAEC000B287F5 /* Constants.swift */,
EAB1D2C628A6E76300DAE764 /* ModelHandlerPublisher.swift */,
EA3361B5288B2A410071C351 /* Control.swift */,
EAF7F09F289AB7EC00B287F5 /* View.swift */,
EAB1D2C628A6E76300DAE764 /* ModelHandlerPublisher.swift */,
);
path = Classes;
sourceTree = "<group>";

View File

@ -10,7 +10,7 @@ import UIKit
import Combine
open class Control<ModelType: Modelable>: UIControl, ModelHandlerPublishable, ViewProtocol, Resettable {
open class Control<ModelType: Modelable>: UIControl, ModelHandlerable, ViewProtocol, Resettable {
//--------------------------------------------------
// MARK: - Combine Properties

View File

@ -9,7 +9,7 @@ import Foundation
import Combine
extension Publishers {
public struct ModelHandlerPublisher<ModelHandlerType: ModelHandlerPublishable>: Publisher {
public struct ModelHandlerPublisher<ModelHandlerType: ModelHandlerable>: Publisher {
public typealias Output = ModelHandlerType.ModelType
public typealias Failure = Never
@ -24,7 +24,7 @@ extension Publishers {
}
}
public class ModelHandlerSubscription<S: Subscriber, ModelHandlerType: ModelHandlerPublishable>: Subscription where S.Input == ModelHandlerType.ModelType, S.Failure == Never {
public class ModelHandlerSubscription<S: Subscriber, ModelHandlerType: ModelHandlerable>: Subscription where S.Input == ModelHandlerType.ModelType, S.Failure == Never {
private var subscriber: S?
private var modelHandler: ModelHandlerType?
@ -53,7 +53,7 @@ extension Publishers {
}
}
extension ModelHandlerPublishable {
extension ModelHandlerable {
public var handlerPublisher: Publishers.ModelHandlerPublisher<Self> {
return Publishers.ModelHandlerPublisher(modelHandler: self)
}

View File

@ -10,7 +10,7 @@ import UIKit
import Combine
open class View<ModelType: Modelable>: UIView, ModelHandlerPublishable, ViewProtocol, Resettable {
open class View<ModelType: Modelable>: UIView, ModelHandlerable, ViewProtocol, Resettable {
//--------------------------------------------------
// MARK: - Combine Properties

View File

@ -12,7 +12,7 @@ import Combine
public class Label:LabelBase<DefaultLabelModel>{}
open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerPublishable, ViewProtocol, Resettable {
open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProtocol, Resettable {
//--------------------------------------------------
// MARK: - Combine Properties

View File

@ -11,6 +11,9 @@ import Combine
public protocol ModelHandlerable: AnyObject {
associatedtype ModelType: Modelable
var model: ModelType { get set }
var modelPublished: Published<ModelType> { get }
var modelPublisher: Published<ModelType>.Publisher { get }
var subscribers: Set<AnyCancellable> { get set }
init(with model: ModelType)
func set(with model: ModelType)
@ -27,9 +30,3 @@ extension ModelHandlerable {
}
}
}
public protocol ModelHandlerPublishable: ModelHandlerable {
var modelPublished: Published<ModelType> { get }
var modelPublisher: Published<ModelType>.Publisher { get }
var subscribers: Set<AnyCancellable> { get set }
}