winter / io.jentz.winter / Component / Builder / alias

alias

fun <R0 : Any, R1 : Any> alias(targetKey: TypeKey<R0>, newKey: TypeKey<R1>, override: Boolean = false): TypeKey<R0>

Create an alias entry.

Be careful, this method will not check if a type cast is possible.

Example:

singleton { ReposViewModel(instance()) }

alias(typeKey<ReposViewModel>(), typeKey<ViewModel<ReposViewState>>(generics = true))

Parameters

targetKey - The TypeKey of an entry an alias should be created for.

newKey - The alias TypeKey.

override - If true this will override an existing factory of type newKey.

Exceptions

EntryNotFoundException - If targetKey entry doesn't exist.

WinterException - If newKey entry already exists and override is false.

inline fun <reified R : Any> TypeKey<*>.alias(aliasQualifier: Any? = null, generics: Boolean = false, override: Boolean = false): TypeKey<*>

Create an alias entry for a TypeKey.

Be careful, this method will not check if a type cast is possible.

Example:

singleton {
  ReposViewModel(instance())
}.alias<ViewModel<ReposViewState>>(generics = true)

Parameters

aliasQualifier - The qualifier of the alias entry.

generics - If true this creates a type key that also takes generic type parameters into account.

override - If true this will override an existing factory for type R.