added handler publisher
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
b9dda3ba1c
commit
0e4bec4327
@ -79,23 +79,18 @@ class RadioButtonViewController: UIViewController, StoryboardInitable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func setupBinding() {
|
func setupBinding() {
|
||||||
//create the subject
|
|
||||||
let modelSubject = CurrentValueSubject<DefaultRadioButtonGroupModel, Never>(model)
|
|
||||||
|
|
||||||
//bind
|
|
||||||
radioButtonGroup.createBinding(with: modelSubject, storeIn: &subscribers)
|
|
||||||
|
|
||||||
//update the model
|
//update the model
|
||||||
//print out on subject changes
|
//print out on subject changes
|
||||||
modelSubject
|
radioButtonGroup.handlerPublisher()
|
||||||
.debounce(for: .seconds(Constants.ModelStateDebounce), scheduler: RunLoop.main)
|
|
||||||
.sink { [weak self] updatedModel in
|
.sink { [weak self] updatedModel in
|
||||||
|
print("before RadioButtonViewController local selectedModel Id: \(self?.model.selectedModel?.id)")
|
||||||
self?.model = updatedModel
|
self?.model = updatedModel
|
||||||
self?.showErrorSwitch.isOn = updatedModel.hasError
|
self?.showErrorSwitch.isOn = updatedModel.hasError
|
||||||
print("RadioButtonViewController hasError: \(updatedModel.hasError)")
|
print("RadioButtonViewController hasError: \(updatedModel.hasError)")
|
||||||
|
|
||||||
if let selectedModel = updatedModel.selectedModel {
|
if let selectedModel = updatedModel.selectedModel {
|
||||||
print("RadioButtonViewController selectedModel Id: \(selectedModel.id)")
|
print("RadioButtonViewController selectedModel Id: \(selectedModel.id)")
|
||||||
|
print("after RadioButtonViewController local selectedModel Id: \(self?.model.selectedModel?.id)")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &subscribers)
|
.store(in: &subscribers)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user