-
Notifications
You must be signed in to change notification settings - Fork 174
Решение ДЗ по Dagger 2 #130
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?
Conversation
antonkazakov
left a comment
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.
Привет. Пару комментов написал
app/src/main/java/ru/otus/daggerhomework/ApplicationComponent.kt
Outdated
Show resolved
Hide resolved
| private val context: Context | ||
| ) { | ||
| @ContextApplication private val context: Context, | ||
| private val colorObservable: IColorObservable, |
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.
Они здесь и не имитятся, только подписка на события.
Или я не правильно понял по задаче?
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.
Но у тебя при этом есть возможность заэмитить, а яя не должно быть.
Посмотри на разделение в stateflow/livedata
| private val colorGenerator: ColorGenerator, | ||
| private val context: Context | ||
| ) { | ||
| @ContextActivity private val context: Context, |
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.
Здесь будет утечка памяти. Тк ViewModelProducer живет дольше чем Context
| class MainActivity : AppCompatActivity() { | ||
| @Inject | ||
| @ContextApplication | ||
| lateinit var _applicationContext: Context |
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.
Его можно не инжектить. У активити есть метод getApplication
| ) { | ||
| private val context: Context, | ||
| private val colorObservable: IColorObservable, | ||
| ): 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.
Нужно убрать наследование иначе потечет память тк ВМ живет дольше чем активити
| private val context: Context | ||
| ) { | ||
| @ContextApplication private val context: Context, | ||
| private val colorObservable: IColorObservable, |
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.
Но у тебя при этом есть возможность заэмитить, а яя не должно быть.
Посмотри на разделение в stateflow/livedata
No description provided.