Question: what's best practice for hotpath extensi...
# kodein
a
Question: what's best practice for hotpath extension methods which need to refer to
DI
factories? Should I put the reference to the DI object into the [global state of] the file which includes the extension methods? For instance, something like:
Copy code
package foo

import something.Message

val extensionDI = someMethodToGetAholdOfTheDI()

internal fun Message.needsFooFactoryToMakeFoo(): Foo {
    val fooFactory by extensionDI.instance<FooFactory>()
    return fooFactory.newFooFromBytes(this.toByteArray())
}