Skip to content

What's the best approach to manually append some data to a Store's contents? #612

Answered by matt-ramotar
erawhctim asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for sharing. Here's one way you could approach this. Note that StoreKey, StoreData, and StoreMultiCache are experimental and will change.

@OptIn(ExperimentalStoreApi::class)
sealed class Key : StoreKey<String> {
    data class Collection(
        val isLoggedIn: Boolean, val key2: String?,
        override val insertionStrategy: InsertionStrategy = InsertionStrategy.APPEND
    ) : Key(), StoreKey.Collection<String>

    data class Single(val id: String) : Key(), StoreKey.Single<String>
}

@OptIn(ExperimentalStoreApi::class)
sealed class ResponseModel : StoreData<String> {
    data class Collection(
        override val items: List<Single>, override val itemsAfter: Int? = null,
    …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@matt-ramotar
Comment options

@erawhctim
Comment options

@matt-ramotar
Comment options

Answer selected by matt-ramotar
@erawhctim
Comment options

@matt-ramotar
Comment options

@matt-ramotar
Comment options

@erawhctim
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants