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
Albert Chang
08/31/2021, 12:05 AM
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