Skip to content

Conversation

@BestPricklyCactus
Copy link

  1. Переод с коллбеков на саспенд функции и корутины
  2. Добавлено к запросу фактов запрос рандомных картинок
  3. Реализация решения ViewModel

lateinit var catsPresenter: CatsPresenter

private val diContainer = DiContainer()
private var isPresenretMode = true

Choose a reason for hiding this comment

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

nit: опечатка isPresenterMode

Copy link
Author

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()

Choose a reason for hiding this comment

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

нет проверки на инициализацию catsPresenter, в режиме isPresenterMode == false будет краш

Copy link
Author

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))

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 ->

Choose a reason for hiding this comment

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

можно сделать приватным, снаружи не нужен

Copy link
Author

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

Choose a reason for hiding this comment

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

не стоит во вью подкладывать ссылку на вьюмодель, она там вообще не нужна

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

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