-
Notifications
You must be signed in to change notification settings - Fork 222
HW_3 #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
HW_3 #230
Conversation
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)) |
There was a problem hiding this comment.
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 -> { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 не продолжать работу
- add repeatOnLifecycle
No description provided.