Skip to content

Instantly share code, notes, and snippets.

@skywall
Created November 7, 2020 20:57
Show Gist options
  • Save skywall/87c2289bdc6f7ae0a8bac8fe2f05e249 to your computer and use it in GitHub Desktop.
Save skywall/87c2289bdc6f7ae0a8bac8fe2f05e249 to your computer and use it in GitHub Desktop.
Injection
@Module
class TicketMachineModule {
@Provides
@Singleton
fun printer(display: Display) = Printer(display)
@Singleton
@Provides
fun display(): Display = Display()
@Singleton
@Provides
fun coinCounter(): CoinCounter = CoinCounter()
}
@Singleton
@Component(modules = [
TicketMachineModule::class
])
interface TicketMachineComponent {
val ticketMachine: TicketMachine
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment