P-Y on Nostr: Ok so, while that Linker class is our entire Dependency Injection framework, we would ...
Ok so, while that Linker class is our entire Dependency Injection framework, we would like a little bit of syntactic sugar to make this easier.
First, we need to be able to add factories, i.e. tell our DI Framework how things should be build:
```
inline fun <reified T> Linker.install(noinline factory: Linker.() -> T) {
factories[T::class.java] = factory
}
```
Published at
2024-01-17 06:11:44Event JSON
{
"id": "c3a699230160576416ddb5dedab6656380ab9d3ec46f04269914b6fcf205455f",
"pubkey": "2b9c6c28bce249a1ef28497a2ec6f6c01bc7be0721124b8ce7da3e1592080c57",
"created_at": 1705471904,
"kind": 1,
"tags": [
[
"e",
"4f277a597a825f10267b9224e4ee734aa3b58743ada7f83161a4a0af4d35b992",
"wss://relay.mostr.pub",
"reply"
],
[
"proxy",
"https://androiddev.social/users/py/statuses/111769806755763114",
"activitypub"
]
],
"content": "Ok so, while that Linker class is our entire Dependency Injection framework, we would like a little bit of syntactic sugar to make this easier.\n\nFirst, we need to be able to add factories, i.e. tell our DI Framework how things should be build:\n\n```\ninline fun \u003creified T\u003e Linker.install(noinline factory: Linker.() -\u003e T) {\n factories[T::class.java] = factory\n}\n```",
"sig": "97b08b16134b172ac8ea00c68515bdca8ef5dda717e4cd9474102b882a001fe645917d5f6c79df91bb39d2adebc9ac953f79bb8ac4c37083217db23c701ff841"
}