Quantcast
Viewing all articles
Browse latest Browse all 210

Get value from RoomDB into Composable function from Jetpack Compose

I have looked for many solutions but I found it as a newbie verycomplex on how to solve it properly without throwing away all my backendcode.

I want to get an Float value from my RoomDB into a composableUI value but as far as we all know getting RoomDB values with queriesneeds an asynchronus scope. And those aren't capable of returning valuesbecause values stay within a scope and die there too. There is I thinkno way to no use Coroutine Scopes or anything else that doesn't block the UI loadingso it can actually work.

What can I do? I don't want to throw away the entire RoomDB databaseneither our Jetpack Compose base GUI?

I tried replacing the 0.8f with a method that calls a Coroutine Scope whichshould idealistically return a Float value to this part of our code.

@Composablefun ChargeScreen(){    val context = LocalContext.current    Box(        contentAlignment = Alignment.Center,        modifier = Modifier.fillMaxSize()    ){        Column {            ChargeTopText()            CircularChargeBar(percentage = 0.8f, number =100 )        }    }}

Viewing all articles
Browse latest Browse all 210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>