Skip to content

Instantly share code, notes, and snippets.

@rachitmishra
Last active October 21, 2017 20:58
Show Gist options
  • Save rachitmishra/fb44d1c0c6ebbd5c118102c9d7dcbcc2 to your computer and use it in GitHub Desktop.
Save rachitmishra/fb44d1c0c6ebbd5c118102c9d7dcbcc2 to your computer and use it in GitHub Desktop.
dagger-module-provides
package di
import dagger.Module
import dagger.Provides
import di.dependencies.*
@Module
abstract class ComputerModule(private val memorySize: Int,
private val vMemorySize: Int) {
@Provides
fun providesRam(): Ram = Ddr5Ram(memorySize)
@Provides
fun providesGraphicRam(): VideoRam = Ddr5VideoRam(vMemorySize)
@Provides
@Named("large")
fun providesLargeGraphicRam(): VideoRam = Ddr5VideoRam(vMemorySize)
@Provides
fun providesMotherBoardWithLargeVideoRam(processor: Cpu,
ram: Ram,
@Named("large") videoRam: VideoRam): Gigabyte
= Gigabyte(processor, ram, videoRam)
@Module
companion object {
@Provides
@JvmStatic
fun providesPowerSupply(): Psu = Psu()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment