putAlias
inline fun <TAlias : Any, TTarget : TAlias> ContextBuilderDsl.putAlias(aliasQualifier: Qualifier = EmptyQualifier, targetQualifier: Qualifier = EmptyQualifier): Declaration<TAlias>
Adds an alias to another component within this environment.
For example:
interface FooContract
class FooImpl
val env = tegralDi {
put(::FooImpl)
put<FooContract, FooImpl>()
}
val contract = env.get<FooContract>() // OK!
val impl = env.get<FooImpl>() // OK!
contract === impl // true
Content copied to clipboard
This overload is the inline-reified version. For non-reifiable use cases, see the KClass-based overload.
fun <TAlias : Any, TTarget : TAlias> ContextBuilderDsl.putAlias(aliasClass: KClass<TAlias>, aliasQualifier: Qualifier = EmptyQualifier, targetClass: KClass<TTarget>, targetQualifier: Qualifier = EmptyQualifier): Declaration<TAlias>
Adds an alias to another component within this environment.
For example:
interface FooContract
class FooImpl
val env = tegralDi {
put(::FooImpl)
put(aliasClass = FooContract::class, targetClass = FooImpl::class)
}
val contract = env.get<FooContract>() // OK!
val impl = env.get<FooImpl>() // OK!
contract === impl // true
Content copied to clipboard
This is the KClass-based overload. For most cases, you should use the inline-reified version instead.