Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
주요 내용
참고
아래는 ViewModel이 Activity의 Context를 참조하면 안되는 이유를 개인적으로 정리하였던 내용인데 공유하면 좋을 것 같아 같이 남겨두었습니다.
ViewModel이 Activity의 Context를 참조하면 안 되는 이유
https://developer.android.com/topic/libraries/architecture/viewmodel?hl=ko#best-practices
ViewModel은 UI 관련 데이터를 관리하고 Configuration Change 시에도 데이터를 유지하도록 설계되었습니다. 이러한 특성 때문 ViewModel은 Activity나 Fragment의 생명주기와 독립적으로 동작합니다. 따라서 ViewModel이 Activity의 Context를 참조하게 되면 다음과 같은 문제가 발생할 수 있습니다: