P-Y on Nostr: What's that? Oh you want modules? Add the factory maps! ``` val logModule = Linker() ...
What's that? Oh you want modules?
Add the factory maps!
```
val logModule = Linker()
logModule.installSingleton {
CoffeeLogger()
}
val partsModule = Linker()
partsModule.installSingleton<Heater> {
ElectricHeater(get())
}
partsModule.install<Pump> {
Thermosiphon(get(), get())
}
val appModule = Linker()
appModule.install {
CoffeeMaker(get(), get(), get())
}
appModule.factories += logModule.factories + partsModule.factories
val maker = appModule.get<CoffeeMaker>()
maker.brew()
```
Add the factory maps!
```
val logModule = Linker()
logModule.installSingleton {
CoffeeLogger()
}
val partsModule = Linker()
partsModule.installSingleton<Heater> {
ElectricHeater(get())
}
partsModule.install<Pump> {
Thermosiphon(get(), get())
}
val appModule = Linker()
appModule.install {
CoffeeMaker(get(), get(), get())
}
appModule.factories += logModule.factories + partsModule.factories
val maker = appModule.get<CoffeeMaker>()
maker.brew()
```