why not add a new key world observable to kotlin `...
# android
c
why not add a new key world observable to kotlin
Copy code
data class ObservableFieldProfile(
        val name: String,
        val lastName: String,
        val likes: ObservableInt
)
to reduce such long meaningless name into
Copy code
observable FieldProfile (
        val name: String,
        val lastName: String,
        val likes: Int
)
šŸ¤” 4
šŸ‘ŽšŸ» 1
šŸ‘Ž 3
šŸ‘ŽšŸ¾ 1
a
Doesn’t make sense to me. First example here is just naming the object ā€œobservable ā€œ but it’s not even observable. It’s just a data class
šŸ‘ 1
You want all fields individually observable?
c
why it is named ObservableFieldProfile if it is not an observable data ?
You should ask android team why made it observable first.
c
FYI. that
observableFieldsActivityButton
is derived form the
id
of the view in the xml. you can name it whatever you want.
and it has nothing to do with observables. you should check the tutorial you are refering to a little bit deeper.
c
You should tell the example builder to learn a good naming skill to avoid such misunderstanding.
c
It’s a good name in my opionion - it’s the button the open the Observable Field Activity šŸ˜… couldn’t be less expressive šŸ˜‚
c
Maybe Christian Grach Observable Field Activity is a much cheaper name.
šŸ‘Ž 1
šŸ‘ŽšŸ¾ 1
c
Why so ovensive? I just try to give you feedback why someone is doing something that you did not understand in the first place.
c
I just try to follow your logic to understand what is less expensive.
c
What you mean with expensive? How would a meaningful name be ā€œexpensiveā€
šŸ˜„ 2
a
I don’t see how it’s more clear when a field is declared with the type it is. You can also use Kotlin delegation to make all fields observable, or the usage of the data class as observable itself
k
why not just have a keyword for everything? Surely that would help?
Copy code
class observable field profile
Oh no….compiler error:
Copy code
e: observable can only be called from the context of an observable identifier, field is not observable
🧌
šŸ‘€ 1
c
> why not add a new key world observable to kotlin It's already in the standard library:
Copy code
var value: Int by Delegates.observable { p, old, new ->
    println("The value changed: $old -> $new")
}
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.properties/-delegates/observable.html