i have a problem in my app that inside a compose u...
# compose-desktop
z
i have a problem in my app that inside a compose ui component i do some SQL for it to render. it get info from the database. so far it works fine. you now may probabaly say, hey dont do that. but lets just for now say it has to be that way. bear with me. now the problem is when i activate WAL mode on sqlite i have issues. because when the compose step is interrupted the sql stuff may not fully finish and the statement is not closed. giving "database table is locked" and WAL mode only appends to the WAL file from then on. so say i have:
Copy code
Row() {
  val x = do_sql_stuff_here()
  Text(x)
}
is there a "simple" way to say that
do_sql_stuff_here()
must always finish and never be cancelled?
a
Look into produceState
z
ok i will check it. but another question is there any way for the do_sql_stuff_here() function to know when it is killed? how does compose actually technically stop composition? does it kill the thread?
a
It doesn’t kill the Thread. If you want to be notified when the composable leaves the composition, use DisposableEffect. If you want to run on every successful composition, use SideEffect.
k
The answer is simple, don’t do that. There’s documentation on how to separate data fetching and handling from the UI construction.
☝🏻 2
☝🏼 1
z
And the answers to your other questions (lifecycle and cancellation) are basically “coroutines”.