BennyWang/KBinding

Binding according to the generated associated classes

ztc1997 opened this issue · 1 comments

Currently, this library is binding according to the simple name of binded member, what is a string programmer may typo. I highly recommend you refer to DBFlow's approach, generates the associated classes for each model, contains special properties for binded members, and binding according to the special properties.
E.g.
The model:

class SimpleModel : ViewModel() {
    @delegate:Property
    var name by Delegates.property<String>()
}

The associated class:

class SimpleModel_KB {
    val name: BindingProperty<String> = ...
}

Using in UI:

textView {
    bind { text(SimpleModel_KB.name) }
}

@ztc1997
Now generate the corresponding name constants in the file ~$$KB that is automatically generated for the annotation.
You can use the

`LoginViewModel$$KB`.k_login"

form,also can directly use the "k_login" after the import

`LoginViewModel$$KB`.*

Please see LoginFragment.