Updated on 2026-08-14
This commit is contained in:
parent
d2f28313e9
commit
96d5f31d82
4 changed files with 25 additions and 26 deletions
|
|
@ -28,7 +28,7 @@ interface NewsRepository {
|
|||
*
|
||||
* @param config config for getting news list
|
||||
*/
|
||||
fun getNews(config: NewsListConfig, limit: Int): Flow<List<ShortArticle>>
|
||||
fun getNews(config: NewsListConfig, limit: Int): Flow<Either<Throwable, List<ShortArticle>>>
|
||||
|
||||
/**
|
||||
* Observes cached detailed articles.
|
||||
|
|
|
|||
|
|
@ -8,11 +8,9 @@ import kotlinx.coroutines.flow.Flow
|
|||
|
||||
class GetNewsUseCase(private val repository: NewsRepository) {
|
||||
|
||||
fun getNews(limit: Int, newsListConfig: NewsListConfig): Either<Throwable, Flow<List<ShortArticle>>> =
|
||||
Either.catch {
|
||||
repository.getNews(
|
||||
config = newsListConfig,
|
||||
limit = limit,
|
||||
)
|
||||
}
|
||||
fun getNews(limit: Int, newsListConfig: NewsListConfig): Flow<Either<Throwable, List<ShortArticle>>> =
|
||||
repository.getNews(
|
||||
config = newsListConfig,
|
||||
limit = limit,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue