Post AaH8DuViNyRSFuEbui by py@androiddev.social
(DIR) More posts by py@androiddev.social
(DIR) Post #AaH8DsUZtELNzngfrc by py@androiddev.social
2023-09-29T05:43:11Z
0 likes, 0 repeats
I've been reading the sources of Android Datastore internals and....A library who's sole purpose is dumping a binary to a file and reading it later has no business being that complex.So many layers of locks & suspending functions, it's really hard to reason about.SharedPreferencesImpl, Tape, SQLite internals are all easier to understand than Datastore...https://github.com/androidx/androidx/tree/androidx-main/datastore
(DIR) Post #AaH8DtaHpUVLNnMkOu by py@androiddev.social
2023-09-29T16:36:07Z
0 likes, 0 repeats
Undocumented behavior AFAIK: when running a migration on initial read, Datastore will write the migrated value to disk only if the data's equals() method returns true.That's a pretty big deal, you better implement equals() right for your data! https://github.com/androidx/androidx/blob/androidx-main/datastore/datastore-core/src/commonMain/kotlin/androidx/datastore/core/DataStoreImpl.kt#L357-L359
(DIR) Post #AaH8DuSAb9be4uZmO8 by friendlymike@androiddev.social
2023-09-30T00:00:36Z
0 likes, 0 repeats
@py I don't write many docs but that's one I remembered in Store
(DIR) Post #AaH8DuViNyRSFuEbui by py@androiddev.social
2023-09-29T05:44:46Z
0 likes, 0 repeats
I'm reading the internals in the context of us having read timeouts or deadlocks on the initial read & trying to figure out what could be happening (no, "slow disk" isn't a good enough reason)
(DIR) Post #AaH8RATgKbEXXdbaro by friendlymike@androiddev.social
2023-09-30T00:03:01Z
0 likes, 0 repeats
@py I wonder if you can somehow do a contract for classes that are data classes/implement hashcode/equals. Tbh why would you have data that doesn't implement those? Wouldn't you have same risk that someone would use in a map
(DIR) Post #AaHEIwExyseenGBJD6 by saket@androiddev.social
2023-09-30T01:08:45Z
0 likes, 0 repeats
@friendlymike @py I often wish Kotlin had something like Equatable from Swift
(DIR) Post #AaHEp1UK0PlaKrf9mq by ryan@social.harter.us
2023-09-30T01:14:33Z
0 likes, 0 repeats
@friendlymike @py But *every* class implements hash code and equals since Object implements it. Without requiring data/value classes (which seems like a strict requirement, if even possible), there's not really any way to know if the class overrode equals or not.
(DIR) Post #AaHpPDXuFVKYVUtiQy by fourlastor@androiddev.social
2023-09-30T08:04:29Z
0 likes, 0 repeats
@friendlymike @py `interface PleaseImplementEquals`