antoninbiret / RxEureka

This library is a small RxSwift wrapper around Eureka
MIT License
37 stars 9 forks source link

Changes updated but not displayed #20

Open deceroainfinito opened 6 years ago

deceroainfinito commented 6 years ago

When I press a ButtonRow I change the value of my binded viewmodel-form tuple. Although the updated is made, I can see the change through the form.values() method, the row is not automatically "re-displayed". I have to force it wether with row.reload() or selecting the row. Is this behaviour ok?

antoninbiret commented 6 years ago

Hi @deceroainfinito. Could you provide a sample code/project describing what your trying to do ? Thanks

sedwo commented 6 years ago

@antoninbiret I can confirm fields not being updated automatically by RxEureka as well; forcing me to add .onChange { row in row.updateCell() } for each row. HD video attached to better see the code.

ezgif com-video-to-gif 1 RxEureka.mp4.zip

antoninbiret commented 6 years ago

Hi @sedwo. Hard to say what the problem is with just a video. I think the binding from the viewModel to the row is not properly set. I could tell you more with a sample code I can play with.

sedwo commented 6 years ago

[SOLVED] @antoninbiret You are correct. the binding from the viewModel to the row is not properly set I looked at your example again and you bind the actual _textRow: TextRow property. Where as I was wrapping mine, for example:

var serverURLrow: TextFloatLabelRow? {
        return self.form.rowBy(tag: RowTags.customURL.rawValue) as? TextFloatLabelRow
    }

        // Bind viewModel Variable to --> row UI
        self.viewModel.serverURLRxString
            .asObservable()
            .bind(to: self.serverURLrow!.rx.value)
            .disposed(by: self.disposeBag)

This failed to correctly bind to the actual property for adequate refresh of the UI.

Curiously, why in your example do you set up the form within the viewModel and not the VC? Is it more correct MVVM?

antoninbiret commented 6 years ago

@sedwo I could have set up the row in the view controller, you're right to point this out. It actually could make more sense to put all this setup in the View part instead of the ViewModel as it describes how the view should be created. It's totally up to you 👍