updated code
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
f68a815680
commit
2e0d044c15
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user