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()
```
Published at
2024-01-17 06:31:16Event JSON
{
"id": "2248d3bf033f4a87fe6480d9cc0c35cea04050e2bdcb159c8495f3e800e8b295",
"pubkey": "2b9c6c28bce249a1ef28497a2ec6f6c01bc7be0721124b8ce7da3e1592080c57",
"created_at": 1705473076,
"kind": 1,
"tags": [
[
"e",
"0c467f1b248662962a410d796bac07a092add4b491f43bf62f6caa2561f3787a",
"wss://relay.mostr.pub",
"reply"
],
[
"proxy",
"https://androiddev.social/users/py/statuses/111769883519987952",
"activitypub"
]
],
"content": "What's that? Oh you want modules?\n\nAdd the factory maps!\n\n```\nval logModule = Linker()\nlogModule.installSingleton {\n CoffeeLogger()\n}\n\nval partsModule = Linker()\npartsModule.installSingleton\u003cHeater\u003e {\n ElectricHeater(get())\n}\npartsModule.install\u003cPump\u003e {\n Thermosiphon(get(), get())\n}\n\nval appModule = Linker()\nappModule.install {\n CoffeeMaker(get(), get(), get())\n}\n\nappModule.factories += logModule.factories + partsModule.factories\n\nval maker = appModule.get\u003cCoffeeMaker\u003e()\nmaker.brew()\n```",
"sig": "957938ee1c8b24fc8e4d7e404dac4f9335e1cebe2f5e8b89c51ddb485b815f541a23eef714a3f8dd6e4cf46b7985e02e63dae44c15785067ba1f27d088112e43"
}