Hi everyone, do SQLDelght queries execute on main thread then I need wrap them with Dispatchers.IO?
y
yschimke
04/30/2023, 12:27 PM
I don't know the answer. But I think it's agreed that we'll written coroutines libraries are main safe. So it should be a bug if you need to do that. Hopefully only doing a small and acceptable amount of work on the main thread if at all.
e
ephemient
04/30/2023, 12:42 PM
the sqldelight apis are blocking not suspending, aren't they?
y
yschimke
04/30/2023, 12:44 PM
Sorry, my bad. Was thinking it's suspend API like room. I'll defer to the experts :)
k
kevin.cianfarini
04/30/2023, 1:50 PM
For single shot functions the threadpool queries run on is up to you (via withContext).
The flow extension requires you provide a dispatcher which defaults to
Dispatchers.Default
.
e
ephemient
04/30/2023, 1:55 PM
the docs say the default dispatcher for
mapToList
is removed in sqldelight 2.0 so you always have to specify your own