HiltDependency Injection
Alireza Nazari
http://AlirezaNazari.ir
Hilt vs Dagger
• Hilt built on top of dagger
• Hilt has all of dagger ability
• Hilt reduce much boilerplate codes
Hilt advantageous
• Write less code
• Make source more readable
• Construct easier a DI for beginner developers.
logcat Hilt
Application.kt in Dagger
Application.kt in Hilt
Component in Dagger
Component in Hilt
Nothing
Components and Scopes
• Application Component (@Singleton)
• Activity Component (@ActivityScoped)
• Activity Retained Component (@ActivityRetainedScoped)
• Fragment Component (@FragmentScoped)
• Service Component (@ServiceScoped)
• View Component (@ViewScoped)
Modules
Activity or Fragments in Dagger
Activity or Fragments in Hilt
View Models in Dagger
View Models in Hilt
Entry Point
@EntryPoint
@InstallIn(SingletonComponent::class)
interface FooBarInterface {
@Foo fun getBar(): Bar
}
val bar = EntryPoints.get(applicationContext,
FooBarInterface::class.java).getBar()
Custom Component
@DefineComponent(parent = SingletonComponent.class)
interface MyCustomComponent {}
@DefineComponent.Builder
interface MyCustomComponentBuilder {
MyCustomComponentBuilder fooSeedData(@BindsInstance Foo foo);
MyCustomComponent build();
}
@EntryPoint
@InstallIn(MyCustomComponent.class)
Testing
Thank you
https://dagger.dev/hilt/
https://developer.android.com/training/dependency-injection/hilt-android

More Related Content

PDF
PostGraphQL
PDF
Adding GraphQL to your existing architecture
PDF
Who's afraid of front end databases
PDF
GraphQL: The Missing Link Between Frontend and Backend Devs
PDF
Performance optimisation with GraphQL
PPTX
Angularjs Basics
PDF
Modular GraphQL with Schema Stitching
PDF
Eclipse IDE Tips and Tricks - Lakshmi Priya Shanmugam
PostGraphQL
Adding GraphQL to your existing architecture
Who's afraid of front end databases
GraphQL: The Missing Link Between Frontend and Backend Devs
Performance optimisation with GraphQL
Angularjs Basics
Modular GraphQL with Schema Stitching
Eclipse IDE Tips and Tricks - Lakshmi Priya Shanmugam

What's hot (19)

PDF
Intro to the Intersection Observer API - Tara Ojo
PDF
PDF
Introduction to GraphQL at API days
PDF
GraphQL over REST at Reactathon 2018
PDF
Implementing GraphQL - Without a Backend
PPTX
Into to GraphQL
PPTX
Functional Reactive Endpoints using Spring 5
PPTX
An intro to GraphQL
PPTX
Introduction to GraphQL
PPTX
Sap open connectors #sitcph
PDF
GraphQL
PDF
GraphQL + relay
PDF
AppSyncをReactで使ってみた
PDF
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
PDF
AppSphere 15 - PHP, Node.js and Python Deep Dive
PDF
The Apollo and GraphQL Stack
PPTX
GraphQL Introduction
PDF
Let's Graph
PDF
AngularJS Basics
Intro to the Intersection Observer API - Tara Ojo
Introduction to GraphQL at API days
GraphQL over REST at Reactathon 2018
Implementing GraphQL - Without a Backend
Into to GraphQL
Functional Reactive Endpoints using Spring 5
An intro to GraphQL
Introduction to GraphQL
Sap open connectors #sitcph
GraphQL
GraphQL + relay
AppSyncをReactで使ってみた
Alon Fliess: APM – What Is It, and Why Do I Need It? - Architecture Next 20
AppSphere 15 - PHP, Node.js and Python Deep Dive
The Apollo and GraphQL Stack
GraphQL Introduction
Let's Graph
AngularJS Basics
Ad

Recently uploaded (20)

PDF
STKI Israel Market Study 2025 version august
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
CloudStack 4.21: First Look Webinar slides
PPTX
The various Industrial Revolutions .pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Architecture types and enterprise applications.pdf
PDF
Five Habits of High-Impact Board Members
PPT
What is a Computer? Input Devices /output devices
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
Tartificialntelligence_presentation.pptx
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
August Patch Tuesday
STKI Israel Market Study 2025 version august
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
DP Operators-handbook-extract for the Mautical Institute
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
observCloud-Native Containerability and monitoring.pptx
Taming the Chaos: How to Turn Unstructured Data into Decisions
Getting started with AI Agents and Multi-Agent Systems
CloudStack 4.21: First Look Webinar slides
The various Industrial Revolutions .pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Architecture types and enterprise applications.pdf
Five Habits of High-Impact Board Members
What is a Computer? Input Devices /output devices
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Tartificialntelligence_presentation.pptx
sustainability-14-14877-v2.pddhzftheheeeee
Hindi spoken digit analysis for native and non-native speakers
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
August Patch Tuesday
Ad

logcat Hilt