I have an interesting case, where I essentially ne...
# store
s
I have an interesting case, where I essentially need to switch between store responses on the same screen. So in the view model I am doing something like this:
Copy code
private var selectedVariantIdFlow = MutableStateFlow(variantId)

val dataFlow = selectedVariantIdFlow.flatMapMerge { variantId ->
    store.stream(
        StoreReadRequest.cached(
            key = variantId,
            refresh = false
        )
    ).map {
        println("MAGIC")
    }
}
and then I can trigger updates based on the status of
dataFlow
. What I notice in my particular set up in that even if I switch between only two variants (which are cached for 25 minutes), in the 15th the store flow is no longer triggering the transform (MAGIC). Specially since 15 seems very specific and close to 16, I have been racking my brain trying to figure out what could it be. So couple of questions: 1. Is there a way to enable additional logging in stream or something to help with debugging? I didn't see anything in the docs or the public APIs 2. Any idea on how to approach on debugging this issue?\
I found my issue. It is the use of flatMapMerge while I actually need the latest value so needed to use flatMapLatest. https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-d-e-f-a-u-l-t_-c-o-n-c-u-r-r-e-n-c-y.html
That said it can still be useful to have a way to enable debug logs easily.
m
Thanks Saud! Sorry to be slow. I created a ticket: https://github.com/MobileNativeFoundation/Store/issues/638
🙏🏽 1