I used to be able to create convenience functions ...
# kodein
r
I used to be able to create convenience functions for set bindings like this:
Copy code
fun DI.Builder.bindFoo() = bind<Foo>().inSet()
which I could then call like this:
Copy code
bindFoo() with singleton { ... }
It looks like
inSet
is deprecated now, and I have to create my convenience function like this:
Copy code
fun DI.Builder.bindFoo(binding: () -> DIBinding<*, *, out Foo>) =
  inBindSet { add(binding) }
which is ugly since the
DIBinding
type is no longer inferred by the compiler as its a parameter rather than a return value. Am I missing something? (More in thread)
Things become marginally better with a type alias:
Copy code
typealias DITypeBinding<T> = () -> DIBinding<*, *, out T>
and now I can declare:
Copy code
fun DI.Builder.bindFoo(binding: DITypeBinding<Foo>) =
  inBindSet { add(binding) }
but its still a bit ugly.