hello everyone. MVIKoltin works like a charm. Cong...
# mvikotlin
f
hello everyone. MVIKoltin works like a charm. Congrats for all maintainers. I would like to log info inside Executor. How can I do that properly??
Copy code
override fun executeIntent(intent: Intent, getState: () -> State): Unit =
    when (intent) {
        Intent.StartScan -> scope.startScan()
        Intent.StopScan -> stopScan()
    }

private fun CoroutineScope.startScan() {
    launch {
        withTimeout(20000) {
            Scanner()
                .advertisements
                .onEach { } // log here
                .launchIn(scope)
        }
    }
}
a
Thanks for the feedback! I think in this case you would need custom logging. E.g.
println
, or expect/actual, or use a logging library
f
So LoggingStoreFactory is just for store related, corretc??
a
Yes, it's primarily designed for logging store events. However, you try Logger, it's super simple but may work for you. Just pass it to your store as follows - https://github.com/arkivanov/MVIKotlin/blob/master/mvikotlin-logging/src/commonMain/kotlin/com/arkivanov/mvikotlin/logging/store/LoggingStoreFactory.kt#L23
f
ok, Arkadii, I will try here, tks
Arkadii, more one question please. How can I implement
asvalue
extension using coroutine????
a
You don't need coroutines to convert
Store
to
Value
. In fact, it's much simpler than converting
StateFlow
to
Value
. Check out example - https://github.com/JetBrains/compose-jb/blob/master/examples/todoapp/common/utils/src/commonMain/kotlin/example/todo/common/utils/StoreExt.kt It's also ok to expose
StateFlow
or
Flow
if you like coroutines.
f
ok, I use coroutine everywhere, but I is not problem convert
Store
to
Value
without coroutines
a
Absolutely.
here I used simply
private val output: (Output) -> Unit
. Is it wrong my approach ???
a
That's also fine. Using Consumer there was probably a bit wrong way.
f
ok, thanks again