What is the reason to not update the UI if you use...
# compose
h
What is the reason to not update the UI if you use Room directly with Compose:
dao.get().collectAsState(emptyList())
with
interface Dao { @Query(...) fun get(): Flow }
? You have to use a ViewModel to get updates on DB changes. WA: wrap the
collect
in VM and emit them to the flow accessed by Compose...
a
dao.get()
is a function, which means every time it is called you get a new flow, and it will be called on every recomposition. If you really want to use it directly in a composable function, you should use
remember { dao.get() }.collectAsState(emptyList())
.
h
Thanks, makes sense!