From 552e0416d3e687e8d3cfb924d35f684bd180822e Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 12 Aug 2022 15:27:50 -0500 Subject: [PATCH] refactored out ModelHandlerPublishable and moved into the handler Signed-off-by: Matt Bruce --- VDS.xcodeproj/project.pbxproj | 2 +- VDS/Classes/Control.swift | 2 +- VDS/Classes/ModelHandlerPublisher.swift | 6 +++--- VDS/Classes/View.swift | 2 +- VDS/Components/Label/Label.swift | 2 +- VDS/Protocols/ModelHandlerable.swift | 9 +++------ 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/VDS.xcodeproj/project.pbxproj b/VDS.xcodeproj/project.pbxproj index 5ae7d63b..2858e5f0 100644 --- a/VDS.xcodeproj/project.pbxproj +++ b/VDS.xcodeproj/project.pbxproj @@ -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 = ""; diff --git a/VDS/Classes/Control.swift b/VDS/Classes/Control.swift index 39682be0..6e871f4f 100644 --- a/VDS/Classes/Control.swift +++ b/VDS/Classes/Control.swift @@ -10,7 +10,7 @@ import UIKit import Combine -open class Control: UIControl, ModelHandlerPublishable, ViewProtocol, Resettable { +open class Control: UIControl, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties diff --git a/VDS/Classes/ModelHandlerPublisher.swift b/VDS/Classes/ModelHandlerPublisher.swift index 07077184..07778df7 100644 --- a/VDS/Classes/ModelHandlerPublisher.swift +++ b/VDS/Classes/ModelHandlerPublisher.swift @@ -9,7 +9,7 @@ import Foundation import Combine extension Publishers { - public struct ModelHandlerPublisher: Publisher { + public struct ModelHandlerPublisher: Publisher { public typealias Output = ModelHandlerType.ModelType public typealias Failure = Never @@ -24,7 +24,7 @@ extension Publishers { } } - public class ModelHandlerSubscription: Subscription where S.Input == ModelHandlerType.ModelType, S.Failure == Never { + public class ModelHandlerSubscription: 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 { return Publishers.ModelHandlerPublisher(modelHandler: self) } diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index d80935d5..06c8cec8 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -10,7 +10,7 @@ import UIKit import Combine -open class View: UIView, ModelHandlerPublishable, ViewProtocol, Resettable { +open class View: UIView, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index fb29a2b8..347a94ee 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -12,7 +12,7 @@ import Combine public class Label:LabelBase{} -open class LabelBase: UILabel, ModelHandlerPublishable, ViewProtocol, Resettable { +open class LabelBase: UILabel, ModelHandlerable, ViewProtocol, Resettable { //-------------------------------------------------- // MARK: - Combine Properties diff --git a/VDS/Protocols/ModelHandlerable.swift b/VDS/Protocols/ModelHandlerable.swift index 215f2454..9202e7f3 100644 --- a/VDS/Protocols/ModelHandlerable.swift +++ b/VDS/Protocols/ModelHandlerable.swift @@ -11,6 +11,9 @@ import Combine public protocol ModelHandlerable: AnyObject { associatedtype ModelType: Modelable var model: ModelType { get set } + var modelPublished: Published { get } + var modelPublisher: Published.Publisher { get } + var subscribers: Set { get set } init(with model: ModelType) func set(with model: ModelType) @@ -27,9 +30,3 @@ extension ModelHandlerable { } } } - -public protocol ModelHandlerPublishable: ModelHandlerable { - var modelPublished: Published { get } - var modelPublisher: Published.Publisher { get } - var subscribers: Set { get set } -}