Android-CleanArchitecture-Kotlin icon indicating copy to clipboard operation
Android-CleanArchitecture-Kotlin copied to clipboard

info query about binding format in the view

Open giuliohome opened this issue 7 years ago • 1 comments

For me this project is interesting because it is based on viewmodel pattern I see it uses livedata, observe: very cool! But I would have expected to see the binding like

    android:layout_height="wrap_content"
    android:text="@{user.firstName, default=my_default}"/>

(from https://developer.android.com/topic/libraries/data-binding/expressions) where are they in such project? Thanks in advance for your hint!

giuliohome avatar Jul 23 '18 23:07 giuliohome

Do you think it makes sense to introduce (from this other [post] ) a gradle dependency for databinding?(http://www.albertgao.xyz/2018/04/13/minimal-android-mvvm-databinding-setup-with-kotlin/))

apply plugin: 'kotlin-kapt'
android {
  dataBinding {
      enabled = true
  }
}
dependencies {
    implementation "android.arch.lifecycle:extensions:1.1.1"
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
    kapt "com.android.databinding:compiler:3.1.1"
}

so that one can simply write android:text="@{viewModel.name}"?

Or see the paragraph Layout, DataBinding and BindingAdapters of a longer article about MVVM kith Kotlin.

I come from the world of MVVM in dotnet (C# and F# with WPF) so I'd appreciate very much the {...} curly parentheses format for data binding :-)

giuliohome avatar Jul 24 '18 07:07 giuliohome