0Pricing
Jetpack Compose Academy · Lesson

Scopes & Component Lifetimes

Control how long dependencies live.

What a Scope Controls

A scope decides how long Hilt keeps a single instance alive and where it gets shared. It is about lifetime, not just creation.

Unscoped by Default

Without a scope annotation, Hilt builds a new instance every time it is requested. That is fine for cheap, stateless objects.

@Provides
fun provideMapper(): Mapper = Mapper() // fresh each time

All lessons in this course

  1. Why DI: Testable, Decoupled Code
  2. Modules, @Provides & @Binds
  3. hiltViewModel & @HiltViewModel
  4. Scopes & Component Lifetimes
← Back to Jetpack Compose Academy