Injector

Main class to perform injections

Author

Pau Corbella

Since

1.0.0

Constructors

Link copied to clipboard
constructor()
constructor(resolverPool: ResolverPool, providerPool: ProviderPool)

Functions

Link copied to clipboard
open fun <T : Any> addInjectable(instance: T, environment: String? = null)

open override fun <T : Any> addInjectable(instance: T, type: KClass<out T>, environment: String?)

This method allows to add an injectable instance at runtime. No scopes are defined here, as you are supposed to manually control it by addInjectable/removeInjectable

Link copied to clipboard
open override fun <T : Any> create(clazz: KClass<T>, environment: String?, config: CreatorConfig.Builder.() -> Unit?): T

Creates an object of type clazz. Notice that this function will always return a new instance ignoring the scope it has.

Link copied to clipboard
open override fun <T : Any> inject(clazz: KClass<T>, environment: String?, config: InjectorConfig.Builder.() -> Unit?): T

Retrieves an object of type clazz (it will be created or provided depending on its Scope)

Link copied to clipboard
open override fun <T : Any> injectOrNull(clazz: KClass<T>, environment: String?, config: InjectorConfig.Builder.() -> Unit?): T?

Retrieves an object of type clazz (it will be created or provided depending on its Scope) If fails getting it, will return null

Link copied to clipboard
open override fun purge()

Frees memory that is not needed anymore

Link copied to clipboard
open override fun <T : Any> removeInjectable(type: KClass<T>, environment: String?)

This method allows to remove an injectable instance at runtime.

Link copied to clipboard
open override fun reset()

Resets all instances created by this time. This will force to recreate all instances Notice that objects which already have an injected classes will maintain them until recreated.