they are synchronous so use `withContext`
# squarelibraries
j
they are synchronous so use
withContext
👍 3
m
@jw what about when we request as flow ? will
Copy code
fun getActiveCurrencies() = currencyQueries
        .getActiveCurrencies()
        .asFlow()
        .flowOn(ioDispatcher)
        .mapToList(ioDispatcher)
be enough ? or should we still call with
withContext
like this?
Copy code
suspend fun getActiveCurrencies() = withContext(ioDispatcher) {
        currencyQueries
            .getActiveCurrencies()
            .asFlow()
            .flowOn(ioDispatcher)
            .mapToList(ioDispatcher)
    }
j
Remove flowOn
Also withContext
Also suspend
m
Thanks a lot for the answers! Removing
withContext
and
suspend
makes perfect sense, but I confused about removing the
flowOn(ioDispatcher)
is SQLDelight emitting value changes on IO thread ?
j
You pass a dispatcher to the map function which is where the query is executed
m
Ohh right, the rest actually doesn’t require the context in terms of the querying 👍 Thanks a lot!