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))
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.
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)
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.