edvin / tornadofx

Lightweight JavaFX Framework for Kotlin
Apache License 2.0
3.68k stars 272 forks source link

Error in Wiki #173

Closed programaths closed 8 years ago

programaths commented 8 years ago

The page wiki/ViewModel contains an error in the source code example.

The model is defined like this :

    class PersonModel(var source: Person) : ViewModel() {
        val name = bind { source.nameProperty() }
        val title = bind { source.titleProperty() }
    }

You may want to change it to:

    class PersonModel(var person: Person) : ViewModel() {
        val name = bind { person.nameProperty() }
        val title = bind { person.titleProperty() }
    }

Since it is used like this :

                // Update the person inside the view model on selection change
                model.rebindOnChange(this) { selectedPerson ->
                    person = selectedPerson ?: Person()
                }
edvin commented 8 years ago

Thanks for pointing that out. It seems I've used person/source inconsistently. I'll sort it out :)

edvin commented 8 years ago

There, fixed :) I was also missing var in a couple of places. I'll make sure these changes goes into the upcoming guide as well. Thanks again!

edvin commented 8 years ago

The guide has also been updated :)

https://edvin.gitbooks.io/tornadofx-guide/content/11.%20ViewModel%20and%20Validation.html