반응형

hilt 3

[Android] Concept of DI Hilt. Dive into Hilt Components.

Component Hierarchy 기존 Dagger와 달리 Hilt 사용자는 Dagger의 Components를 직접 정의하거나 인스턴스화하지 않는다. 대신 Hilt는 사용자를 위해 생성되는 미리 정의된 Components를 제공한다. Hilt는 안드로이드 애플리케이션의 다양한 라이프 사이클에 맞춰 자동으로 통합되는 Components(및 해당 Scope Annotaion) 세트가 제공된다. 아래 Diagram은 Hilt Component의 계층 구성도를 보여준다. 각 Component의 주석은 해당 Component의 수명으로 바인딩 범위를 지정하는 데 사용되는 범위 지정 주석이다. Component의 화살표는 하위 Components를 가리킨다. 일반적으로 하위 Components의 바인딩은 상위 ..

[Android] Hilt AndroidEntryPoint Annotation

Introduce Application에서 멤버 주입을 사용 가능으로 설정한 후, @AndroidEntryPoint Annotation을 사용하여 다른 Android class에서 멤버 주입을 사용 가능으로 설정할 수 있다. 다음 유형에서 @AndroidEntryPoint를 사용할 수 있다. Activity Fragment View Service BroadcastReceiver @AndroidEntryPoint class MyActivity : MyBaseActivity() { // Bindings in SingletonComponent or ActivityComponent @Inject lateinit var bar: Bar override fun onCreate(savedInstanceState: B..

Foundation/Android 2022.11.20

[Android] Dive inti concept of Hilt Annotations. @_@

Introduce Hilt는 Android Application에 Dagger Dependency Injection을 통합하는 표준화된 방법을 제공한다. Hilt를 사용하면 Android 앱에 종속성 주입을 쉽게 추가할 수 있다. Hilt의 목표 Android Application을 위한 Dagger 관련 인프라를 단순화한다. 가독성, 이해 및 코드 공유를 용이하게 하는 Standard set of Components 및 Scopes를 만든다. 다양한 빌드 유형에 서로 다른 바인딩을 쉽게 프로비저닝 할 수 있는 방법을 제공한다. Hilt Application Hilt를 사용하는 모든 앱은 @HiltAndroidApp Annotation이 포함된 Application class를 사용해야 한다. @Hilt..