Skip to content

Conversation

@dmilkov97
Copy link

No description provided.

override fun onFailure(call: Call<Fact>, t: Throwable) {
CrashMonitor.trackWarning()
catch (e: Exception) {
when (e) {

Choose a reason for hiding this comment

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

тут будет перехвачено CancellationException, что сломает механизм отмены корутин, нужно прокидывать его дальше
is CancellationException -> throw e

_result.value = Result.Success(fact)
}
catch (e: Exception) {
CrashMonitor.trackWarning(e)

Choose a reason for hiding this comment

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

здесь тоже CancellationException

override fun onCleared() {
super.onCleared()
detachView()
viewModelScope.cancel()

Choose a reason for hiding this comment

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

viewModelScope сам отменится, это избыточно

private val catsService: CatsService,
private val catsServicePics: CatsServicePics
) : ViewModel() {
private var _catsView: ICatsView? = null

Choose a reason for hiding this comment

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

тут архитектурная проблема, ViewModel в отличие от Presenter ничего не знает о View и не должна хранить на нее ссылку, вью должна сама подписаться на стейты вьюмодели и обновлять свое состояние в соответствии с ними

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