Androidx DataStore generated support
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 4.4k
- Forks
- 627
- Avg merge
- 3d 15m
- Merged PRs (30d)
- 20
Description
Is there any plans for integration with Androidx DataStore? Or does Androidx provide this somewhere?
There are some nuances with https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:datastore/datastore-core-okio/src/commonMain/kotlin/androidx/datastore/core/okio/OkioSerializer.kt?q=OkioSerializer
That would be good to handle once. Something like
fun <T: Message<T, Nothing>> ProtoAdapter<T>.toOkioSerializer(): OkioSerializer<T> {
return object : OkioSerializer<T> {
override val defaultValue: T = this@toOkioSerializer.decode(ByteString.EMPTY)
override suspend fun readFrom(source: BufferedSource): T {
try {
return this@toOkioSerializer.decode(source)
} catch (exception: IOException) {
throw CorruptionException("Cannot read UserFavouriteGames proto.", exception)
}
}
override suspend fun writeTo(t: T, sink: BufferedSink) {
sink.write(t.encode())
}
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with AndroidX's datastore-core-okio OkioSerializer.kt implementation linked in the issue, then compare it with the proposed ProtoAdapter extension. Check the default-value, readFrom, and writeTo behavior shown in the example; done means Wire provides the requested AndroidX DataStore integration while handling those noted nuances.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100