https://kotlinlang.org logo
#android
Title
# android
c

calidion

09/28/2023, 5:54 AM
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

agrosner

09/28/2023, 11:11 AM
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

calidion

09/28/2023, 11:41 AM
why it is named ObservableFieldProfile if it is not an observable data ?
You should ask android team why made it observable first.
c

Chrimaeon

09/28/2023, 2:31 PM
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

calidion

09/28/2023, 3:12 PM
You should tell the example builder to learn a good naming skill to avoid such misunderstanding.
c

Chrimaeon

09/28/2023, 3:17 PM
It’s a good name in my opionion - it’s the button the open the Observable Field Activity 😅 couldn’t be less expressive 😂
c

calidion

09/28/2023, 3:19 PM
Maybe Christian Grach Observable Field Activity is a much cheaper name.
👎 1
👎🏾 1
c

Chrimaeon

09/28/2023, 3:21 PM
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

calidion

09/28/2023, 3:29 PM
I just try to follow your logic to understand what is less expensive.
c

Chrimaeon

09/28/2023, 3:30 PM
What you mean with expensive? How would a meaningful name be “expensive”
😄 2
a

agrosner

09/28/2023, 4:26 PM
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

kevin.cianfarini

09/28/2023, 5:19 PM
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

CLOVIS

10/03/2023, 12:13 PM
> 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
2 Views