kotlin-libui icon indicating copy to clipboard operation
kotlin-libui copied to clipboard

Data-binding

Open andreas-mausch opened this issue 7 years ago • 5 comments

Do you plan to support some kind of data-binding?

I think of it in a way that you pass a model object (Observable<String>?) to a TextField, and each time the string is changed, the UI is changed as well.

And, additionally, each time the user types into the TextField, the model object get's changed automatically.

andreas-mausch avatar Nov 03 '18 15:11 andreas-mausch

As general direction - yes, it should support some data-binding, but I think it should be separate library.

No concrete plans for now.

msink avatar Nov 03 '18 15:11 msink

Hello,

we (@andreas-mausch and me) would like to work on it. We already have a prototype version of this running (included in the DSL, not a separate library), but we are not sure how to test it. We found some files in the test directory, but can not make any sense of them. How can we write unit-tests for the stuff we came up with?

Our prototype is implementing the same as you can see in this vueJS example here: https://vuejs.org/v2/guide/#Handling-User-Input (app-6) -- the one with the input and the text.

mervyn-mccreight avatar Nov 04 '18 20:11 mervyn-mccreight

About tests - test directory was here from very early days of development, and still not used. Maybe it should be removed or cleaned - I still don't figure out how to test this correctly.

Anyway it too should wait for migration to 'multiplatform' plugin.

msink avatar Nov 05 '18 09:11 msink

@msink Can you take a look at the changes in this branch and tell us if you like it? https://github.com/mervyn-mccreight/kotlin-libui/tree/data-binding

Just check the new examples data-binding-1 and 2 to get an impression.

It's not complete yet, and we want to rename "ModelEntry" to "Property" to be more similar to TornadoFX. But if you in general like what we did, I would continue on implementing ObservableLists for ComboBoxes and ListViews.

andreas-mausch avatar Nov 27 '18 05:11 andreas-mausch

I'm not competent in this area, but to me it looks overcomplicated. Can it be just some data class, something like is done for tables? checkbox(Data::checkbox)

Maybe more clean way could be using coroutines.

msink avatar Nov 27 '18 07:11 msink