updated code

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-09-08 15:07:56 -05:00
parent f68a815680
commit 2e0d044c15
2 changed files with 11 additions and 2 deletions

View File

@ -124,7 +124,8 @@ public class RadioBoxGroup: Control<DefaultRadioBoxGroupModel>, SelectorGroupSel
}
open override func shouldUpdateView(viewModel: ModelType) -> Bool {
let update = viewModel.selectors.count != model.selectors.count
let update = viewModel.selectedModel?.inputId != model.selectedModel?.inputId
|| viewModel.selectors.count != model.selectors.count
|| viewModel.hasError != model.hasError
|| viewModel.surface != model.surface
|| viewModel.disabled != model.disabled

View File

@ -89,6 +89,15 @@ extension SelectorGroupSelectedModelHandlerable {
//create view
let newSelectorView = ModelHandlerType(with: selector)
//add model update to the subscribers
newSelectorView.handlerPublisher()
.sink { [weak self] model in
if let cached = self?.getCachedSelector(viewModel: model), newSelectorView.shouldUpdateView(viewModel: cached) {
self?.replace(viewModel: model)
}
}
.store(in: &subscribers)
//add the selectedPublisher for the change
newSelectorView
.publisher(for: .touchUpInside)
@ -96,7 +105,6 @@ extension SelectorGroupSelectedModelHandlerable {
self?.didSelect(control)
}
.store(in: &subscribers)
return newSelectorView