gh-pages / com.nextfaze.devfun.inject / CapturingInstanceProvider
CapturingInstanceProvider
class CapturingInstanceProvider<out T : Any> : InstanceProvider (source)
An instance provider that requests an instance of a class from a captured lambda.
Be aware of leaks! The lambda could implicitly hold a local this reference.
Be wary of using a typealias as a type - the resultant function “type” itself is used at compile time.
e.g.
typealias MyStringAlias = () -> String?
val provider1 = captureInstance<MyStringAlias> { ... }
typealias MyOtherAlias = () -> Type?
// will be triggered for MyStringAlias and MyOtherAlias since behind the scenes they are both kotlin.Function0<T>
val provider2 = captureInstance<MyOtherAlias> { ... }
See Also
Constructors
| Name | Summary | 
|---|---|
| <init> | CapturingInstanceProvider(instanceClass: KClass<T>, instance: () -> T?)An instance provider that requests an instance of a class from a captured lambda. | 
Functions
| Name | Summary | 
|---|---|
| get | fun <T : Any> get(clazz: KClass<out T>): T?Try to get an instance of some clazz. |