-
Notifications
You must be signed in to change notification settings - Fork 241
HomeWork2 #264
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: development
Are you sure you want to change the base?
HomeWork2 #264
Conversation
BestPricklyCactus
commented
Sep 22, 2025
- Переод с коллбеков на саспенд функции и корутины
- Добавлено к запросу фактов запрос рандомных картинок
- Реализация решения ViewModel
| lateinit var catsPresenter: CatsPresenter | ||
|
|
||
| private val diContainer = DiContainer() | ||
| private var isPresenretMode = true |
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.
nit: опечатка isPresenterMode
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.
Fixed
| override fun onStop() { | ||
| if (isFinishing) { | ||
| catsPresenter.detachView() | ||
| catsPresenter.onStop() |
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.
нет проверки на инициализацию catsPresenter, в режиме isPresenterMode == false будет краш
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.
Fixed
| when (state) { | ||
| is Result.Success<*> -> { | ||
| if (state.data is Model) { | ||
| view.populate(Model(state.data.fact, state.data.imageUrl)) |
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.
лишнее пересоздание модели, можно скастить к Model
| private val _state = MutableStateFlow<Result>(Result.Error("Не получилось получить факт")) | ||
| val state: StateFlow<Result> = _state.asStateFlow() | ||
|
|
||
| val handler = CoroutineExceptionHandler { _, exception -> |
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.
можно сделать приватным, снаружи не нужен
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.
Fixed
| ::onShowToast | ||
| ) | ||
| viewModel.onInitComplete() | ||
| view.viewModel = viewModel |
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.
не стоит во вью подкладывать ссылку на вьюмодель, она там вообще не нужна
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.
Fixed