Hi everyone, do SQLDelght queries execute on main ...
# squarelibraries
a
Hi everyone, do SQLDelght queries execute on main thread then I need wrap them with Dispatchers.IO
y
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
the sqldelight apis are blocking not suspending, aren't they?
y
Sorry, my bad. Was thinking it's suspend API like room. I'll defer to the experts :)
k
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
the docs say the default dispatcher for
mapToList
is removed in sqldelight 2.0 so you always have to specify your own
s
Why isn't there a version of
mapToList
that inherits the context from the flow? Like:
Copy code
.map { it.awaitAsList() }
.flowOn(context)