I am wondering if there's a better way to call a method on an element within a list that is contained in a Flow. Currently i'm doing this but i don't like calling map() twice:
override fun getEarnings(): Flow<List<Transaction>> {
return transactionDao.getEarnings().map {
it.map { transaction -> transaction.asDomainModel() }
}
}
the getEarnings() method defined in the transactionsDao:
@Query("SELECT * FROM transactions WHERE is_income = 1")
fun getEarnings(): Flow<List<DatabaseTransaction>>