All methods that return Flow must not be suspendable
This commit is contained in:
+3
-3
@@ -10,19 +10,19 @@ import javax.inject.Inject
|
||||
class LocalLottieFileDataSource @Inject constructor(
|
||||
private val lottieFileDao: LottieFilesDao
|
||||
) : LottieFileDataSource {
|
||||
override suspend fun findRecent(): Flow<Result<List<Lottiefile>>> {
|
||||
override fun findRecent(): Flow<Result<List<Lottiefile>>> {
|
||||
return lottieFileDao.findRecent().map {
|
||||
Result.Success(it)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun findPopular(): Flow<Result<List<Lottiefile>>> {
|
||||
override fun findPopular(): Flow<Result<List<Lottiefile>>> {
|
||||
return lottieFileDao.findPopular().map {
|
||||
Result.Success(it)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun findFeatured(): Flow<Result<List<Lottiefile>>> {
|
||||
override fun findFeatured(): Flow<Result<List<Lottiefile>>> {
|
||||
return lottieFileDao.findFeatured().map {
|
||||
Result.Success(it)
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@ import com.ericampire.android.androidstudycase.util.Result
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface LottieFileDataSource {
|
||||
suspend fun findRecent(): Flow<Result<List<Lottiefile>>>
|
||||
suspend fun findPopular(): Flow<Result<List<Lottiefile>>>
|
||||
suspend fun findFeatured(): Flow<Result<List<Lottiefile>>>
|
||||
fun findRecent(): Flow<Result<List<Lottiefile>>>
|
||||
fun findPopular(): Flow<Result<List<Lottiefile>>>
|
||||
fun findFeatured(): Flow<Result<List<Lottiefile>>>
|
||||
suspend fun save(lottiefile: Lottiefile)
|
||||
}
|
||||
+4
-4
@@ -14,7 +14,7 @@ class RemoteLottieFileDataSource @Inject constructor(
|
||||
private val httpClient: HttpClient
|
||||
) : LottieFileDataSource {
|
||||
|
||||
private suspend fun find(url: String): Flow<Result<List<Lottiefile>>> {
|
||||
private fun find(url: String): Flow<Result<List<Lottiefile>>> {
|
||||
return flow {
|
||||
try {
|
||||
val data = httpClient.get<LottieFilesApiResponse>(url)
|
||||
@@ -25,15 +25,15 @@ class RemoteLottieFileDataSource @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun findRecent(): Flow<Result<List<Lottiefile>>> {
|
||||
override fun findRecent(): Flow<Result<List<Lottiefile>>> {
|
||||
return find(ApiUrl.LottieFile.recent)
|
||||
}
|
||||
|
||||
override suspend fun findPopular(): Flow<Result<List<Lottiefile>>> {
|
||||
override fun findPopular(): Flow<Result<List<Lottiefile>>> {
|
||||
return find(ApiUrl.LottieFile.popular)
|
||||
}
|
||||
|
||||
override suspend fun findFeatured(): Flow<Result<List<Lottiefile>>> {
|
||||
override fun findFeatured(): Flow<Result<List<Lottiefile>>> {
|
||||
return find(ApiUrl.LottieFile.featured)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user