일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- androidStudio
- 암호학
- Kotlin
- Codeforces
- ProGuard
- architecture
- GitHub
- MyVoca
- textfield
- AWS
- MiTweet
- Coroutine
- Rxjava
- Coroutines
- Gradle
- activity
- Python
- 코루틴
- 프로그래머스
- TEST
- boj
- android
- relay
- 백준
- 코드포스
- 쿠링
- livedata
- pandas
- Hilt
- Compose
- Today
- Total
목록Hilt (5)
이동식 저장소

Dagger가 직접 지원하지 않는 클래스에서 객체를 주입받고 싶다면 entry point를 사용해 보자. Entry point는 Dagger가 관리하는 객체 간의 그래프를 참조하기 위한 진입점 역할을 한다. AndroidEntryPoint 사실 우리는 이미 @AndroidEntryPoint라는 어노테이션을 알고 있다. @AndroidEntryPoint는 Hilt가 미리 정의해 둔 entry point로, Activity나 Fragment 등 주요 Android 클래스에서 Hilt 컴포넌트와 해당 컴포넌트에 설치된 Hilt 모듈에 접근할 수 있게 한다. 그러나 AndroidEntryPoint를 사용해도 Hilt가 지원하지 않는 클래스에서 객체를 주입받을 수는 없다. 이런 경우에는 어쩔..

Hilt module은 Dagger의 module에 @InstallIn 어노테이션을 추가한 형태이다. 잠깐 복습: @InstallIn 어노테이션을 사용하면 module을 어느 component에 설치할 지, 즉 해당 module에 정의된 의존성을 어느 범위에서 사용할 수 있는지 지정할 수 있다. @InstallIn 모듈에 @InstallIn 어노테이션을 붙일 수 있다. Hilt를 사용할 때는 모든 module에 @InstallIn을 붙여야 한다. @InstallIn이 없는 모듈은 어떠한 Hilt component에도 속하지 않고, 어쩌면 컴파일 에러가 날 수도 있다. 모듈을 SingletonComponent에 설치하는 예시이다. @Module @Insta..
Hilt는 Jetpack ViewModel을 생성자 주입할 수 있다. 생성자 주입이란 생성자에 @Inject 키워드를 붙이는 방식이다. @HiltViewModel class MainScreenViewModel @Inject constructor( private val someData: Data ) : ViewModel() { /* ... */} 이제 @AndroidEntryPoint 어노테이션이 붙은 클래스에서 ViewModel 객체를 얻을 수 있다. by viewModels() 구문이 많이 사용된다. KTX(KoTlin eXtension) 구문 중 하나이다. 기차 아님. @AndroidEntryPoint class MyActivity : AppCompatActivity() { pr..

Hilt를 사용하려면 Application 클래스에 @HiltAndroidApp 어노테이션을 붙여야 한다. @HiltAndroidApp은 Hilt component 코드를 만드는 시발점이다. @HiltAndroidApp class MyVocaApplication: Application() { @Inject lateinit var foo: Foo } 사실 Application도 Hilt의 entry point이다. 따라서 Application에서도 변수를 주입받을 수 있으며, 해당 변수는 super.onCreate() 안에서 주입된다. 물론 해당 변수를 제공할 바인딩이 SingletonComponent에 존재해야 한다. 잠깐 복습! 바인딩의 위치를 결정하는..

다음 문서를 요약한 글입니다. 인사이트 넘치는 글이니 일독을 권합니다. Hilt Testing Philosophy Overview This page aims to explain the testing practices that Hilt is built upon. A lot of the APIs and functionality in Hilt (and certain lack of functionality as well) were created on an unstated philosophy of what makes a good test. The notion of a good dagger.dev 좋은 테스트 코드는 객체 내부의 구현에 독립적이어야 한다. 예를 들어 함수 A를 실행했을 때 함수 B가 실행되었는지 테..