Skip to content

Conversation

@BestPricklyCactus
Copy link

No description provided.

m_kolobanova added 2 commits September 26, 2025 23:23
1. Исправлена ошибка краща
2. Изменена реализация с `LiveData` на `StateFlow`
3. В случае если возникнет ошибка в стриме, нужно заэмитить айтем `Result.Error`*

PS baseUrl("https://cat-fact.herokuapp.com/facts/") - HTTP  404, поэтому  https://catfact.ninja/
emit(Result.Success(latestNews))
delay(refreshIntervalMs)
} catch (e: Exception) {
emit(Result.Error(e.message))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

при ошибке нет задержки до следующего запроса, потенциально можем закидать ненужными запросами сервер, лучше задержку вынести из try

Toast.makeText(context, result.msg, Toast.LENGTH_SHORT).show()
}

else -> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

вроде как лишнее тут


catsViewModel.catsLiveData.observe(this){
view.populate(it)
lifecycleScope.launch {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут лучше добавить repeatOnLifecycle(Lifecycle.State.STARTED), чтобы в STOPPED не продолжать работу

m_kolobanova added 2 commits October 4, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants