Skip to content

Conversation

@temikng
Copy link

@temikng temikng commented May 28, 2024

No description provided.

Copy link
Contributor

@antonkazakov antonkazakov left a 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,
Copy link
Contributor

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.

Они здесь и не имитятся, только подписка на события.
Или я не правильно понял по задаче?

Copy link
Contributor

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,
Copy link
Contributor

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
Copy link
Contributor

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() {
Copy link
Contributor

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,
Copy link
Contributor

Choose a reason for hiding this comment

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

Но у тебя при этом есть возможность заэмитить, а яя не должно быть.
Посмотри на разделение в stateflow/livedata

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