Updated on 2026-08-14
This commit is contained in:
parent
75e81283f8
commit
faaa2aad8f
28 changed files with 795 additions and 316 deletions
|
|
@ -23,18 +23,11 @@ interface NewsRepository {
|
|||
fun getNewsListBatchFlow(context: NewsListBatchingContext, batchSize: Int): NewsListBatchFlow
|
||||
|
||||
/**
|
||||
* Returns list of short article by config.
|
||||
* Returns flow of list of short article by config.
|
||||
*
|
||||
* @param config config for getting news list
|
||||
*/
|
||||
suspend fun getNews(config: NewsListConfig, limit: Int): List<ShortArticle>
|
||||
|
||||
/**
|
||||
* Returns detailed article by id with locale configuration.
|
||||
* @param newsId news identification
|
||||
* @param language current locale
|
||||
*/
|
||||
suspend fun getDetailedArticle(newsId: Int, language: String?): DetailedArticle
|
||||
fun getNews(config: NewsListConfig, limit: Int): Flow<List<ShortArticle>>
|
||||
|
||||
/**
|
||||
* Observes cached detailed articles.
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ import arrow.core.Either
|
|||
import com.tangem.domain.models.news.ShortArticle
|
||||
import com.tangem.domain.news.model.NewsListConfig
|
||||
import com.tangem.domain.news.repository.NewsRepository
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
class GetNewsUseCase(private val repository: NewsRepository) {
|
||||
|
||||
suspend fun getNews(limit: Int, newsListConfig: NewsListConfig): Either<Throwable, List<ShortArticle>> =
|
||||
fun getNews(limit: Int, newsListConfig: NewsListConfig): Either<Throwable, Flow<List<ShortArticle>>> =
|
||||
Either.catch {
|
||||
repository.getNews(
|
||||
config = newsListConfig,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue