updated init

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-11 09:50:53 -05:00
parent f97b08460a
commit c00c0fb24d
3 changed files with 6 additions and 15 deletions

View File

@ -12,7 +12,7 @@ import Combine
open class Control<ModelType: Modelable>: UIControl, ModelHandlerable, ViewProtocol, Resettable {
@Published public var model: ModelType
@Published public var model: ModelType = ModelType()
public var cancellables = Set<AnyCancellable>()
open func shouldUpdateView(viewModel: ModelType) -> Bool {
@ -38,25 +38,22 @@ open class Control<ModelType: Modelable>: UIControl, ModelHandlerable, ViewProto
// MARK: - Initializers
//--------------------------------------------------
required public init() {
self.model = ModelType()
super.init(frame: .zero)
initialSetup()
}
public required init(with model: ModelType) {
self.model = model
super.init(frame: .zero)
initialSetup()
set(with: model)
}
public override init(frame: CGRect) {
self.model = ModelType()
super.init(frame: .zero)
initialSetup()
}
public required init?(coder: NSCoder) {
self.model = ModelType.init()
super.init(coder: coder)
initialSetup()
}

View File

@ -12,7 +12,7 @@ import Combine
open class View<ModelType: Modelable>: UIView, ModelHandlerable, ViewProtocol, Resettable {
@Published public var model: ModelType
@Published public var model: ModelType = ModelType()
public var cancellables = Set<AnyCancellable>()
open func shouldUpdateView(viewModel: ModelType) -> Bool {
@ -38,25 +38,22 @@ open class View<ModelType: Modelable>: UIView, ModelHandlerable, ViewProtocol, R
// MARK: - Initializers
//--------------------------------------------------
required public init() {
self.model = ModelType()
super.init(frame: .zero)
initialSetup()
}
public required init(with model: ModelType) {
self.model = model
super.init(frame: .zero)
initialSetup()
set(with: model)
}
public override init(frame: CGRect) {
self.model = ModelType()
super.init(frame: .zero)
initialSetup()
}
public required init?(coder: NSCoder) {
self.model = ModelType.init()
super.init(coder: coder)
initialSetup()
}

View File

@ -17,7 +17,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, Initable
//--------------------------------------------------
// MARK: - Combine Properties
//--------------------------------------------------
@Published public var model: ModelType
@Published public var model: ModelType = ModelType()
public var cancellables = Set<AnyCancellable>()
//--------------------------------------------------
@ -63,25 +63,22 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, Initable
// MARK: - Initializers
//--------------------------------------------------
required public init() {
self.model = ModelType()
super.init(frame: .zero)
initialSetup()
}
public required init(with model: ModelType) {
self.model = model
super.init(frame: .zero)
initialSetup()
}
public override init(frame: CGRect) {
self.model = ModelType()
super.init(frame: .zero)
initialSetup()
set(with: model)
}
public required init?(coder: NSCoder) {
self.model = ModelType.init()
super.init(coder: coder)
initialSetup()
}