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.
#️⃣연관된 이슈
#23
📝작업 내용
Hilt를 사용하여 의존성 주입을 적용하고 코드의 유지보수성을 개선하였습니다.
Hilt는 Android 공식 DI 솔루션으로 Dagger의 성능을 유지하면서 설정이 간편하고 Jetpack과 완벽히 연동가능 해 Hilt로 선택하였습니다.
Viewmodel 의존성 주입
@HiltViewModel
을 추가하여 MainViewmodel을 Hilt에서 관리하도록 변경UnsplashRepository
를 생성자 주입하여 종송석 정의Repository 의존성 주입
UnsplashRepository
에@Inject
를 추가하여 Hilt가 자동으로 관리하도록 설정API통신을 위한
UnsplashApiService
를 생성자 주입Retrofit 의존성 주입
@Provides
와@Singleton
을 사용하여Retrofit
과UnsplashApiService
를 DI 컨테이너에서 관리하도록 설정API 호출 시 객체를 매번 생성하지 않고, 하나의 인스턴스를 공유하도록 개선
참고 내용
Hilt android developers